• Stars
    star
    604
  • Rank 74,189 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 3 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

💾 An API to get a Google Sheet as JSON, no authentication required.

opensheet

A free, super simple, hosted API for getting Google Sheets as JSON.

Tutorial blog post: benborgers.com/posts/google-sheets-json

If you have questions: [email protected]

Documentation

This API returns a given Google Sheet’s rows as JSON data.

In order to use it:

  1. The first row of your Google Sheet should be a header row (here’s an example).
  2. Link sharing must be turned on so anyone with the link can view the Google Sheet.

The format for this API is:

https://opensheet.elk.sh/spreadsheet_id/tab_name

For example:

https://opensheet.elk.sh/1o5t26He2DzTweYeleXOGiDjlU4Jkx896f95VUHVgS8U/Test+Sheet

You can also replace tab_name with the tab number (in the order that the tabs are arranged), if you don’t know the name. For example, to get the first sheet:

https://opensheet.elk.sh/1o5t26He2DzTweYeleXOGiDjlU4Jkx896f95VUHVgS8U/1

Take note that the first sheet in order is numbered 1, not 0.

Caching

Responses are cached for 30 seconds in order to improve performance and to avoid hitting Google Sheets’ rate limits, so it might take up to 30 seconds for fresh edits to show up in the API response.

Recent hosting changes

I’ve moved the hosted instance of opensheet through a couple providers:

  • First Vercel, which ended up being too expensive.
  • Then Railway, which ended up being a bit unreliable.
  • Most recently, Cloudflare Workers!

Note that the base URL is now opensheet.elk.sh, not opensheet.vercel.app. opensheet.vercel.app will continue to redirect to the correct URL, but you should update your code to use opensheet.elk.sh to avoid the slight performance degradation that comes from needing to redirect.

Self-hosting

This section is only necessary if you want to fork opensheet and host your own instance of it. If you don’t want to deal with that, you’re welcome to use my hosted instance at opensheet.elk.sh.

opensheet is written as a Cloudflare Worker. It uses Cloudflare’s Cache API for caching, however note that the Cache API only works on custom domains (not *.workers.dev domains).

If you host opensheet in your own Cloudflare account or make a fork, you’ll need to get your own Google Sheets API key:

  1. Go to the Google Cloud Console and create a new project from the top navigation bar.
  2. Search for “Google Sheets API” and enable it.
  3. Search for “Credentials” and create an API key. If you want, you can restrict it to only be able to access the Google Sheets API.
  4. Run npm run add-env-variables and paste in the API key.

Local development

npm run dev

Deployment

npm run deploy

Troubleshooting

For some reason, I was getting the error Error: expected value at line 1 column 1 when running npm run dev. I fixed this by uncommenting the workers_dev line and commenting the route line in wrangler.toml.

More Repositories

1

potion

🧪 Reverse-engineered Notion API.
JavaScript
339
star
2

emojicdn

🥳 A fast, global content delivery network for emojis.
Ruby
141
star
3

driver

🏎 A quick and simple API for reading Google Drive and Google Docs.
JavaScript
12
star
4

glitch-proxy

🕳 Proxy server for Glitch.
11
star
5

ben.page

🐙 My personal website!
Astro
10
star
6

notion-api

🪄 Notion API client for Node.js
JavaScript
8
star
7

stickies

📒 Note-taking app built around a board of virtual sticky notes.
TypeScript
6
star
8

figure

🖼 An asset pipeline for using your Figma files.
JavaScript
3
star
9

swipes

🌯 I want to use all of my meal swipes.
TypeScript
3
star
10

progress

🕰 Keeping track of progress towards the end of the school year.
JavaScript
3
star
11

ap-chem

🧪 Summaries for AP Chemistry units.
JavaScript
2
star
12

callout

💡 A wrapper around the Notion API.
TypeScript
2
star
13

borg-image

🖼 Microservice that generates og:images for my sites.
JavaScript
2
star
14

big-bang

🪐 Final project for Big Bang to Humankind, Fall 2022.
Astro
2
star
15

nota-viewer

📃 Website that publishes my notes from Nota.
TypeScript
2
star
16

ben.cv-craft

🐙 Bits of writing
TypeScript
2
star
17

ben.cv-ghost

🐙 Ghost theme for ben.cv
Handlebars
2
star
18

photos

🐙 Photo of the Day website
PHP
2
star
19

brain

🧠 Notes on notecards.
PHP
1
star
20

henrynitzberg

Website for Henry Nitzberg.
TypeScript
1
star
21

media-literacy

Final project for Children & Mass Media, Fall 2022.
Astro
1
star
22

1984

📺 1984 Final Assignment for Dystopias class
JavaScript
1
star
23

tiny-notion-api

A small HTTP wrapper around the Notion API.
TypeScript
1
star
24

brain2

🧠 Notes on notecards.
TypeScript
1
star
25

slowmochristian

🐢 Fun site for @slowmochristian.
JavaScript
1
star
26

build-button

🔴 A simple utility that creates a user-friendly link for building a Netlify site.
HTML
1
star