Show labels for choices when data is pulled

Hello family!
I hope you are all doing well?
I would like to know if there is any update on how to pull data Kobo to power bi showing the labels instead of the xml values using the API version 2

1 Like

Welcome to the community, @Alex_ousman! We will let you know when we resolve this issue.

Okay thanks and hope there is any workaround
If any please help

A workaround is well illustrated here: Show 'Labels' instead of XML Values in KoBoToolbox using jr:choice-name! - YouTube
Essentially runs a jr calc to record the label making it available as a field to share/pull.

Except, I spoke too soon. This is not an advised route, there seem to be all sorts of glitches when using jr:choice-name. Mine current is that I cannot then share that field dynamically…

@Kal_Lam Is there any update on whether this is possible?

Can you be more specific about what the issue(s) are that you are seeing using jr:choice-name for this?

It is a bit tricky to get right, I admit, but you should be able to use a calculation with jr:choice-name() to get the label for a select_one, and this calculated field should be shareable ‘dynamically’, just like any other submission field [Note, this calculated field with the select option label could also be pulled down into, say, PowerBI and used instead of the original selected option value].

Or, if you have the same choice list in both your child form and parent form, the child form can also lookup the label corresponding to a dynamically shared value. So there are a few possible options here - if you can be more specific about what you are trying to do I might be able to offer some suggestions.

@Xiphware I’m trying to get the same end result as Chris but without having to create a calculation field for every select_one or select_multiple question. This would increase the speed and cost of processing the data.

I saw it possible in the v1 API which is being phased out:
https://support.kobotoolbox.org/migrating_api.html

Is there a way to pull the question labels and choices labels using an API?

Yes, you can still obtain the label(s) associated with a specific question - be it a select_one, select_multiple or regular question - as well the label(s) associated with specific choice options, via the v2 API. It’s just a little more involved, and they’re not all nicely bundled up in a dictionary for you. :slightly_smiling_face:

As a working example, here’s my form:

a3pXrHbMdVJMKRxAyJfakd.xlsx (6.4 KB)

I’m going to use command-line curl and jq here to illustrate the API calls involved, but you can use your favorite API client to accomplish the same.

First, you need to obtain your token to authenticate against the v2 endpoints, using your regular Kobo username (eg $USERID) and password (eg $PASSWORD) [you may be doing this already, but just for completeness]:

% KPI=‘https://kf.kobotoolbox.org’

% curl -s -u $USERID:$PASSWORD “$KPI/token/”
{“token”:“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”}

Your forms are under the v2 endpoint here $KPI/api/v2/assets/. To find your specific form you can query this endpoint and filter the result for a specific form name, or whatever other unique identifier you wish; the goal is to obtain the target form’s url (or, equivalently, its asset uid):

% FORMNAME=‘Simple Form’

% curl -s -H “Authorization: Token $TOKEN” “$KPI/api/v2/assets/” | jq “.results
 | select(.name == "$FORMNAME")”
{
“url”: “https://kf.kobotoolbox.org/api/v2/assets/a3pXrHbMdVJMKRxAyJfakd/”,
“date_created”: “2025-06-09T20:42:30.818103Z”,
“date_modified”: “2026-01-04T21:35:12.768276Z”,
“date_deployed”: “2026-01-01T22:36:07.880470Z”,
“owner”: “https://kf.kobotoolbox.org/api/v2/users/tiritea/”,
“summary”: {
“geo”: false,
“labels”: [
  “What is your name?”,
  “Do you have any children?”,
  “how old is your eldest child?”
],
“columns”: [
  “name”,
  “type”,
  “label”,
  “required”,
  “select_from_list_name”,
  “relevant”
],
…

Now, if we fetch the form’s url we can obtain all the info about the form, which includes these question and choice labels:

% URL=‘https://kf.kobotoolbox.org/api/v2/assets/a3pXrHbMdVJMKRxAyJfakd/’

% curl -s -H “Authorization: Token $TOKEN” $URL | jq .
{
“url”: “https://kf.kobotoolbox.org/api/v2/assets/a3pXrHbMdVJMKRxAyJfakd/”,
…

If you look at the rest of the returned response payload, you will see the content: {survey: []} dictionary, which has all your questions along with their name and label(s). label is an array because you may well have defined multiple language localizations. I haven’t so I can just use the first, ie label[0] to get my desired target label, but if you have then you’ll need to determine which language label you want back.

% curl -s -H “Authorization: Token $TOKEN” “$FORMURL” | jq .content.survey

[
{
“name”: “start”,
“type”: “start”,
“$kuid”: “1EhVHouKs”,
“$xpath”: “start”,
“$autoname”: “start”
},
{
“name”: “end”,
“type”: “end”,
“$kuid”: “L5zlgXX2K”,
“$xpath”: “end”,
“$autoname”: “end”
},
{
“name”: “name”,
“type”: “text”,
“$kuid”: “I2VfrvYib”,
“label”: [
  “What is your name?”
],
“$xpath”: “name”,
“required”: false,
“$autoname”: “name”
},
{
“name”: “isParent”,
“type”: “select_one”,
“$kuid”: “DQhpLjGM6”,
“label”: [
  “Do you have any children?”
],
“$xpath”: “isParent”,
“required”: true,
“$autoname”: “isParent”,
“select_from_list_name”: “yes_no”
},
…

Extracting specific fields this from the payload will depend on what API client tool you are using, but with jq it looks like:

% FIELDNAME=‘isParent’

% curl -s -H “Authorization: Token $TOKEN” “$URL” | jq “.content.survey
 | select(.name == "$FIELDNAME").label[0]”
“Do you have any children?”

So there is the label “Do you have any children?” for my form question isParent. :tada:

You can accomplish something similar to obtain the choice labels; these are under the content: {choices: []} dictionary:

% curl -s -H “Authorization: Token $TOKEN” “$FORMURL” | jq .content.choices

[
{
“name”: “0”,
“$kuid”: “IguEPoyT2”,
“label”: [
  “no”
],
“list_name”: “yes_no”,
“$autovalue”: “0”
},
{
“name”: “1”,
“$kuid”: “0VfDdo68V”,
“label”: [
  “yes”
],
“list_name”: “yes_no”,
“$autovalue”: “1”
}
]

The jq to get the label for a specific choice name in a specific choice list is:

% LISTNAME=‘yes_no’
% CHOICENAME=‘1’

% curl -s -H “Authorization: Token $TOKEN” “$FORMURL” | jq “.content.choices
 | select(.list_name=="$LISTNAME" and .name=="$CHOICENAME").label[0]”
“yes”

% CHOICENAME=‘0’

% curl -s -H “Authorization: Token $TOKEN” “$FORMURL” | jq “.content.choices
 | select(.list_name=="$LISTNAME" and .name=="$CHOICENAME").label[0]”
“no”

So there are the labels for my choices. :tada:

Hopefully that’s enough to get you going! :slightly_smiling_face:

For completeness, if you have added language translations to your form, then you will need to cross-reference the label arrays against the ordered list of supported languages, to know which indexed string to use. Specifically:

% FIELDNAME=‘isParent’

% curl -s -H “Authorization: Token $TOKEN” “$FORMURL” | jq “.content.survey
 | select(.name == "$FIELDNAME").label”
[
“Do you have any children?”,
“Avez-vous des enfants?”,
“Tienes hijos?”
]

% curl -s -H “Authorization: Token $TOKEN” “$FORMURL” | jq “.content.translations”
[
“English (en)”,
“French (fr)”,
“Spanish (es)”
]