The Hipsift API.
Find your sheets, run queries, and manage views and collections over HTTPS with an API key.
Authentication
Sign in to Hipsift, open the API Keys page and create a key. It's shown once, so copy it somewhere safe. Send it with every request:
Authorization: Bearer pfg_YOUR_API_KEYThe base URL is https://hipsift.com/api. An x-api-key header works too. Call the API from your own server or scripts: browsers on other sites can't call it.
Scopes
read: Discover data, inspect status, and run analytical queries.write: Read access plus imports, schedules, transforms, views, collections and other changes.admin: Write access plus sharing views and making them public.
| Area | read | write | admin |
|---|---|---|---|
| Sheets and columns |
|
| — |
| Queries |
| — | — |
| Sources and schedules |
|
| — |
| Saved views and sharing |
|
|
|
| Collections |
|
| — |
| Google Sheets, files and open data |
|
| — |
| Import status and storage |
| — | — |
Sending isPublic in the body of POST /api/view, PUT /api/view/{id} or PATCH /api/view/{id} needs an admin key.
Quickstart: total a column
Replace SHEET_ID and QUERY_ID with the ids from the steps before, and the column names with your own.
1. Find your sheets
Each sheet has a numeric id.
curl -H "Authorization: Bearer pfg_YOUR_API_KEY" \
https://hipsift.com/api/sheet2. List a sheet's columns
Use each field's parquetName in queries. Totals need a number column.
curl -H "Authorization: Bearer pfg_YOUR_API_KEY" \
https://hipsift.com/api/sheet/SHEET_ID/fields3. Run a query
Queries run in the background. The answer has a queryId.
curl -X POST -H "Authorization: Bearer pfg_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"selectFields":[{"fieldExpressionString":"category"}],"selectFieldFunctions":[{"functionName":"AggregateSum","args":["amount"],"alias":"total"}],"groupByFields":[{"fieldExpressionString":"category"}],"limit":100}' \
https://hipsift.com/api/query/SHEET_ID4. Get the result
Repeat until status is COMPLETE (the rows are in result) or ERROR.
curl -H "Authorization: Bearer pfg_YOUR_API_KEY" \
https://hipsift.com/api/query/SHEET_ID/run/QUERY_IDA plain-text 404 Dataset not ingested yet means the sheet's import hasn't finished: check GET /api/ingest-queue/all and try again once it's synced. If a column holds text such as “$1,200”, add "transform": "CAST_USD" to the function.
Errors
Most errors are JSON with error, code and message. Some answer with plain text instead, so check the HTTP status first.
| Status | code | Meaning |
|---|---|---|
| 400 | invalid_request | The request is missing or has an invalid field. An invalid query answers errors: [{ field, message }] instead. |
| 400 | missing_connection_id, ambiguous_connection_id | Importing a Google Sheet needs connectionId (the id from GET /api/connections). |
| 400 | unsupported_format, file_invalid | The file's format isn't supported, or it isn't a valid file of that format. |
| 401 | auth_required | No credential, or the key is invalid or deleted. |
| 401 | account_inactive | The account was deleted. |
| 401 / 403 | reauthorize_required | The Google account needs reconnecting in the app (not a key problem). |
| 403 | insufficient_scope | The key's scope is too low; requiredScope says which is needed. |
| 403 | paid_plan_required | Scheduled refresh needs the Basic plan. |
| 403 | storage_limit_reached | The plan's storage is full. |
| 403 | file_access_required | Google can't open the spreadsheet for this connection: pick it again in Hipsift with Google's file picker. |
| 404 | not_found | No such resource, or it isn't yours. |
| 404 | query_run_not_found | Right after submitting a query, the run may not be visible yet. Retry a few times. |
| 409 | conflict | The request conflicts with the current state. |
| 413 | file_too_large, dataset_too_large | The file or dataset is over the import limit. |
| 422 | not_socrata | The host isn't a Socrata open-data portal. |
| 429 | rate_limited | Too many open-data searches; wait for Retry-After seconds. |
| 502 | enqueue_failed | The source was created but its import didn't start. Send the same request again after a few minutes. |
| 503 | queue_unavailable | Imports can't be started right now. Retry later. |
| 502 / 503 | upstream_unavailable | A service Hipsift depends on is unavailable. Retry. |
| 503 | metadata_sync_failed | A change couldn't be saved yet. Retry. |
| 503 | entitlement_unavailable, storage_usage_unavailable | Your plan or storage use couldn't be checked. Retry. |
| 503 | service_draining | Hipsift is restarting. Retry. |
| 504 | upstream_timeout | A dependency (such as Google) didn't answer in time. Retry. |
Importing data
Imports need a write key, count toward your plan's storage, and run in the background. To upload a file instead of linking to it, use POST /api/file/presign first (see the reference). Google Sheets and open data can be refreshed later with POST /api/source/SOURCE_ID/resync-now; to update a file, add the new one and delete the old source.
Add a Google Sheet
Use a spreadsheetId from GET /api/google/spreadsheets (spreadsheets you've picked in Hipsift). Add connectionId (the id from GET /api/connections) if you have more than one Google account, or no Google Sheets in Hipsift yet.
curl -X POST -H "Authorization: Bearer pfg_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"spreadsheetId":"SPREADSHEET_ID"}' \
https://hipsift.com/api/sheet-syncAdd a file from a URL
A public HTTPS link to a Parquet or CSV file. requestId is a new random UUID (for example from uuidgen); sending the same one again is safe.
curl -X POST -H "Authorization: Bearer pfg_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"format":"csv","fileName":"orders.csv","sourceKind":"url","url":"https://example.com/orders.csv","requestId":"REQUEST_UUID"}' \
https://hipsift.com/api/file/ingestAdd an open-data dataset
The dataset's page on a Socrata portal.
curl -X POST -H "Authorization: Bearer pfg_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://data.example.gov/d/abcd-1234"}' \
https://hipsift.com/api/socrata/ingestWait for the import
Use the sourceId from the import's answer. Repeat until the list isn't empty and every sheet's status is SYNCED (or FAILED, with an error).
curl -H "Authorization: Bearer pfg_YOUR_API_KEY" \
https://hipsift.com/api/ingest-queue/source/SOURCE_ID