Snowflake API¶
Prerequisites¶
Access to Spectus's API layer is protected through our Internal Identity Provider (IDP) which adheres to the OpenID Connect and OAuth2 Standards.
In order to access Spectus' data through the API, you need a token and refresh token request. Please request API access by contacting your Spectus representative, or via our Support Form. Once your access request has been approved, Spectus will provide a client_id
and client_secret
as well as a customerId
.
For more details about the Authentication process please refer to this page.
Overview¶
End point: https://ltoxcuc-prod_XXXX.snowflakecomputing.com/api/v2/statements
The Spectus Snowflake API allows users to submit SQL code to perform the following actions:
- Call a stored procedure that returns a string type variable
- Execute a Task
Variables in the body of the API¶
The API recieves a JSON with the following variables
Field | Required | Type | Description |
statement | yes | string | SQL command |
timeout | no | integer | Timeout value in minutes for the API call |
warehouse | yes | string | Select the Warehouse you wish to use, e.g. COMPUTE_WH |
role | yes | string | Set to ROLE_SERVICE |
The ROLE_SERVICE
is authorized to POST
the following two SQL commmands within the statement
field:
Note: The API cannot return a DataTable object and can be solely utilized to trigger and monitor TASKS and PROCEDURES created within the platform. Please make sure to change the return type of your procedure to String
before deploying/creating it.
Example of a request body:
{
statement : "EXECUTE TASK dedicated.test_table.test_task",
timeout: 60,
warehouse: "COMPUTE_WH",
role: "ROLE_SERVICE"
}
Tip: When executing long run procedure set the query param async=true
. The API response will contain an handler you can use to monitor the status of the execution.
Tip: When creating the TASK utilize the ALLOW_OVERLAPPING_EXECUTION = TRUE
parameter to allow for multiple instances of the TASK to be initiated.