An API for exporting CSVs

Hi everyone.

I have built out an endpoint for exporting base to CSV. Documentation can be found here

Here is the api.

https://csv-getter-for-airtable.ew.r.appspot.com/all-csv?bid=<your_base_id>&apik=<your_api_key>&tname=<your_table_name>&vname=<your_view_name>

With the correct parameters it will give the latest version of your base as CSV and will be useful in python scripts etc. Any issues getting it working please check out the docs or reach out.

Additionally, any questions or concerns about how keys or data is handled that are not addressed in the docs - i’ll be happy to answer :slight_smile:

2 Likes

@GavinA, this is very impressive! Would you care to elaborate how you were technically able to achieve this? Better yet, could you open source the code on GitHub so I can take a look at it?

HI @jonathanlaniado,

Thanks for your kind words. Of course. The app is written in Python and utilises Flask and Pandas. The script (when triggered) communicates with the Airtable API. Using the api key, base id, table name and view name passed by the user, it queries the referenced table and handles any pagination. Everything is piped into a pandas dataframe and pandas’ to_csv() method is used to convert the dataframe to csv. The csv is passed back to the caller through the route so nothing is stored.

The api is hosted using google app engine.

Pros:

  • Link is reusable – meaning it will always have your latest data. This can be handy for scheduled jobs or for giving non-airtable users access to latest updates
  • Users will not need to worry about pagination or json format if they are interested in working with CSV.

Cons:

  • The api key is visibile in the URL meaning you should only be sharing the populated URL with people you trust. (To make this more secure, the api key, table name and view name could be stored and referenced by an id. This id could be visibile in the URL instead and will be meaningless for other applications – I could build this out if there is a decent demand)
  • Getting all the params passed into the URL can be fiddly. We have submitted an app to the marketplace to generate the URL automatically for a given table. Hopefully this will be reviewed and released soon!

Good idea about sharing the code on Github. When I have some time, I’ll clean it up and share it through the docs!

1 Like

UPDATE: The api was giving the “something went wrong” error for some bases that feature the “Multiple select” field. This has been fixed as of 31/10/21

Thanks so much for your reply! This is why I’d love to see the Python in GitHub. We could verify the level of privacy and repurpose the script to increase its security.

No rush, but I would love to see it once it’s ready. :blush:

@jonathanlaniado. The code is now open source and available on Github. You’ll find it here and it is also now available on the docs :slight_smile:

1 Like