🤖

Let's Read Google Spreadsheets via API!

This article is machine-translated, may not be accurate 6/22/2024

Let’s Read Google Spreadsheets via API!

Image from Gyazo

This is a repost of an article I wrote on another site last year.

It’s super easy! I’ll explain how to read information from Google Spreadsheets using an API. With some customization, you can even use it as a simple CMS! Just copy and paste to get started.

Let’s Create a Spreadsheet

Obviously, we first need to create a spreadsheet. For clarity, I recommend creating it like this:

$$ \begin{array}{|c|c|c|c|c|} \hline When (yyyy-mm) & Where & What & How & Link \ \hline 2023-08 & In Tokyo & Ate sushi & Nom nom. & url \ \hline 2022-05 & In Malaysia & Ate Nasi Lemak & Ate with a spoon & url \ \hline \end{array} $$

I wanted to create something like a diary page, so I did it this way. You might wonder “Won’t it read the top row too?” but don’t worry - we can configure it not to.

Let’s Use the API

Enable Google Sheets API

First, enable the Google Sheets API from this site: Google Cloud console

Click the enable button to activate it.

Create an API Key

Go to the “APIs & Services” page and create new credentials.

Click “API Key” to create one. Now we’re ready! All that’s left is to send requests to the API!

Send Requests to the API

You can use the Google Sheets API by sending requests to sheets.googleapis.com. Here’s the link format containing everything needed for retrieval. Please modify it according to your sheet:

<https://sheets.googleapis.com/v4/spreadsheets/{SheetID}/values/{SheetName!StartPoint:EndPoint}/?key={APIKey}>

Done! Let’s Send the API Request!

When you send the completed API request, you’ll see text like this on screen. If you see it, you’ve succeeded! Hooray!

{ "range": "Japanese!A2:F10", "majorDimension": "ROWS", "values": [ [ "2023-08", "In Tokyo", "Ate chicken", "Nom nom", "https://google.com", "bg-green" ] ] }

0 people clapped 0 times

Related articles

🤖

Looking Back at Only My Failures in 2023!

1/2/2024

For those thinking "Isn't this just your opinion?" - Yes, you're right. This post mainly contains...

0 times clapped

🤖

Create a Blog Site with Astro - All You Need is HTML Knowledge!

5/12/2024

Sometimes you just want to create a blog site, right?

These days, you can quickly create a custom...

0 times clapped

🤖

Air Tycoon Online 2 Credit Earning Guide

12/5/2021

Note: This article is still being written and content may change.

After reading various...

0 times clapped

🤖

[ATO2] Most Important Cities in Early Game (Updating)

9/10/2021

I've created a list of cities you should secure in the early game. Please take a look. Cities are...

0 times clapped