SAPI REST APIs & Google Spreadsheets
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:
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.
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.
With SAPI’s API Manager, creating the REST API will be as easy as:
- Selecting the Product we’ve just created.
- Name the API (slug or public address can be changed to a custom one).
- Selecting the Google Document from the list (Load stored Google Spreadsheets).
After selecting the Google document, the Response Content block should be populated with its JSON version. Hit Create REST API.
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.









