The demo companion code for Snowflake REST API demo with Postman.
As part of this demo we will cover few APIs:
- Warehouses
- Tables
- Roles
- Grants
- Users
git clone https://github.com/Snowflake-Labs/snowflake-rest-postman-demo.git
Use the Postman Import feature to import the collections from $DEMO_HOME/collections
folder and environment tutorial
from $DEMO_HOME/environments
folder.
Important
Ensure to set the tutorial
as DEFAULT environment in postman
Ensure that you have Snowflake account available and configured to be used with Snowflake CLI.
Run the following command to ensure all set with respect to Snowflake connection,
snow connection test -c <your connection name>
If you have not configured your Snowflake session, please refer to this documentation.
Tip
It is very convinient to have a variable named SNOWFLAKE_DEFAULT_CONNECTION_NAME
configured on your shell. It helps snow
cli to use a default connection without -c
parameter
To be able to generate JWT
token you need to have your connection configured with Key-Pair authentication. Check the documentation on how to configure KeyPair auth with the Snowflake CLI.
Important
Please configure your Key-Pair in encrypted mode with a private key passphrase
export SNOWFLAKE_DEFAULT_CONNECTION_NAME=trial
export PRIVATE_KEY_PASSPHRASE=<your private key passphrase>
Ensure you have configured all and successful run the following command to generate JWT token,
snow generate-jwt
The following information are need to configure the following variables as part of Postman's tutorial
environment:
snowflake_jwt_token
- output ofsnow generate-jwt -c <your connection name>
snowflake_username
- the Snowflake account user login namebase_url
- The Snowflake Account URL. Refer https://docs.snowflake.com/en/user-guide/admin-account-identifier
Tip
If you have tools like jq then you can build your base url like
snow connection test --format json | jq -r '"https://" + .Host'
AND
snowflake_username
like
snow connection test --format json | jq -r '.User'
Both these commands use Snowflake connectio fomr $SNOWFLAKE_DEFAULT_CONNECTION_NAME
All requests are configured to have the following headers,
Content-Type
is alwaysapplication/json
x-snowflake-authorization-token-type
is set to use the variablesnowflake_auth_type
from the environment which is by default set toKEYPAIR_JWT
Now you are all set to run the collections using Postman. For demonstration purpose there is some data that you can use API inside config folder. Please check https://learning.postman.com/docs/collections/running-collections/working-with-data-files/ to see how to use the data with Postman.
There are few SQL statements in check.sql that you can try before and after the collection run to make sure all works.
- Snowflake trial sign-up at https://signup.snowflake.com/
- Demo sources used in this tutorial at https://github.com/Snowflake-Labs/snowflake-rest-postman-demo
- Snowflake REST API Reference Documentation https://docs.snowflake.com/en/developer-guide/snowflake-rest-api/snowflake-rest-api
- Snowflake Postman Public Workspace at https://postman.com/snowflake/snowflake-public-workspace/collection/ot7drnh/snowflake-role-api