The LogicSheetAPI formula

Use the =LogicSheetAPI custom function to import API directly to your worksheet using cell formulas.

How to use =LogicSheetAPI?

If you want to use the =LogicSheetAPI function in a new spreadsheet, you have to launch the Logic Sheet add-on at least once in that spreadsheet. The add-on can be found in the Add-on menu. If you haven't installed Logic Sheet yet, click here to install.

Call the LogicSheetAPI custom function by typing =LogicSheetAPI in any cell. Now you will see a list of parameters to fill in to use the function. You will also be able to see the documentation inside your Google Sheets. If the documentation doesn't show up, just click the question mark(?) next to the function name.

Parameters

Here are the parameters you can use to call LogicSheetAPI.

It's a good practice to store parameter content in separate cells for later reference. It will also help you escape quotations markets if you want to include a JSON request body.

  • method: The HTTP request method for the API request. It can either be "GET" or "POST".

  • url: The URL of the API endpoint. You can also include request parameters in the URL.

  • path: [optional] A list of paths to be imported. For example: "/first_name, /email" will only import data under the "first_name" and "email" paths. If you don't want to specify the path, just use "" in the parameter to escape it.

  • header: [optional] The request header should be a comma-separated list of header items. You can use it to pass authentications. For example: "apikey=YOUR_API_KEY,content-type=application/json". No space before or after commas.

  • requetBody: [optional] For the POST method only. The request body sent to the API endpoint. Type in JSON format if you are using application/json.

Here is an example GET request

GET https://api.thecatapi.com/v1/votes?limit=3

Headers

NameTypeDescription

x-api-key

DEMO-API-KEY

content-type

application/json

This is how you can make the GET request using LogicSheetAPI.

=LogicSheetAPI("GET", "https://api.thecatapi.com/v1/votes", "", "x-api-key=f2b451ef-af64-49d4-8594-378ee24ae040,content-type=applic
ation/json")

This is an example of the LogicSheetAPI working on Google Sheets. Parameters are stored in separate cells.

This is an example result:

Here is an example POST request

POST https://api.thecatapi.com/v1/votes/

Headers

NameTypeDescription

x-api-key

DEMO-API-KEY

content-type

application/json

Request Body

NameTypeDescription

image_id

the_image_id

sub_id

my-user-1234

value

3

This is how you can make the POST request using LogicSheetAPI.

=LogicSheetAPI("POST", "https://api.thecatapi.com/v1/votes", "", "x-api-key=DEMO-API-KEY,content-type=applic
ation/json", D2)

In this example, we use cell D2 to store the request body in order to escape the quotation marks in the JSON string.

This is an example of the LogicSheetAPI working on Google Sheets. Parameters are stored in separate cells.

Last updated