⚙️Get Query Results

API key can be the user or query API key

Use this endpoint to get a cached result for any URL as a JSON file:

Get a cached result for this query ID as JSON

GET https://query.nansen.ai/api/queries/<url>/results.json?api_key=<api_key>

Only works for non-parameterized queries. If you attempt to GET results for a parameterized query you’ll receive the error: no cached result found for this query.

Query Parameters

NameTypeDescription

api_key*

String

If you prefer to get the results as a CSV file, use this endpoint:

Get a cached result for this query ID as CSV

GET https://query.nansen.ai/api/queries/<url>/results.csv?api_key=<api_key>

Only works for non-parameterized queries. If you attempt to GET results for a parameterized query you’ll receive the error: no cached result found for this query.

Query Parameters

NameTypeDescription

api_key*

String

Note the workflow for getting query results are:

1) Use the [User] key and the [URL] to initiate a query execution.

When the query has been initiated, it will return a job_id

2) Check the status of the query using the job_id.

When the status return 3, the query will have finished and the results can be retrieved.

3) Retrieve the results using the [User] or [API] key and the [URL]

Query Result JSON Structure

The result JSON includes two important sections, both contained in the "data" section.

  • A "columns" section, which contains the metadata for the result

  • A "rows" sections, which contain the actual result

The metadata can assist in properly processing the returned result.

{
    "query_result": {
		...
		"data": {
		   "columns": [
		                {...
		                }
		   ],
	           "rows": [
		             {
		             DATA HERE
		             }
		   ],
                   "metadata": {
                       		...
                   }
                },
                ...
     }
}

If you want to do a fresh query execution or get results for parameterized queries, see the following instructions:

⚙️Execute A Query

Get Query Results in Google Sheets

To get your query results in Google Sheets automatically, please follow these steps:

Step 1: Go to the query you are interested in and click on Show API Key

Step 2: Copy the results in csv format URL

Step 3: Use the =importdata function on the google sheet you wish the results to be exported. Please use the following format: =importdata("csv link")

Last updated