0.1.2 • Published 9 years ago

typeform-js v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

#typeform-js

typeform client for node and the browser

##Installation

clone this repo

##Usage

import (ES6) or require the package and set your API-key for authentication. Every method of the library returns a promise tha will be fulfilled with typeform.io's response.

src folder contain the ES6 version. dist folder contains the ES5 version.

import Typeform from 'typeform-js';

let typeform = Typeform('MY_API_SECRET');

##Available endpoints

###base

The base endpoint response contains information about the API.

example

typeform.base().then( res => console.log(res));

###forms

####Create a form

arguments:

CommandTypeOptionalDescription
Titlestringnoform title
Fieldsarraynoform fields
Extraobjectyesextra options

example

typeform.form( "My first typeform",
    [
        {
            "type": "short_text",
            "question": "What is your name?"
        }
    ],
	{ "branding": false }
);

####Get a form

arguments:

CommandTypeOptionalDescription
Idstringnoform id

example:

typeform.form.get( 'id' );

###images

####send an image

arguments:

CommandTypeOptionalDescription
Urlstringnourl to sent

example

typeform.image( "http://MY_IMAGE.URL");

####Get an image

arguments:

CommandTypeOptionalDescription
Idstringnoimage id

example:

typeform.image.get( 'id' );

###designs

####Create a design

arguments:

CommandTypeOptionalDescription
Colorsobjectnodesign colors
Fontstringnogoogle web font for this design

example

typeform.design({
        "question": "#3D3D3D",
        "button": "#4FB0AE",
        "answer": "#4FB0AE",
        "background": "#FFFFFF"
    },
    'Playfair'
);

####Get a design

arguments:

CommandTypeOptionalDescription
Idstringnodesign id

example:

typeform.design.get( 'id' );

###urls

####Create a new url

arguments:

CommandTypeOptionalDescription
form_idobjectnoactual id

example

typeform.url('anId');

####Get a url

arguments:

CommandTypeOptionalDescription
Idstringnourl id

example:

typeform.url.get( 'id' );

###Get a url

arguments:

CommandTypeOptionalDescription
Old_idstringnocurrent url id
New_idstringnonew url id

example:

typeform.url.set( 'id', 'newSuperCoolId' );

#TODO

  • fields Objects?