How do I get the id of a form using python?

Hi, I have a project with multiples forms uploaded and and I would like to know how can I get the id of certain forms using python and my access token. For now I have this:

import requests
import json

TOKEN = ‘xxxxxxxxxxxxxxxxx’
PARAMS = {‘format’: ‘json’}
HEADERS = {‘Authorization’: f’Token {TOKEN}’}
URL = ‘’+asset+’/data/bulk/
payload = { }
res = requests.patch(url= URL, data= {‘payload’: json.dumps(payload)}, params= PARAMS, headers= HEADERS)

Could you help me with the script? Or if there is a way to do it with Kobo_kpi I would appreciate if you could tell me how to do it.

Hi @Akratos, you can find some helpful examples here:

Hi @Josh, I could only get this far. I need to do a search by names (e, “louis”) in the form and get the data of that person:

import requests
import json

TOKEN = ‘xxxxxxxxxxxxxxxxxxxxx’
PARAMS = {‘format’: ‘json’}
HEADERS = {‘Authorization’:f’Token {TOKEN}’,‘Accept’: ‘application/json’}

URL = ‘
payload = {‘group_pe65x02/Nombre_de_la_persona_encuestada’: ‘louis’}
res = requests.get(url=URL,headers= HEADERS,params= PARAMS,data= {‘payload’: json.dumps(payload)})

The server response is successful but I only get

<Response [200]>

I would like to have the _id of that record or any other data. Could you help me with the script?

Hi @Akratos, you can use the query parameter to do this kind of lookup through the API. The documentation is here (replace with your asset UID):<your asset uid>/data/#query-submitted-data

So your URL should like something like:<your asset uid>/data?format=json&query={"group_pe65x02/Nombre_de_la_persona_encuestada": "louis"}

Or in Python, something like:

import requests
import json

TOKEN = 'your_secret_token'
ASSET_UID = 'your_asset_uid'
URL = f'{ASSET_UID}/data'
    'format': 'json',
    'query': json.dumps({
        'group_pe65x02/Nombre_de_la_persona_encuestada': 'louis'
    'Authorization': f'Token {TOKEN}'

res = requests.get(url=URL, params=PARAMS, headers=HEADERS)

assert res.status_code == 200

print(json.dumps(res.json(), indent=2))

Since you asked about getting <Response [200]>, it seems you might need to familiarize yourself with the Python requests library and interacting with data through APIs. This might be a helpful resource: Python & APIs: A Winning Combo for Reading Public Data – Real Python

1 Like

Thank you very much @Josh. Your answer is very helpful and the documentation about python too. :+1: