Save as file

Save as File

There are a few file extensions that you can save as.

You can send query that you want to save as:

POST /dataset/store/query/ HTTP/1.1
Authorization: token 01234567890123456789
X-API-Version: 20151130

{
    "tickers": [
        "nasdaq:aapl"
    ],
    "filters": [
        {
            "match": "any",
            "conditions": [
                {
                    "column": "state",
                    "type": "=",
                    "value": [
                        "CA"
                    ]
                },
                {
                    "column": "city",
                    "type": "=",
                    "value": [
                        "New York"
                    ]
                }
            ]
        }
    ]
}

A sample response is as follows:

{
    "state": "complete",
    "total": 4384,
    "id": "60d68cb37d2af4e7b3c4b7aaae0b89ad45f992487997bb173b4b60191fc4d673",
    "formats": [
        "application/vnd.thinknum.table+json",
        "application/vnd.thinknum.map+json"
    ]
}

To check if query is completed:

HEAD datasets/store/query/60d68cb37d2af4e7b3c4b7aaae0b89ad45f992487997bb173b4b60191fc4d673 HTTP/1.1
Authorization: token 01234567890123456789
X-API-Version: 20151130
Accept: application/vnd.thinknum.table+json
Content-Type: application/x-www-form-urlencoded; charset=utf-8

A sample response follows:

HTTP/1.1 200 OK
Server: nginx
Date: Fri, 30 Apr 2021 19:20:08 GMT
Content-Type: application/json
Connection: keep-alive
X-Truncated: false
X-Formats: application/vnd.thinknum.table+json, application/vnd.thinknum.map+json, text/csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
X-Total: 4384
X-State: complete
Strict-Transport-Security: max-age=15768000

Now you can see text/csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, which means you can download rows as csv, xls, and xlsx formats.

To download as csv file:

GET "https://data.thinknum.com/datasets/store/query/60d68cb37d2af4e7b3c4b7aaae0b89ad45f992487997bb173b4b60191fc4d673" \
Accept: text/csv
X-API-Version: 20151130
Authorization: token 01234567890123456789
curl -L "https://data.thinknum.com/datasets/store/query/60d68cb37d2af4e7b3c4b7aaae0b89ad45f992487997bb173b4b60191fc4d673" \
-H "Accept: text/csv" \
-H "X-API-Version: 20151130" \
-H "Authorization: token 01234567890123456789" \
-o 'file.csv'

To download as xls file:

GET "https://data.thinknum.com/datasets/store/query/60d68cb37d2af4e7b3c4b7aaae0b89ad45f992487997bb173b4b60191fc4d673" \
Accept: application/vnd.ms-excel
X-API-Version: 20151130
Authorization: token 01234567890123456789
curl -L "https://data.thinknum.com/datasets/store/query/60d68cb37d2af4e7b3c4b7aaae0b89ad45f992487997bb173b4b60191fc4d673" \
-H "Accept: application/vnd.ms-excel" \
-H "X-API-Version: 20151130" \
-H "Authorization: token 01234567890123456789" \
-o 'file.xls'

To download as xlsx file:

GET "https://data.thinknum.com/datasets/store/query/60d68cb37d2af4e7b3c4b7aaae0b89ad45f992487997bb173b4b60191fc4d673" \
Accept: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
X-API-Version: 20151130
Authorization: token 01234567890123456789
curl -L "https://data.thinknum.com/datasets/store/query/60d68cb37d2af4e7b3c4b7aaae0b89ad45f992487997bb173b4b60191fc4d673" \
-H "Accept: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" \
-H "X-API-Version: 20151130" \
-H "Authorization: token 01234567890123456789" \
-o 'file.xls'