Development Quickstart
Get up and running with our Wegaw API and kick-start your Wegaw integration.
Integrating the Wegaw API in your apps can begin right after you receive a Wegaw account, and in just four simple steps:
Obtain your API tokens
Check the basins available via API Request
Get data via API Request
Find available maps and download them via API Request
Step 1: Obtain your API tokens
To use the Wegaw API, you will 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 by using the Create Token API endpoint.
You will obtain two tokens:
One Access Token, allowing you to make any API or Maps request
One Refresh Token, allowing you to obtain a new Access Token when this expires
To increase the security of your account, Access tokens automatically expire after 24 hours, while Refresh tokens expire after 1 day.
Due to automated expiration of both tokens, you will need to implement an automatic token retrieval in your system. An expired Access Token will return an HTTP response code 401 Unauthorised. This indicates that you must 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.
curl -X POST 'https://api.staging.defrost.io/v2/token/' --header 'Content-Type: application/json' --data '{"username":"string","password":"string"}' import requests
url = 'https://api.staging.defrost.io/v2/token/'
payload = {'username':'string','password':'string'}
r = requests.post(url, json=payload, timeout=300)
if r.status_code == 200:
data = r.json()//import axios on the header <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
let url = 'https://api.staging.defrost.io/v2/token/';
(async() => {
const payload = {'username':'string','password':'string'}
try {
const response = await axios.post(url, payload);
if (response.status == 200) {
const data = response.data;
console.log(data);// Work with the data
} else {
console.error('Failed with status code:', response.status);
}
} catch (error) {
console.error('Error during the call:', error);
}
})(); Step 2: Check the catchments available via API Request
Use the following code to check the catchments for which data can be downloaded. You can use the following code:
Make sure to modify the snippets with your API tokens obtained in the step above
Step 3: Get data via API Request
In this snip of code, we will request Snow Water Equivalent (SWE) data via API.
Step 4: Find available maps and download them via API Request
In this snip of code, we will request Snow Water Equivalent (SWE) available maps via API.
And we will receive an array of files with information about the filename, the date and the URL to download the file.
In this snip of code, we will download a SWE map, using the filename, via API.
Last updated