Programmatically Retrieve SQL 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:
Curl
API Response
The API responds with query details including the query_id:
API_Response
Step 3: Checking Query Status
To check the status of your query, use the query_id returned in the previous response:
Curl
Example Status Response
wordwrap
Step 4: Downloading Results
Once the query status is “Complete,” retrieve the results download URL:
Curl
Example Response
The response provides a temporary link to download the results:
API Response
Notes
- The download link expires 15 minutes after it is generated (configurable via the
expiration_secondsquery parameter).
Example: Full Query Execution Workflow
-
Submit a query via POST.
-
Use the query_id to check the status of the query.
-
Once the status is “Complete,” download the results.
