Skip to content

Google Sheets API

remkohdev edited this page Mar 9, 2017 · 5 revisions

https://developers.google.com/sheets/api/guides/values

Setup

To Parse this Conferences doc:

Original example:

https://docs.google.com/spreadsheets/d/1WYQ0bi8c6OLGx9ZPgUHhGG3x7unIPz1XpODj7OrHPDE/edit#gid=552525635

In the URL you see the spreadsheetid (1WYQ0bi8c6OLGx9ZPgUHhGG3x7unIPz1XpODj7OrHPDE) and the sheetid (552525635).

Cleaned-up example:

https://docs.google.com/spreadsheets/d/1Xa_JjB4x36GSpULvJZMf6Lt8RJcp9N9naixpJSsWN_g/edit#gid=552525635

Api Key

You also need an API KEY:

https://developers.google.com/sheets/api/guides/authorizing#APIKey

Enable the Sheets API, and you're good to go.

Examples

curl -X GET "https://sheets.googleapis.com/v4/spreadsheets/1WYQ0bi8c6OLGx9ZPgUHhGG3x7unIPz1XpODj7OrHPDE/values/'2017'!A4:A9?key=your-apikey;"

https://sheets.googleapis.com/v4/spreadsheets/1WYQ0bi8c6OLGx9ZPgUHhGG3x7unIPz1XpODj7OrHPDE/values/'2017'!A:K?key={{eventquarry_key}}&majorDimension=ROWS

https://sheets.googleapis.com/v4/spreadsheets/1WYQ0bi8c6OLGx9ZPgUHhGG3x7unIPz1XpODj7OrHPDE/values/'2017'!A:K?key={{eventquarry_key}}&majorDimension=COLUMNS

Cleaned-up example:

https://sheets.googleapis.com/v4/spreadsheets/1Xa_JjB4x36GSpULvJZMf6Lt8RJcp9N9naixpJSsWN_g/values/'2017'!A:K?key={{eventquarry_key}}&majorDimension=ROWS

Postman collection for Google API

https://www.getpostman.com/collections/7341ad011f7f687a0a13

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://sheets.googleapis.com/v4/spreadsheets/1WYQ0bi8c6OLGx9ZPgUHhGG3x7unIPz1XpODj7OrHPDE/values/%272017%27%21A4:A9?key=your-apikey",
  "method": "GET",
  "headers": { }
}
$.ajax(settings).done(function (response) {
  console.log(response);
});
Clone this wiki locally