Retrieving data from the kobo rest api

How do I retrieve data for a form using the rest API in a different format, say csv or xls. The json format returned is quite difficult parse since each form might have different keys for the data field.
I noticed that on the toolbox website, one could export as xls and was wondering if similar functionality was available via the API

Dear Michael,

If you are interested to use R, here are the functions and working examples that download CSV data from KoBo using API and save it as xlsx.

Best regards,

Punya

···

On Wednesday, September 12, 2018 at 9:15:39 AM UTC+3, Michael Bukachi wrote:

How do I retrieve data for a form using the rest API in a different format, say csv or xls. The json format returned is quite difficult parse since each form might have different keys for the data field.
I noticed that on the toolbox website, one could export as xls and was wondering if similar functionality was available via the API

1 Like

Dear all,

I am using stata. It is very difficult for me to have database in stata format with labels and codes. Do we have a simple way to convert database from kobo to stata format with labels and codes?

Thanks in advance

···

**ABOUDOU Rachidi, (****Msc) ****Agricultural Economist, **


Figured it out from your code. A call to the following url ‘https://kc.kobotoolbox.org/api/v1/data/formid.xls’ returns an excel document.

···

On Wednesday, September 12, 2018 at 2:46:47 PM UTC+3, Punya Sapkota wrote:

Dear Michael,

If you are interested to use R, here are the functions and working examples that download CSV data from KoBo using API and save it as xlsx.

https://github.com/ppsapkota/kobohrtoolbox/blob/master/R/r_func_ps_kobo_utils.R

https://github.com/ppsapkota/kobohrtoolbox/blob/master/R/00_1_r_ps_kobo_export_data.R

Best regards,

Punya

On Wednesday, September 12, 2018 at 9:15:39 AM UTC+3, Michael Bukachi wrote:

How do I retrieve data for a form using the rest API in a different format, say csv or xls. The json format returned is quite difficult parse since each form might have different keys for the data field.
I noticed that on the toolbox website, one could export as xls and was wondering if similar functionality was available via the API

Hi dear @punya ,
I use your api to download my dataset but i have a problem.
We appload the kobo form last week by adding other questions in the first form.
Now, we i download dataset, there are some variables wich are empty and all are the new variables.
NB: The asset_uid not changed

I know this is two years late from the original question by @punya but I had the same issue - wanted to use an R script to download data from KoBo using the API.

I was able to use the GET function in the curl package in R. Very simple- just the url of your file, username, password, and where you would like to write the file.

URL is the extension with the form ID.
url <- “https://kc.humanitarianresponse.info/api/v1/data/form_id.xlsx

GET(url,authenticate(“username”,“password”),progress(),write_disk(“example.xlsx”))

Hope this helps anyone else trying to use R to download through KoBo’s API

Welcome to the community @mark.buttweiler! I have moved your post here so that you could benefit from the response provided by Punya_Sapkota.

1 Like