[ODK2] Example of use of REST API in Python

Hi

Does anyone have a python script to show the use of the REST API ?
I would like to get data from the ODK2 Sync endpoint.

Thanks

Karim

Hi,

See link for the API documentation. It has a list of all the API endpoints along with their parameters and outputs.

We currently don’t have examples in Python but the API is fairly straightforward. Though we do have a Java library, see my reply in the thread ODK Aggregate replacement - API to share ODK2 forms with ODK Survey - #3 by linl33 for detail.

A simple example using the requests library to fetch a list of tables
With a server at the address https://odk-sync-endpoint-example/, and the user admin:password

import requests

#  fetch tables through HTTP GET and authenticating with HTTP Basic Auth (admin:password)
res = requests.get('https://odk-sync-endpoint-example/odktables/default/tables', auth=('admin', 'password'))

#  get JSON response
res.json()

Thanks !
Got it working