Programmatically Retrieve SQL results
Tutorial: Programmatically retrieve SQL Query results
This tutorial focuses on programmatically retrieving SQL query results to extract metadata using the Coactive API and Coactive SQL Engine functionality.
Step 1: Setting Up Authorization
Retrieve and setup API Credentials
- Refer to our API Authenication page
Step 2: Submitting a Query
To automate queries, use the Coactive API’s asynchronous query submission functionality.
Example Query Submission
Use the following curl command to submit a SQL query:
API Response
The API will respond with details including a query_id:
Step 3: Checking Query Status
To check the status of your query, use the queryId returned in the previous response:
Example Status Response
Step 4: Paginating Through Results
For large datasets, you may need to paginate through the results:
Step 5: Downloading Results as CSV
Alternatively, you can download the results as a CSV file:
Example Response
The response provides a temporary link to the CSV file:
Notes
- The download link expires 15 minutes after it is generated.
Example: Full Query Execution Workflow
-
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.