Introducing the Google Sheets API v4: Transferring data from a SQL database to a Sheet
At Google I/O 2016, we launched a new Google Sheets API —click here to watch the entire announcement. The updated API includes many new features that weren’t available in previous versions, including access to functionality found in the Sheets desktop and mobile user interfaces. My latest DevByte video shows developers how to get data into and out of a Google Sheet programmatically, walking through a simple script that reads rows out of a relational database and transferring the data to a brand new Google Sheet.
Let’s take a sneak peek of the code covered in the video. Assuming that
SHEETS has been established as the API service endpoint,
SHEET_ID is the ID of the Sheet to write to, and
is an array with all the database rows, this is the only call developers need to
make to write that raw data into the Sheet:
range='A1', body=data, valueInputOption='RAW').execute()
Reading rows out of a Sheet is even easier. With
SHEET_ID again, this is all you need to read and display those
rows = SHEETS.spreadsheets().values().get(spreadsheetId=SHEET_ID,
for row in rows:
We hope all these resources help developers create amazing applications and awesome tools with the new Google Sheets API! Please subscribe to our channel, give us your feedback below, and tell us what topics you would like to see in future episodes!