Development Quickstart
Get up and running with our Snow Cover API & Maps and kick-start your DeFROST integration.
Integrating DeFROST in your apps can begin right after you create a DeFROST account, and in just three simple steps:
Obtain your API tokens
Make a test API Request
Display the snow cover map layer
Read below for a step by step guide:
Step 1: Obtain your API tokens
To use DeFROST, you'll need an access token. We use this token to associate any of your requests to your account. Find your token or refresh it in your Account Dashboard page or obtain it programmatically using the Create Token API endpoint.
You will obtain two tokens:
An Access Token, allowing you to make any API or Maps request
A Refresh Token, allowing you to obtain a new Access Token when this expires
Due to automated expiration of both tokens, you need to implement your integration taking this aspect into account. An expired Access Token will return an HTTP response code 401 Unauthorized, a signal for you to use the Refresh Token API endpoint to obtain a newly valid Access Token. If the Refresh Token is expired, obtain a new pair of tokens via the Create Token API endpoint.
The tokens are standard JSON Web Tokens. Their payload contain the expiration date, which allows you to easily test whether a token is expired or not:
var access_or_refresh_token = '<YOUR_ACCESS_OR_REFRESH_TOKEN>';
return JWTDecode(access_or_refresh_token).exp < Date.now() / 1000;Step 2: Make a test API Request
To test that you are ready to start integrating with DeFROST API, make a test API request using your secret API Access and Refresh tokens to refresh the Access token or retrieve the available snow covers.
Make sure to modify the snippets with your API tokens obtained in the step above
Step 3: Display the snow cover map layer
To test that your integration with DeFROST Maps is working correctly, use the examples below for your web mapping library of choice. We provide examples for the most popular web mapping libraries: OpenLayers, Leaflet, Mapbox and Google Maps.
Google Maps users: whitelist your HTTP referrers
Using the DeFROST API, you can add as many HTTP referrers as you want to your whitelist - exclusively allowing requests from such referrers to use your tokens and DeFROST services. This is an added security layer that, while recommended for all cases, it is only mandatory for Google Maps users. Since this library does not support sending your token in each tile request's authorization header, you need to send it via a query parameter - making your token exposed.
Make sure to modify the snippets below with your API access token. The Mapbox snippet requires, in addition, your Mapbox token.
The key point to keep in mind is that DeFROST Maps requires Bearer token Authentication. This forces libraries displaying tile layers to include the appropriate Authentication header in each tile request. While Mapbox supports this method out of the box, OpenLayers and Leaflet require a minor workaround: have a look in the examples above. In the special case of Google Maps, you have no option but to send the token as a query parameter, which forces you to add any HTTP Referrer to your whitelist.
Next steps
You are now ready to integrate DeFROST! You can check the following additional resources:
Code Examples GitHub repository: Full source code and starter project demonstrating integration of DeFROST Maps and API in supported platforms.
Last updated
Was this helpful?