How to export a csv from Google Sheet API?

user1447414 picture user1447414 · Jun 8, 2016 · Viewed 18.4k times · Source

I can't find any reference to an API that enables Rest API clients to export an existing Google Sheet to a csv file.

https://developers.google.com/sheets/

I believe there should be a way to export them.

Answer

Overbryd picture Overbryd · Apr 8, 2020

The following URL gives you the CSV of a Google spreadsheet per sheet. The sheet must be accessible by the public, by anyone with the link (unlisted).

The parameters you need to provide are:

  • sheet ID (that is simply the ID in the URL of a Google Spreadsheet https://docs.google.com/spreadsheets/d/{{ID}}/edit)
  • sheet name (that is simply the name of the sheet as given by the user)
https://docs.google.com/spreadsheets/d/{{ID}}/gviz/tq?tqx=out:csv&sheet={{sheet_name}}

With that URL you can run a GET-request to fetch the CSV. Or paste it in your browser address bar.