Add rows to Google Sheets from Python
Log rows from Python scripts, notebooks, scrapers or backend jobs with the requests library.
- 1
Get your sheet and access key ready
Create a Google Sheet (headers are optional: we'll add a column for each field) and share it with this address as an Editor:
sheetcapture@appspot.gserviceaccount.comCopy the sheet ID from its URL (the part between
/d/and/edit), and your access key from your account page. No account yet? Start free. - 2
Send a row
Install requests with pip install requests, then:
import os import requests def add_row(data): response = requests.post( "https://www.sheetcapture.com/add-row", headers={"Authorization": f"Bearer {os.environ['SHEETCAPTURE_KEY']}"}, json={"GoogleSheetID": os.environ["GOOGLE_SHEET_ID"], "data": data}, timeout=30, ) if not response.ok: raise RuntimeError(response.json()["error"]) add_row({"Name": "Ada Lovelace", "Email": "ada@example.com"})
Every response includes X-Requests-Remaining, so long-running jobs can keep an eye on their allowance.
Want every option?
The API docs cover responses, limits and error codes.