You can query the API to get measurements from a specific location.
Request
The following is a cURL example of making a
request with GET.
curl -L -X GET 'https://api.eu.platform.xweather.com/measurements/location' \
-H 'Accept: application/json' \
-H 'X-API-KEY: <API_KEY_VALUE>'
| Parameter | Mandatory | Description | Example |
|---|---|---|---|
| geometry | ✓ |
Longitude and latitude of the device, specified with 5 decimal accuracy. |
25.25354,61.23456 |
| max_distance | - | A device can be located at most this many meters from the given coordinates. The default value for max_distance is 22.2 meters which equals 0.0001 in decimals in the equator. The allowed values are 0–100. | 10 |
| start_time | - | The start time (inclusive) for the request | 2023-03-01T00:00:00Z |
| end_time | - | The end time (exclusive) for the request | 2023-03-01T12:00:00Z |
Authorization
type: apiKey
name: X-API-KEY
in: header
Request example in Python using API key
##
#
# Copyright (c) Vaisala Oyj. All rights reserved.
#
##
import requests
base_url = "https://api.eu.platform.xweather.com"
endpoint = "/measurements/location"
api_key = "your_api_key" # Place your api-key here
start_time = "2023-12-22T10:00:00Z" # Replace with your actual start time in UTC
end_time = "2023-12-22T12:00:00Z" # Replace with your actual end time in UTC (Optional)
geometry = "24.87762,60.28456" # Replace with your actual location with 5 decimal accuracy in lon,lat format
max_distance = 25 # Radius of circle in meters
url = f"{base_url}{endpoint}"
headers = {
"X-API-Key": api_key,
}
params = {
"geometry": geometry, # If only geometry set, latest values are returned
# "start_time": start_time,
# "end_time": end_time
}
try:
response = requests.get(url, headers=headers, params=params)
# Check if the request was successful (status code 200)
if response.status_code == 200:
print("Request successful")
print(response.json()) # Assuming the response is in JSON format
else:
print(f"Request failed with status code {response.status_code}")
print(response.text) # Print the response content in case of an error
except Exception as e:
print(f"An error occurred: {e}")