MENU navbar-image

Introduction

This documentation aims to provide all the information you need to work with our API.

<aside>As you scroll, you'll see code examples for working with the API in different programming languages in the dark area to the right (or as part of the content on mobile).
You can switch the language used with the tabs at the top right (or from the nav menu at the top left on mobile).</aside>

Authenticating requests

To authenticate requests, include a x-api-key header with the value "{YOUR_AUTH_KEY}".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

You can retrieve your token by visiting your dashboard and clicking Generate API token.

Sensors

Export sensor data

requires authentication

Export data from a sensor. Only sensors you own (via its hub) or sensors marked as public can be exported.

Dates: from and to accept ISO-8601 datetime strings (e.g. 2025-10-31T12:00:00Z) or Unix timestamps (seconds or milliseconds; ms auto-detected by length). If to is omitted it defaults to "now". All processing is in UTC. from must be before (or equal to) to.

Aggregation shapes:

Example request:
curl --request GET \
    --get "https://weather-guardian.com/api/sensors/SEN-089272C3AB30/export?from=2025-10-01T00%3A00%3A00Z&to=1730332799000&agg_type=hour" \
    --header "x-api-key: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"architecto\",
    \"to\": \"architecto\",
    \"agg_type\": \"raw\"
}"
const url = new URL(
    "https://weather-guardian.com/api/sensors/SEN-089272C3AB30/export"
);

const params = {
    "from": "2025-10-01T00:00:00Z",
    "to": "1730332799000",
    "agg_type": "hour",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "x-api-key": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "from": "architecto",
    "to": "architecto",
    "agg_type": "raw"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (200, raw):


{
    "ok": true,
    "geohash": "gcw2mn3",
    "data": [
        {
            "observed_at": "2025-10-31T12:34:56Z",
            "pressure_hpa": 1013.2,
            "temperature_c": 19.8,
            "humidity_pct": 62.1
        },
        {
            "observed_at": "2025-10-31T12:35:56Z",
            "pressure_hpa": 1013.1,
            "temperature_c": 19.9,
            "humidity_pct": 61.8
        }
    ]
}
 

Example response (200, hour):


{
    "ok": true,
    "geohash": "gcw2mn3",
    "data": {
        "2025-10-31": {
            "hours": {
                "12": {
                    "temperature": {
                        "avg": 19.4,
                        "min": 18.9,
                        "max": 20.1
                    },
                    "humidity": {
                        "avg": 61.7,
                        "min": 59.2,
                        "max": 64
                    },
                    "pressure": {
                        "avg": 1012.9,
                        "min": 1012.4,
                        "max": 1013.5
                    }
                },
                "13": {
                    "temperature": {
                        "avg": 19.1,
                        "min": 18.6,
                        "max": 19.8
                    },
                    "humidity": {
                        "avg": 62.3,
                        "min": 60.1,
                        "max": 64.2
                    },
                    "pressure": {
                        "avg": 1012.6,
                        "min": 1012.1,
                        "max": 1013
                    }
                }
            }
        }
    }
}
 

Example response (200, day):


{
    "ok": true,
    "geohash": "gcw2mn3",
    "data": [
        {
            "2025-10-30": {
                "temperature": {
                    "avg": 18.7,
                    "min": 16.9,
                    "max": 20.8
                },
                "humidity": {
                    "avg": 63.2,
                    "min": 54,
                    "max": 71.4
                },
                "pressure": {
                    "avg": 1014.1,
                    "min": 1009.8,
                    "max": 1017.2
                }
            }
        },
        {
            "2025-10-31": {
                "temperature": {
                    "avg": 18.1,
                    "min": 17.3,
                    "max": 19.4
                },
                "humidity": {
                    "avg": 64.5,
                    "min": 58.2,
                    "max": 69.9
                },
                "pressure": {
                    "avg": 1013,
                    "min": 1010.1,
                    "max": 1015
                }
            }
        }
    ]
}
 

Example response (403):


{
    "ok": false,
    "message": "unauthorised"
}
 

Example response (422):


{
    "message": "from date cannot be null"
}
 

Example response (422):


{
    "message": "unable to parse from date"
}
 

Example response (422):


{
    "message": "unable to parse to date"
}
 

Example response (422):


{
    "message": "to date must be after from date"
}
 

Request      

GET api/sensors/{sensor_id}/export

Headers

x-api-key        

Example: {YOUR_AUTH_KEY}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

sensor_id   string     

The ID of the sensor. Example: SEN-089272C3AB30

Query Parameters

from   string     

Start of the range (inclusive). ISO-8601 or Unix timestamp (s or ms). Example: 2025-10-01T00:00:00Z

to   string  optional    

End of the range (inclusive). ISO-8601 or Unix timestamp (s or ms). Defaults to now. Example: 1730332799000

agg_type   string     

The aggregation level. One of: raw, hour, day. Example: hour

Body Parameters

from   string     

Example: architecto

to   string  optional    

Example: architecto

agg_type   string     

Example: raw

Must be one of:
  • raw
  • hour
  • day

Export latest sensor measurement

requires authentication

Returns the latest measurement for a single sensor. Only sensors you own (via its hub) or sensors marked as public can be queried.

The response payload is the MeasurementResource output for the sensor's lastMeasurement.

Example request:
curl --request GET \
    --get "https://weather-guardian.com/api/sensors/SEN-089272C3AB30/latest" \
    --header "x-api-key: {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://weather-guardian.com/api/sensors/SEN-089272C3AB30/latest"
);

const headers = {
    "x-api-key": "{YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (200, ok):


{
    "observed_at": "2026-01-10T00:00:00Z",
    "pressure_hpa": 1013.2,
    "temperature_c": 19.8,
    "humidity_pct": 62.1,
    "battery_pct": 87
}
 

Example response (200, no_measurement):


null
 

Example response (403):


{
    "ok": false,
    "message": "unauthorised"
}
 

Example response (422):


"Data can only be exported from sensors"
 

Request      

GET api/sensors/{sensor_id}/latest

Headers

x-api-key        

Example: {YOUR_AUTH_KEY}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

sensor_id   string     

The ID of the sensor. Example: SEN-089272C3AB30

sensor   string     

The sensor device ID. Example: SEN-1234567890