https://github.com/user-attachments/assets/f33b9052-9cde-425e-8607-d2a94f50d9e2
See what I'm reading by using Google Sheets as a database. Check the live Google Sheets
Goodreads interface sucks at showcasing your books. I started using to track what books I'm reading and found out that they don't support the use of public APIs.
Hearing about stories of websites using Google Sheets / Excel as a database like Levels.fyi scaling to millions with Google Sheets, made me want to try it.
Goodreads supports exporting your information as a .csv file. Then import the CSV into Google Sheets and let the magic begin.
To expose using Sheets as an API you need to enable it on Google Cloud, then create a service account, and export the ´credentials.json´ to a file. See more on this video. Your credentials.json should look like this:
{
"type": "service_account",
"project_id": "<project-id>",
"private_key_id": "<private-key-id>",
"private_key": "<private-key>",
"client_email": "<client-email>",
"client_id": "<client-id>",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "<client-x509-cert-url>",
"universe_domain": "googleapis.com"
}
This file needs to live on the root of your project.
Now you need to add the email of the service account to your Google Gheets as an Editor.
To interact with the Google Sheets API, we need to install the googleapis package.
After that, we can use the library for accesing the ROWS and COLUMNS of the Sheet and start querying.
[!WARNING] Expect cumulative Layout Shift (CLS) on the first load, caused by the swiper library and the onMount hook I'm using.
[!WARNING] Images are not optimized for external CDNs / URLs. The network request are heavy.
credentials.json
. You can't deploy it without this file.