QuantAQ Cloud API
The QuantAQ Cloud API allows you to manage your air quality sensors and data in a simple, programmatic way using conventional HTTP requests. Each endpoint is intuitive and allows you to obtain data and execute various actions easily. If you notice something that can be made more clear or more intuitive, please let us know!
This documentation will begin with a general overview of the API and how it works, followed by details on each endpoint that is available in *v1* of the API. Throughout this documentation, there will be code examples using httpie - an easy-to-use command line client for making HTTP requests. The names of specific resources will be represented by variables which are wrapped in "<>".
Getting Started
Obtaining an API key
Authentication is handled using HTTP Basic Auth which consists of sending an API key that is unique to your account with each request. This key should be kept secret and not shared with anyone. This API key is tied to your user account and will only allow you to take actions within your assigned scope of permissions.
You can generate an API key for your account by visiting the Developer section within the QuantAQ Cloud and clicking Generate New Key in the upper right-hand corner of your screen. It is recommended that you set this key as an environment variable on your computer with the name QUANTAQ_APIKEY.
To include your API key in your request, add an HTTP Authorization header, consisting of a username
and password.
When using httpie, you can use the -a
flag to indicate authorization. The API key serves as the username and the password should be left blank.
Sending your first API call
To make an API call, you need four pieces of information:
api_key
: a random string of alphanumeric characters that gives you access to the APIendpoint
: the URI listed in the API reference section belowmethod
: one of GET, POST, PUT, or DELETEarguments
: JSON-encoded values sent to the method (these are not always required)
More often than not, you will be sending either GET or POST requests to api.quant-aq.com
. All API endpoints begin with the same URL which, for the QuantAQ Cloud, is api.quant-aq.com/
. The full URL will be of the form:
The version
of the API may change (this will be documented) which signals changes in the underlying structure of the API. For now, there is only one version available: v1
. Throughout these docs, we will just assume the version is v1
.
A good first API call would be to get your account information. As mentioned above, we will be using httpie for examples. To get your account information, the API call would look like:
You should see a response that looks something like the following:
Understanding API calls and responses
Any tool that is fluent in HTTP requests and supports HTTP basic authentication protocols can be used to communicate with the QuantAQ Cloud API. Requests must be made using HTTPS. The interface response depends on the action required.
HTTP statuses and errors
Each request that is made to the API will have an attached status code that tells you whether the request was successful or not. If there is an issue with the request, an error will be returned as indicated both by the HTTP status code and the response body. In general, if the status code is in the 200's, the request was successful. If the status code is in the 400's, there was an error with the request; this could range from improper authentication to an illegal operation (e.g., you were trying to request data for which you do not have the necessary permissions). If a 500 error is returned, there was a server-side error which means we were unable to process the request for some reason.
An example error response:
API Reference
Account
This is an object representing your account information. You can retrieve it to see basic information about your account, as summarized in the attributes section below.
Get your account information
GET
/v1/account
Retrieves the current account information for the user who is making the request.
Path Parameters
None.
Query Parameters
None.
Response
Body
username
string
The accounts username
confirmed
boolean
True if the account user has confirmed their email address
email
string
The email address of record for the user
first_name
string
The first name of the account user
last_name
string
The last name of the account user
id
int
The unique identifier for the account user
last_seen
datetime
The last time the account user was seen
member_since
datetime
The timestamp corresponding to when the user joined the site
Devices
This is an object representing a QuantAQ device. You can retrieve device information, either on an individual sensor basis or as a list to see basic information about the device(s), as summarized in the attributes section below. You can also update the information for a single device or delete a device.
Get a single Device
GET
/v1/devices/{serial_number}
Retrieves the information for a single device by its serial number.
Path Parameters
serial_number
string
The serial number of the device
Query Parameters
None.
Response
Body
city
string
The city in which the device is installed
country
string
2-digit ISO country code corresponding to the country where the device is installed
created
datetime
The timestamp corresponding to when the device was brought online
description
string
The user-defined device description
geo.lat
float
The latitude corresponding to the geolocation of the device
geo.lon
float
The longitude corresponding to the geolocation of the device
id
int
The unique identifier for the device
model
string
The device model: one of [ modulair, modulair_pm, arisense_v200 ]
last_seen
datetime
The last time the device was seen
n_datapoints
int
The total number of data points the device has collected over its lifetime
*no longer valid
owner_id
int
The id of the device owner
private
boolean
True if the device is marked as private by the device owner
sn
string
The serial number of the device
status
string
The current operation status of the device. One of: [ CALIBRATION, ACTIVE, RETIRED, PRE_REGISTERED ]
timezone
string
The timezone corresponding to the location where the device is installed
url
string
The url corresponding to the device
Get a list of Devices
GET
/v1/devices
Retrieves a paginated list of devices including all devices the user has access to across Organizations and Networks. If no Devices are available, an empty list will be returned.
Path Parameters
None.
Query Parameters
org_id
int, optional
The ID of the Organization to subquery
network_id
int, optional
The ID of the Network to subquery
per_page
int
The number of items to return per page (default=50)
page
int
The page number to return (default=1)
sort
string, optional
Please see the advanced queries section at the bottom of this page for more information
filter
string, optional
Please see the advanced queries section at the bottom of this page for more information
limit
int, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the table in the previous section for detailed body information.
Meta
Update a Device
PUT
/v1/devices/{serial_number}
Retrieves the information for a single device by its serial number.
Path Parameters
serial_number
string
The serial number of the device
Query Parameters
city
string
The city in which the device is installed
country
string
2-digit ISO country code corresponding to the country where the device is installed
description
string
The user-defined device description
lat
float
The latitude corresponding to the geolocation of the device
lon
float
The longitude corresponding to the geolocation of the device
is_private
boolean
True if the device is marked as private by the device owner
device_state
string
The current operation status of the device. One of: [ CALIBRATION, ACTIVE, RETIRED, PRE_REGISTERED ]
timezone
string
The timezone corresponding to the location where the device is installed
Response
Body
Please see the table in the previous section for detailed body information.
Organizations
This is an object representing an Organization. You can retrieve it to see basic information about a given Organization including the members and devices, as summarized in the attributes section below.
Get a single Organization
GET
/v1/orgs/{org_id}
Retrieve the information for a single Organization by its Organization ID. The user must be a confirmed member of the Organization, or the endpoint will return a 403.
Path Parameters
org_id
int
The ID of the Organization
Query Parameters
None.
Response
Body
name
string
The name of the Organization
id
string
The unique identifier for the Organization
description
string
A short description of the Organization
created_on
datetime
An ISO-formatted timestamp representing the creation date of the Organization
sandbox
boolean
true if a Sandbox Organization, otherwise false
members
list
A list containing the confirmed members of the Organization that are visible to the requesting user. Organization administrators can see all Organization members. Each entry is a sub-object representing an Organization user including their role and username.
devices
list
A list containing the serial number of all Devices associated with the Organization that are visible to the requesting user. An administrator can see all Organization-managed devices, while a non-administrator can see the Devices for the Networks they are a member of.
networks
list
A list containing the IDs of all Networks associated with the Organization that are visible to the requesting user.
Get a list of all Organizations
GET
/v1/orgs/
Retrieves a list of all organizations the user account has access to. This endpoint returns a paginated list of Organization objects. The call will return an empty list if no Organizations met the provided parameters, or if the requester is not a confirmed member of any Organizations (though they should be the member of their own sandbox).
Path Parameters
None.
Query Parameters
per_page
int
The number of items to return per page (default=50)
page
int
The page number to return (default=1)
sort
string, optional
Please see the advanced queries section at the bottom of this page for more information
filter
string, optional
Please see the advanced queries section at the bottom of this page for more information
limit
int, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the single Organization section above for details on the response body.
Meta
Networks
This is an object representing a Network. You can retrieve it to see basic information about a given Network including the members and Devices.
Get a Network
GET
/v1/orgs/{org_id}/{network_id}
Retrieve the information for a single Network by its Organization ID and Network ID. The user must be a confirmed member of the Network, or the endpoint will return a 403.
Path Parameters
org_id
int
The ID of the Organization
network_id
int
The ID of the Network
Query Parameters
None.
Response
Body
name
string
The name of the Network
id
string
The unique identifier for the Network
description
string
A short description of the Network
created_on
datetime
An ISO-formatted timestamp representing the creation date of the Network
members
list
A list containing the confirmed members of the Network that are visible to the requesting user.
devices
list
A list containing the serial number of all Devices associated with the Network.
Get a list of Networks
GET
/v1/orgs/{org_id}/networks/
Retrieves a list of all visible Networks belonging to a given Organization. This endpoint is scoped behind the Organization endpoint, so you must provide an Organization ID. An Organization’s Network is visible to a user if they are an Organization administrator or a member of the Network. The Organization must be visible to the requester, or the endpoint will return a 403.
Path Parameters
org_id
int
The ID of the Organization
Query Parameters
per_page
int
The number of items to return per page (default=50)
page
int
The page number to return (default=1)
sort
string, optional
Please see the advanced queries section at the bottom of this page for more information
filter
string, optional
Please see the advanced queries section at the bottom of this page for more information
limit
int, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the single Network section above for details on the response body.
Meta
Data
This is an object representing your data for a given Device. You can retrieve it as a list for either raw or final data
Get final data
GET
/v1/devices/{serial_number}/data/
Retrieves a paginated list of data for a specific device using its serial number.
Path Parameters
serial_number
string
The serial number of the device you would like to query
Query Parameters
per_page
int
The number of items to return per page (default=50)
page
int
The page number to return (default=1)
sort
string, optional
Please see the advanced queries section at the bottom of this page for more information
filter
string, optional
Please see the advanced queries section at the bottom of this page for more information
limit
int, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the product manual for the type of Device you are querying for details on the response body. These are located in the "Hardware" section of these docs.
Meta
Get raw data
GET
/v1/devices/{serial_number}/data/raw/
Retrieves a paginated list of raw data for a specific device using its serial number.
Path Parameters
serial_number
string
The serial number of the device you would like to query
Query Parameters
per_page
int
The number of items to return per page (default=50)
page
int
The page number to return (default=1)
sort
string, optional
Please see the advanced queries section at the bottom of this page for more information
filter
string, optional
Please see the advanced queries section at the bottom of this page for more information
limit
int, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the product manual for the type of Device you are querying for details on the response body. These are located in the "Hardware" section of these docs.
Meta
Data by Date
This section and the endpoint were added on March 31st, 2022.
This is an object representing your data for a given Device, as queried by date. You can retrieve it as a list for either raw or final data.
Get final data by date
GET
/v1/devices/{serial_number}/data-by-date/{date}/
Retrieves a paginated list of final data for a specific device using its serial number for a specific date.
Path Parameters
serial_number
string
The serial number of the device you would like to query
date
string
The date for which you would like to return data. The format must be YYYY-MM-DD and all dates are in GMT. Thus, if you request data for 2022-01-01, it will return all data for the device on Jan. 1st GMT.
Query Parameters
per_page
int
The number of items to return per page (default=50)
page
int
The page number to return (default=1)
sort
string, optional
Please see the advanced queries section at the bottom of this page for more information
filter
string, optional
Please see the advanced queries section at the bottom of this page for more information
limit
int, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the product manual for the type of Device you are querying for details on the response body. These are located in the "Hardware" section of these docs.
Meta
Get raw data by date
GET
/v1/devices/{serial_number}/data-by-date/raw/{date}/
Retrieves a paginated list of raw data for a specific device using its serial number for a specific date.
Path Parameters
serial_number
string
The serial number of the device you would like to query
date
string
The date for which you would like to return data. The format must be YYYY-MM-DD and all dates are in GMT. Thus, if you request data for 2022-01-01, it will return all data for the device on Jan. 1st GMT.
Query Parameters
per_page
int
The number of items to return per page (default=50)
page
int
The page number to return (default=1)
sort
string, optional
Please see the advanced queries section at the bottom of this page for more information
filter
string, optional
Please see the advanced queries section at the bottom of this page for more information
limit
int, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the product manual for the type of Device you are querying for details on the response body. These are located in the "Hardware" section of these docs.
Meta
Most Recent Data
Retrieve the most recent data record for either a single Device (by serial number), a Network (id), or an Organization (id). A list will be returned for any of them.
Get the most recent data
GET
/v1/data/most-recent/
Retrieves the data for a specific Device using its serial number or a list of Devices using an Organization ID or Network ID. If multiple parameters are used, the devices from which data is fetched must meet all conditions.
Path Parameters
None.
Query Parameters
At least one of sn
, org_id
, or network_id
must be provided otherwise a 400 error will be returned.
sn
string
The serial number of the device in question.
org_id
int
The ID of the Organization.
network_id
int
The ID of the Network.
per_page
int
The number of items to return per page (default=50)
page
int
The page number to return (default=1)
sort
string, optional
Please see the advanced queries section at the bottom of this page for more information
filter
string, optional
Please see the advanced queries section at the bottom of this page for more information
limit
int, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the product manual for the type of Device you are querying for details on the response body. These are located in the "Hardware" section of these docs.
Meta
Resampled Data
As of September 24th, 2024, the resampled data downloads only provide data for completed resampling periods. Future periods and the current in-progress period will be omitted. For more information about how QuantAQ resamples data, see this article.
The attributes for the resampled data object depend on the model of the Device and will always return the final data. Generally, a list is returned containing all available data for that Device, per period.
The data returned from this endpoint differs from others in several ways. Some further remarks on the structure and contents:
Data entries may be
null
, if there are no measurements for that period, or if the number of measurements does not meet the completeness criterion. For more information refer to this help article.Periods are included even if no measurements meet the completeness criterion.
The number of data records (of any sort) is provided in
n_datapoints
. Note that this does not indicate that every data record has a valid measurement for every listed pollutant, since components may operate independently of each other.Periods are computed using the device’s local timezone. Across Daylight Savings Time borders, there may be more or less time represented by a given period. Further discussion here.
Times are provided in both local and UTC time, with offsets included.
Averaging is done naively across all data within the period and is not intended to match the National Ambient Air Quality Standard (NAAQS) or other specific averaging logic and is provided for convenience only
Get resampled data
This endpoint will be deprecated in January 2025 and replaced by a new resampled data endpoint.
Retrieves the data for a specific device using its serial number.
GET
/v1/data/resampled/
Path Parameters
None.
Query Parameters
sn
, start_date
, and end_date
must be provided otherwise a 400 error will be returned.
sn
string, required
The serial number of the device in question.
start_date
string, required
The ID of the Organization.
end_date
string, required
The ID of the Network.
period
string, optional
Please see the advanced queries section at the bottom of this page for more information
Response
Body
Please see the product manual for the type of Device you are querying for details on the response body. These are located in the "Hardware" section of these docs.
[FIX META RESPONSE BLOCK]
Meta Data
Logs
Advanced Queries
Most QuantAQ Cloud API endpoints support advanced queries that allow you to filter, limit, and sort your results. All endpoints that return paginated data - such as retrieving data points - support these requests.
Filtering requests
To filter a query, use the filter
keyword argument with the format filter=<parameter>,<filter spec>,<value>
. Multiple filters can be combined using a ;
to build complex queries. For example, if we want to return the data points where PM2.5 is between 25 and 50 µg/m3, we would write filter=pm25,ge,25;pm25,le,50;
.
A full request might then look like:
The following filter specs are supported and available to use:
eq
: = (equals)ne
: ≠ (not equals)lt
: < (less than)gt
: > (greater than)ge
: ≥ (greater than or equal to)le
: ≤ (less than or equal to)in
: inlike
: like
Limiting requests
To limit the number of data points returned for any given request, use the limit
keyword argument with the number of data you would like returned. For example, to return just the first 5 items, use limit=5
. If you are calling an endpoint that returns paginated data and would like to return a specific number of data per page, you can alternatively (or additionally) use the per_page
keyword argument.
Sorting requests
To return data in a specific order, you can use the sort
keyword argument with format sort=<parameter>,<order>
where order
is one of asc
or desc
. For example, if you want to return the data descended by timestamp:
Other Resources
SDKs
py-quantaq
py-quantaq
is the official python API wrapper for the QuantAQ Cloud API and is maintained and supported by QuantAQ. Full documentation can be found here. For questions specfiic to py-quantaq
, please use the GitHub repository issues page.
r-quantaq
r-quantaq
is the official R API wrapper for the QuantAQ Cloud API and is maintained and supported by QuantAQ. Full documentation can be found here. For questions specfiic to R-quantaq
, please use the GitHub repository issues page.
Changelog
September 24th, 2024
The Resampled Data endpoint now omits future periods on the current day instead of including them as null.
February 27th, 2024
A Resampled Data endpoint was added (
/v1/data/resampled/
)
December 28th, 2023
All teams-related endpoints and parameters were removed, following deprecation in Summer 2023
After significant user feedback, “Public” devices are no longer accessible via the API to unauthorized users without Org or Network access. (Public devices remain visible through the QuantAQ Cloud web app)
November 7th, 2023
Several new endpoints were added, to accommodate organization and network requests:
/v1/orgs/
/v1/orgs/<org_id>/
/v1/orgs/<org_id>/networks/
/v1/orgs/<org_id>/networks/<network_id>
Two endpoints were changed to permit filtering by organization and network:
/v1/data/most-recent/
now accepts optionalorg_id
andnetwork_id
filtering parameters/v1/data/devices/
now accepts optionalorg_id
andnetwork_id
filtering parameters
March 31st, 2022
Two new endpoints were added (
/devices/<sn>/data-by-date/<date>/
,/devices/<sn>/data-by-date/raw/<date>/
) to allow users to more efficiently query large amounts of data
January 26th, 2022
A new endpoint was added (
/data/most-recent/
) to allow users to query the most recent data for a single device or team of devices.
January 11th, 2021
the
devices/
endpoint was updated to allow for a new parameter (team
) which permits users to query available devices by team name. Simply add?team=team-1
and you will only be returned the available devices for the requested team. If the team name does not exist or have any devices, an empty list will be returned. If you would like to return all available devices across all of your teams, simply omit the team parameter as before.
Last updated