Quadratic
Search…
⌃K
Links

Making Requests

You can make an external HTTP request directly from a Quadratic Cell using js.fetch
Note: Requets are made from your web browser and are subject to limitations.
You can learn more about making POST requests here.

Example - Pulling stock data from the Polygon API

import json
import js
symbol = "AAPL"
polygon_api_key="xxxxxxxxxxxx"
# Make API Request
response = await js.fetch(
'https://api.polygon.io/vX/reference/financials?ticker={}&apiKey={}'.format(symbol, polygon_api_key),
{
"method": "GET",
"headers": {"Content-Type": "application/json"}
}
)
# Extract JSON data from response
response_json = json.loads(await response.text())
income_statement = response_json["results"][0]["financials"]["income_statement"]
# Return Apple revenue as the cell value
income_statement["revenues"]["value"]