Sitemap
Gonçalo Fontoura

Gonçalo Fontoura

SAPI REST APIs & Google Spreadsheets

3 min readMay 24, 2024

Covering data transformation from CSV and XLS to JSON & some work-arounds.

It is possible and easy for you to have your, e.g.: product stock file (.cvs or .xls) available to others, say partners — assuming you’re planning to generate some income on it (very possible with PDF documents — I will post another article on Content Monetisation). Such options can be found in the API Manager or editor, next to the Response Content <textarea> in Simple API.

We will jump into creating a REST API which loads a Google Spreadsheet and Transforms its content to JSON (perfect to be consumed by your web or mobile application).

Let’s start by creating the Product we will associate this API to. On the left (main) menu, when in the Platform, you can find both the Product Manager and Google Sheet Editor pages:

Press enter or click to view image in full size
SAPI Products — They help Identify & Categorise Content (screenshot 1)
Press enter or click to view image in full size
SAPI Products — They help Identify & Categorise Content (screenshot 2)
Press enter or click to view image in full size
SAPI Products — They help Identify &Categorise Content (screenshot 3)

With our Product created, let’s have the Google document ready to be loaded by the API Manager. We’re now in docs.google.com.

Press enter or click to view image in full size
Google Sheets — Sharing docs with SAPI
Press enter or click to view image in full size
SAPI — Creating a Google Spreadsheets record

As you can see from both pictures, the Google document must be shared with our Google Service Account. Instructions and information about Products, Google Sheet or REST APIs can be found in the Platform.

Get Gonçalo Fontoura’s stories in your inbox

Join Medium for free to get updates from this writer.

Let’s create our API, load the Google Document, and have its JSON response ready to be consumed.

Press enter or click to view image in full size
SAPI (REST) API Manager

With SAPI’s API Manager, creating the REST API will be as easy as:

  1. Selecting the Product we’ve just created.
  2. Name the API (slug or public address can be changed to a custom one).
  3. Selecting the Google Document from the list (Load stored Google Spreadsheets).
Press enter or click to view image in full size
API Manager — JSON Content

After selecting the Google document, the Response Content block should be populated with its JSON version. Hit Create REST API.

Press enter or click to view image in full size
Previewing your API’s response (screenshot 1)
Press enter or click to view image in full size
Previewing your API’s response (screenshot )
Press enter or click to view image in full size
Accessing your REST API / Content output

Your Google Document is now available in JSON format. As of now, you’re able to flag content based on its type, assuming you might also have your API made public in the Marketplace. A couple of Age Rating options can be found in the editor, such: A (All Ages), B (12+), C (15+), D(17+), Z (18+). Remember you can also protect APIs with Basic Auth and decided wether they should be public (available via GET through Port 80) or POST only method.

--

--