When working with data it's likely that you will want to not only retrieve data from your Google Sheets, but you may also want to surface data from external locations within your sheets. In this example, we will show you how to do so with an external csv file from Github that lists out the S&P500 so that we can take advantage of Google Sheet's integration with Google Finance to get prices of the stocks in this index.
You can see the completed example above that we will be taking steps to replicate.
The first step is to create the query that we want to submit to the api. For demo purposes here is the query we want for the sheet that retrieves a listing of ticker symbols.
SELECT Symbol
FROM "<https://raw.githubusercontent.com/dylanroy/sandp500-dataset/main/data.csv>"
The easiest way to build the query will be to copy, and paste this query within the OpenAPI documentation linked below.
After providing your API key as a query parameter you will need to set the format to csv, and submit your query. Following the successful response you can copy the request URL that shows up. It should look like the following request, but with your own API key.
<https://usesql.com/sql?query=select%20Executive%2C%20Company%2C%20Since%20from%20%22https%3A%2F%2Fraw.githubusercontent.com%2Fdylanroy%2Fceo-dataset%2Fmain%2Fdata.csv%22%20LIMIT%2010&format=json&key=YOUR_KEY>
<aside>
<img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7376a166-f82b-4dfc-b476-14dff498fc6d/favicon.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7376a166-f82b-4dfc-b476-14dff498fc6d/favicon.png" width="40px" /> Note: You may need to manually url encode the " to be %22 in this demo if you don't end up using the OpenAPI.
</aside>