JS Client wrapper for Typeform API
# install with yarn
yarn add @typeform/api-client
# install with npm
npm install @typeform/api-client --save
- Import client library
import {createClient} from '@typeform/api-client'
- Create a instance with your personal token
const typeformAPI = createClient({
token: '<your token>'
})
- Use any of the methods available in the reference
// will retrieve all forms
typeformAPI
.forms
.list()
.then(response => {
// do what do you want with your typeforms
})
- Creates a new instance of Typeform's JS client
- Returns an instance with the methods described below
const typeformClient = createClient({
token: '<your token>'
})
Client returns the following properties:
forms
images
teams
workspaces
themes
responses
webhooks
Each one of them encapsulates the operations related to it (like listing, updating, deleting the resource).
- Get a list of your typeforms
- Returns a list of typeform with the payload referenced here.
- Get a typeform by UID
- Returns a typeform with the payload referenced here.
- Update a typeform by UID
- Returns a typeform with the payload referenced here.
- Get custom messages typeform of a given UID
- Updates custom messages typeform of a given UID
- Get your images collection
- Get custom image by ID
returns
: json, binary (default)size
: default, thumbnail, mobile,backgroundSize
: default, thumbnail, mobile, tabletchoiceSize
: default, thumbnail, supersize, supermobile, supersizefit, supermobilefit
- Update an image to Typeform
- Deletes an image with the given ID
- Gets team information for the given ID
- Add members to a team for the given ID
members
:string
or anarray
and should be the email fo the user- Adding multiple members at once is possible using an array of emails
- Remove members to a team for the given ID
members
:string
or anarray
and should be the email fo the user- Deleting multiple members at once is possible using an array of emails
- Gets your themes collection
page
: default1
pageSize: default
10`
- Gets a theme for the given ID
- Creates a theme with the given configuration
- See more details of the payload in the documentation
- Creates a theme with the given configuration
- See more details of the payload in the documentation
- Deletes the theme with the given ID
- Gets your workspaces
page
: default1
pageSize: default
10`search
: search a workspace that partially matches the search string
- Gets the workspace information for the given ID
- Gets the workspace information for the given ID
data
: operation that is wanted to perform, see more details in the documentation
- Deletes the workspace for the given ID
- Gets the workspace information for the given ID
- Add members to a workspace for the given ID
members
:string
or anarray
and should be the email fo the user- Adding multiple members at once is possible using an array of emails
- Remove members to a workspace for the given ID
members
:string
or anarray
and should be the email fo the user- Removing multiple members at once is possible using an array of emails
- List responses from the given ID
uid
: typeform UID- For parameter details check the documentation
- Get detailf for a webhook with the given tag
uid
: typeform UIDtag
: tag of the webhook created
- Create a webhook with the given tag
uid
: typeform UIDtag
: (string) tag of the webhook, how are you going to identify iturl
: (string) url of the service you want to notifyenable
: (bool)
- Update a webhook with the given tag
uid
: typeform UIDtag
: (string) tag of the webhook, how are you going to identify iturl
: (string) url of the service you want to notifyenable
: (bool)
- Delete for a webhook with the given tag
uid
: typeform UIDtag
: (string) tag of the webhook
Update specific typeform property, as referenced here
typeformClient
.forms
.update({
uid: 'asdf',
data: [
{
"op": "replace",
"path": "/title",
"value": 'new title'
}
]
})
.then(response => {
//...
})
typeformClient
.forms
.update({
uid: 'asdf',
override: true,
data: {
"title": newTitle,
"theme": {
"href": "https://api.typeform.com/themes/6lPNE6"
}
}
})
.then(response => {
//...
})
Note:
The theme property applies a theme
to the form. If you don't specify a value for the 'theme' property, Typeform applies a new copy of the default theme to the form, even if you already have a copy of the default theme applied to this form.
typeformClient
.images
.add({
image: "bGRqZmxzZGpmbHNoZmtoc2RrZmpoc2tqZA==",
mediaType: "image/gif",
fileName: "newimage.gif"
})
.then(response => {
//...
})
typeformClient
.images
.get({ id: 'asdf', size: 'thumbnail' })
.then(response => {
//...
})
The project has implemented unit tests.
yarn install
# Runs unit tests
yarn test:unit
Fill out this conversation 🙂