By: Vincentius C. Calvin · July 19, 2024
API Connector
extension from the Google Marketplace.
Alternatively, you can also start by opening up a new Google Sheet file, go to Extensions
> Add ons
> Get add-ons
and then look for API Connector
there. Once you have finished downloading, it will show you the extension under the tab alongside with your other enabled extensions.
API Connector
> Open
.
Create request
to establish our very first connection to the API.
Request URL
and add the headers with Authorization
and value of your <API Key>
.
For the first trial, we are going to use https://api.sectors.app/v1/daily/bbca
and track the daily trading data of BBCA.JK. Feel free to change the ticker with your personal watchlist!
OUTPUT SETTINGS
where you can setup a few things. First, you can set which sheet
and cell
you would like to load the table to. For this recipe, I will just use the Set current
option and it will load the data to the current active sheet and cell A1.
Output mode
selection, since this request is going to be the very first, we can just use overwrite
. If you’re looking to populate more data of another tickers, then you can create a separate request and uses the option append
to automatically add on the first empty rows on the destined place.
Another tip is when you use append
, make sure that you check the Remove header row
option.
Run
!
API Connector
is able to automatically expand your nested JSON objects and explode them to new columns per values.
Try creating a new request to https://api.sectors.app/v1/company/report/bbca/
!
Extensions
tab > API Connector
> Refresh All Now
.
Extensions
> Apps Script
.
This will redirect you to the Apps Script code editor, and by default they provide you with Code.gs
file.
importJSON
includes these main fuctions:
ImportJSON: For use by end users to import a JSON feed from a URL
ImportJSONFromSheet: For use by end users to import JSON from one of the Sheets
ImportJSONViaPost: For use by end users to import a JSON feed from a URL using POST parameters
ImportJSONAdvanced: For use by script developers to easily extend the functionality of this library
ImportJSONBasicAuth: For use by end users to import a JSON feed from a URL with HTTP Basic Auth (added by Karsten Lettow)
Ctrl + S
.
+ Add Trigger
.
Choose the wrapper function (e.g., RunDailyDataBBCA
) from the function dropdown, and choose Time-driven
from the event source dropdown.
Select the type of time-based trigger you want (in this case: daily):
Specific date and time
Minutes timer: Runs every X minutes.
Hour timer: Runs every X hours.
Day timer: Runs once a day at a specific time.
Week timer: Runs once a week on a specific day and time.
Month timer: Runs once a month on a specific day and time.Then, specify the time of the day you would like the trigger to run at.