You can query the API to get measurements from one sensor.
Request
The following is a cURL example of making a
request with GET
.
curl -L -X GET 'https://api.eu.platform.xweather.com/measurements/:sensor_id' \
-H 'Accept: application/json' \
-H 'X-API-KEY: <API_KEY_VALUE>'
Parameter | Mandatory | Description | Example |
---|---|---|---|
sensor_id | ✓ | Full device or sensor uniform resource name (URN) | urn:dev:ops:16961-WXT530-S4131016 |
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"
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)
sensor_id = "123" # Replace with your actual full sensor_id, e.g. urn:dev:ops:16961-WXT530-F1234567
url = f"{base_url}{endpoint}/{sensor_id}"
headers = {
"X-API-Key": api_key,
}
params = {
"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}")