Using the API — KoboToolbox documentation (original) (raw)

Using the API

Last updated: 21 Sep 2023

KoboToolbox has a number of advanced features built in based on our open source libraries, which include useful add-ons for advanced use cases. There are many ways to use our API. For some hands-on examples,see this post.

KoboToolbox has two APIs for its primary tools, kpi and kc. Originally kc was the only api for deploying forms and retrieving data. Now, kpi is the primary API that should be used.

The base URL depends on the server you are using: for most users it iskf.kobotoolbox.org oreu.kobotoolbox.org. Below we only use [kpi-url] to refer to this base URL.

Getting your API Token:

There are different ways to get your API Token.

Method 1:

To find your API token go tohttps://[kpi-url]/token/?format=json

image

Method 2:

Method 3:

You could use the following curl command:

curl -u username:password "https:/[kpi-url]/token/?format=json"

Testing your API:

To test it use this command:

curl -X GET https://[kpi-url]/api/v2/assets.json -H "Authorization: Token [your_token_goes_here]"

You can also use tools like Postman to build and test your API snippets:

image

For more details on using the API follow these endpoints (selection only):

https://[kpi-url]/api/v2/assets/ (list of all assets, including forms/projects, questions, blocks, templates, collections; for each asset there are several additional sub-endpoints)https://[kpi-url]/api/v2/assets/{asset_uid}/data/(access submitted data) https://[kpi-url]/exports/(create or view data exports)

You can find more examplesin this forum post.

Was this article useful?

Did you find what you were looking for? Was the information clear? Was anything missing?
Share your feedback to help us improve this article!

Fill out the short survey here →