How to retrieve data from Kobo Toolbox using Python and load it into PostgreSQL?

Hi everyone,

I’m trying to fetch data from Kobo Toolbox using Python and load it into a PostgreSQL database. However, I’m unsure how to get the correct URL for the API request. Is it the same URL we use to download CSV or XLSX files, or is there a different URL specifically for this task? Any guidance would be greatly appreciated!

Thank you!

Hi @Abessolo, there is two option i believe. One you can use the CSSV or XLSX link to fecth data from Commcare, which is easier to work with but if you need the data in JSON format there is another link to fecth the data.

https ://eu.kobotoolbox.org/api/v2/assets/{form uuid}/data.json

1 Like

Hi @osmanburcu

Sorry if my questions sound a bit beginner, but I’d really appreciate your help!

  1. When data analysts fetch data from Kobo to load it into PostgreSQL using Python, which URL is more commonly used — the JSON data URL or the CSV/XLSX data URL?
  2. I know how to get the CSV or XLSX URL, but I’m having trouble finding the JSON URL. I went to my project, then to “Share,” and got this link:
    KoboToolbox
    I also checked under “Account settings” and found the email address, password, and API key, which looks like:
    9afxxxxda51f03dxxxabb855755f09e44482xxxx
    But I can’t figure out which one is the JSON URL.
  3. Apart from the JSON URL, is there any other detail I would need to fetch and load the data into PostgreSQL?

Thank you for your guidance!

@Abessolo Hi, no worries.

1- I am not really familiar with the PostgreSQL, but i believe It really depends on your familiarity with the JSON, CSV or XLSX. You need to test both and decide it yourself.

2- https://eu.kobotoolbox .org/api/v2/assets/{form uuid}/data.json just replace the {fom uuid} with your form’s uuid. If you are going to do a get request by using python you either can user name and password or API Key. It is up to you.

3- As i mention in the first question, i don’t have much information about the PostgreSQL, i have the SQL experience but the PostgreSQL so you if anyone has that experience in the community might share their experience with you soon

1 Like