Skip to main content

airqo@1.0.0

getHistoricalMeasurements(entityType, entityId, [params])
getRecentMeasurements(entityType, entityId)

This adaptor exports the following namespaced functions:

http.get(path, [options])
http.post(path, [body], [options])
http.request(method, path, [options])

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
ParamTypeDescription
entityTypestringType of entity: sites, devices, grids, or cohorts.
entityIdstringID of the entity to retrieve measurements for.
[params]objectRequest 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
ParamTypeDescription
entityTypestringType of entity: sites, devices, grids, or cohorts.
entityIdstringID 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.

ParamTypeDescription
pathstring
[options]objectAdditional 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.

ParamTypeDescription
pathstringAPI path relative to the configured base URL.
[body]objectJSON request body.
[options]objectAdditional 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.

ParamTypeDescription
methodstringHTTP method.
pathstringAPI path relative to the configured base URL.
[options]objectAdditional request options.

Example: Make an arbitrary request

http.request('GET', 'devices/measurements/sites/site123/recent');