Skip to main content

kobotoolbox@4.1.0

getDeploymentInfo(formId)
getForms()
getSubmissions(formId, [options])

This adaptor exports the following namespaced functions:

http.get(path, [options])
http.post(path, data, [options])
http.put(path, data, [options])
http.request(method, path, [options])

This adaptor exports the following from common:

alterState()
cursor()
dataPath()
dataValue()
each()
field()
fields()
fn()
fnIf()
group()
lastReferenceValue()
merge()
sourceValue()

Functions

getDeploymentInfo

getDeploymentInfo(formId) ⇒ Operation

Get deployment information for a specific form. Calls /api/v2/assets/<id>/deployment/.

ParamTypeDescription
formIdstringForm Id to get the deployment information

This operation writes the following keys to state:

State KeyDescription
dataan object containing deployment information
Example
getDeploymentInfo('aXecHjmbATuF6iGFmvBLBX');

getForms

getForms() ⇒ Operation

Make a request to fetch all survey forms accessible to the authorized user. Calls /api/v2/assets/?asset_type=survey.

This operation writes the following keys to state:

State KeyDescription
dataan array of form objects
Example
getForms();

getSubmissions

getSubmissions(formId, [options]) ⇒ Operation

Get submissions for a specific form. Calls /api/v2/assets/<formId>/data/

ParamTypeDefaultDescription
formIdstringForm Id to get the specific submissions
[options]object{}Options to control the request
[options.sort]objectField and direction to sort submissions by.
[options.query]objectQuery options to filter the submissions. See query operators http://docs.mongodb.org/manual/reference/operator/query/.
[options.start]number0The index of the first submission to return.
[options.limit]number30000Maximum number of submissions to fetch. Pass Infinity to disable the limit and download all submissions
[options.pageSize]number10000Limits the size of each page of submissions. Maximum value is 30000.

This operation writes the following keys to state:

State KeyDescription
dataan array of submission objects
Example: Get submissions for a specific form
getSubmissions('aXecHjmbATuF6iGFmvBLBX');.

Example: Get all submissions for a specific form

getSubmissions('aXecHjmbATuF6iGFmvBLBX', { limit: Infinity });

Example: Get form submissions with a query

getSubmissions('aXecHjmbATuF6iGFmvBLBX', { query: { _submission_time:{ $gte: "2025-03-12T21:54:20" } } });

Example: Get form submissions with sorting

getSubmissions('aXecHjmbATuF6iGFmvBLBX', { sort: { _submission_time: -1 } });

Example: Get form submissions with specific start index

getSubmissions('aXecHjmbATuF6iGFmvBLBX', { start: 10 });

http

These functions belong to the http namespace.

http.get

get(path, [options]) ⇒ operation

Make a GET request to any KoboToolbox endpoint.

ParamTypeDefaultDescription
pathstringpath to resource
[options]HTTPRequestOptions{}An object containing query params and headers for the request

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the KoboToolbox server (excluding the body)
referencesAn array containing all previous data objects
Example: GET assets resource
http.get('assets')

http.post

post(path, data, [options]) ⇒ operation

Make a POST request to a KoboToolbox endpoint

ParamTypeDefaultDescription
pathstringpath to resource
dataanythe body data in JSON format
[options]HTTPRequestOptions{}An object containing query params and headers for the request

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the KoboToolbox server (excluding the body)
referencesAn array containing all previous data objects
Example: Create an asset resource
http.post(
'/assets/',
{
name: 'Feedback Survey Test',
asset_type: 'survey',
},
);

http.put

put(path, data, [options]) ⇒ operation

Make a PUT request to a KoboToolbox endpoint

ParamTypeDefaultDescription
pathstringpath to resource
dataanythe body data in JSON format
[options]HTTPRequestOptions{}An object containing query params and headers for the request

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the KoboToolbox server (excluding the body)
referencesAn array containing all previous data objects
Example: Update an asset resource
http.put(
'assets/a4jAWzoa8SZWzZGhx84sB5/deployment/',
{
name: 'Feedback Survey Test',
asset_type: 'survey',
},
);

http.request

request(method, path, [options]) ⇒ Operation

Make a HTTP request to any KoboToolbox endpoint

ParamTypeDefaultDescription
methodstringHTTP method to use
pathstringPath to resource
[options]HTTPRequestOptions{}An object containing query, headers, and body for the request

This operation writes the following keys to state:

State KeyDescription
dataThe response body (as JSON)
responseThe HTTP response from the KoboToolbox server (excluding the body)
referencesAn array containing all previous data objects
Example: Bulk updating of submissions
http.request("PATCH", `assets/${$.form_uid}/data/bulk/`, {
body: {
submission_ids: [$.data.submission_id],
data: {
Transaction_status: "success",
},
},
});

Interfaces

HTTPRequestOptions

Options object

Properties

NameTypeDefaultDescription
queryobjectAn object of query parameters to be encoded into the URL
headersobjectAn object of all request headers
bodyobjectThe request body (as JSON)
maxRedirectionsnumberThe maximum number of redirects to follow
[parseAs]string"'json'"The response format to parse (e.g., 'json', 'text', or 'stream')