airqo@1.0.0
- getHistoricalMeasurements(entityType, entityId, [params])
- getRecentMeasurements(entityType, entityId)
This adaptor exports the following namespaced functions:
This adaptor exports the following from common:
- as()
- combine()
- cursor()
- dataPath()
- dataValue()
- dateFns
- each()
- field()
- fields()
- fn()
- fnIf()
- group()
- lastReferenceValue()
- map()
- merge()
- scrubEmojis()
- sourceValue()
Functions
getHistoricalMeasurements
getHistoricalMeasurements(entityType, entityId, [params]) ⇒ Operation
Retrieve historical (past) air quality measurements for a monitoring entity.
The entityType determines which kind of entity is queried. Valid values are:
'sites'— a single monitoring site'devices'— a specific sensor device'grids'— a named geographic grid (e.g. a city or country)'cohorts'— a user-defined group of devices
| Param | Type | Description |
|---|---|---|
| entityType | string | Type of entity: sites, devices, grids, or cohorts. |
| entityId | string | ID of the entity to retrieve measurements for. |
| [params] | object | Request parameters documented in Request parameters. |
Example: Get historical measurements for a site
getHistoricalMeasurements('sites', 'site123', { limit: 100 });
Example: Get historical measurements for a grid with date range
getHistoricalMeasurements('grids', 'grid123', {
startTime: '2024-01-01T00:00:00Z',
endTime: '2024-01-31T23:59:59Z',
});
getRecentMeasurements
getRecentMeasurements(entityType, entityId) ⇒ Operation
Retrieve the most recent air quality measurements for a monitoring entity.
The entityType determines which kind of entity is queried. Valid values are:
'sites'— a single monitoring site'devices'— a specific sensor device'grids'— a named geographic grid (e.g. a city or country)'cohorts'— a user-defined group of devices
| Param | Type | Description |
|---|---|---|
| entityType | string | Type of entity: sites, devices, grids, or cohorts. |
| entityId | string | ID of the entity to retrieve measurements for. |
Example: Get recent measurements for a site
getRecentMeasurements('sites', 'site123');
Example: Get recent measurements for a grid
getRecentMeasurements('grids', 'grid123');
Example: Get recent measurements for a device
getRecentMeasurements('devices', 'device123');
http
These functions belong to the http namespace.
http.get
get(path, [options]) ⇒ Operation
Make a generic authenticated GET request to any AirQo endpoint.
| Param | Type | Description |
|---|---|---|
| path | string | |
| [options] | object | Additional options such as query parameters or headers. |
Example: Get raw data from any AirQo path
http.get('devices/measurements/sites/site123/recent');
http.post
post(path, [body], [options]) ⇒ Operation
Make a generic authenticated POST request to any AirQo endpoint.
| Param | Type | Description |
|---|---|---|
| path | string | API path relative to the configured base URL. |
| [body] | object | JSON request body. |
| [options] | object | Additional request options. |
Example: Post a body to any AirQo path
http.post('devices/metadata/sites', { name: 'Kampala' });
http.request
request(method, path, [options]) ⇒ Operation
Make a generic authenticated request of any HTTP method to any AirQo endpoint.
| Param | Type | Description |
|---|---|---|
| method | string | HTTP method. |
| path | string | API path relative to the configured base URL. |
| [options] | object | Additional request options. |
Example: Make an arbitrary request
http.request('GET', 'devices/measurements/sites/site123/recent');