This tutorial focuses on programmatically retrieving SQL query results to extract metadata using the Coactive API and Coactive SQL Engine functionality.
To automate queries, use the Coactive API’s asynchronous query submission functionality.
Use the following curl command to submit a SQL query:
The API will respond with details including a query_id:
To check the status of your query, use the queryId returned in the previous response:
Queries return a maximum of 10,000 results. To retrieve more, use SQL’s LIMIT and OFFSET clauses across multiple queries.
For example, if your query returns 50,000 matching rows, you would run 5 separate queries:
Increment OFFSET by 10,000 with each query. When resultCount in the status response is less than 10,000, you’ve reached the final page.
Alternatively, you can download the results as a CSV file:
The response provides a temporary link to the CSV file:
Submit a query via POST.
Use the queryId to check the status of the query.
Once the status is “Completed,” download the results as a CSV file.