To start using the Roic AI API, you’ll need an API key which can be obtained on the Settings page by registering on our website and subscribing to a Professional plan.
The API and Excel plugin are available only on the Professional plan.
Authentication
To authenticate your API requests, include your API key in the query of each call:
We've tried very hard to get past the review process for the Google Sheets add-on. But this company is too sluggish and we're still waiting for the review to finish.
/**
* RQL - Roic AI Query Language - Fetch fundamental data for a given security.
*
* @param {string} ticker - The security identifier of the company. Should include the exchange code. Ex. "AAPL US"
* @param {string} field - The field to be fetched. Ex. is_sales_revenue_turnover
* @param {string} parameter_1 - The first parameter to be passed to the field. Ex. showdates=true
* @param {string} parameter_2 - The second parameter to be passed to the field. Ex. showheaders=true
* @param {string} parameter_3 - The third parameter to be passed to the field. Ex. transpose=true
* @param {string} parameter_4 - The fourth parameter to be passed to the field. Ex. xlsort=ASC
* @param {string} parameter_5 - The fifth parameter to be passed to the field. Ex. showquery=true
* @return The asked information from the fund, according to the selected source.
* @customfunction
*/
function RQL(ticker, field, parameter_1, parameter_2, parameter_3, parameter_4, parameter_5) {
if (!ticker && !field) {
throw new Error("Please provide a security identifier and a field");
}
if (!ticker) {
throw new Error("Please provide a security identifier");
}
if (!field) {
throw new Error("Please provide a field");
}
var query = "get(".concat(field, ") for('").concat(ticker, "')");
// Compose query parameters
var queryParams = [
parameter_1,
parameter_2,
parameter_3,
parameter_4,
parameter_5,
]
.filter(function (param) { return param; })
.map(function (param) { return "&".concat(param); })
.join("");
// Construct the URL
var url = "https://api.roic.ai/v1/rql/?query=".concat(query).concat(queryParams, "&apikey=YOUR_API_KEY");
var fetch = UrlFetchApp.fetch(url);
if (fetch.getResponseCode() == 200 && fetch.getContent().length > 0) {
var body = fetch.getContentText();
var json = JSON.parse(body);
return json;
}
else {
throw new Error("Wrong combination of asset identifier and source. Please check the accepted ones at the documentation.");
}
}