Introduction

The AirLink provides an HTTP interface that can be used by a computer on the same local area network to retrieve current air quality data.

Current condition data is formatted as a JSON document containing air quality data from the particulate matter sensor as well as readings from the on-board temperature / humidity sensor.

For information on how to remotely retrieve current and historic air quality data, see the WeatherLink v2 API documentation.

Format of HTTP requests

The path for current conditions data is /v1/current_conditions.

The full URL is:

http://<airlink-ip-address-here>/v1/current_conditions

For example, if the IP address of the AirLink is 192.168.1.3, then the URL would be:

http://192.168.1.3/v1/current_conditions

Using curl:

curl -X GET -H "application/json" http://192.168.1.3/v1/current_conditions

Response format

General response format

The general format of all API responses is a JSON object that always contains exactly two keys - data and error.

current_conditions data format

For AirLink current conditions, the data object contains the following fields:

Sensor data format

Each sensor data object contains at a minimum, the following fields:

Combined air quality and temperature / humidity sensor data

For AirLink combined air quality and temperature / humidity data, the data structure type is currently 6.

Apart from the common fields described above, the following fields are defined:

Notes:

Sample JSON

Below is a sample of the JSON response from /v1/current_conditions, after running the output through a JSON formatter:

{
  "data":{
    "did":"001D0A100021",
    "name":"My AirLink",
    "ts":1599150192,
    "conditions":[
      {
        "lsid":123456,
        "data_structure_type":6,
        "temp":75.8,
        "hum":54.3,
        "dew_point":58.2,
        "wet_bulb":62.7,
        "heat_index":76.0,
        "pm_1_last":1,
        "pm_2p5_last":1,
        "pm_10_last":1,
        "pm_1":0.96,
        "pm_2p5":1.21,
        "pm_2p5_last_1_hour":2.30,
        "pm_2p5_last_3_hours":2.29,
        "pm_2p5_last_24_hours":4.81,
        "pm_2p5_nowcast":2.30,
        "pm_10":1.21,
        "pm_10_last_1_hour":2.84,
        "pm_10_last_3_hours":2.80,
        "pm_10_last_24_hours":6.03,
        "pm_10_nowcast":2.84,
        "last_report_time":1599150192,
        "pct_pm_data_last_1_hour":100,
        "pct_pm_data_last_3_hours":100,
        "pct_pm_data_nowcast":100,
        "pct_pm_data_last_24_hours":80
      }
    ]
  },
  "error":null
}

Old versions

Older versions of firmware may report a data structure type of 5. The format is nearly identical to the type 6 document described above, except that some of the fields were not named consistently and have been renamed:

Type 6 Name Type 5 Name
pm_10 pm_10p0
pm_10_last_1_hour pm_10p0_last_1_hour
pm_10_last_3_hours pm_10p0_last_3_hours
pm_10_last_24_hours pm_10p0_last_24_hours
pm_10_nowcast pm_10p0_nowcast

HTTP Server Performance

The embedded web server can process approximately three requests per second. Attempting to poll with multiple connections more often than three times per second may cause some HTTP requests to be dropped.

Device discovery

AirLink devices advertise their presence on the local network using DNS Service Discovery over multicast DNS (mDNS). These technologies are also known as Zeroconf or Bonjour or Avahi.

DNS details

If you are familiar with DNS service discovery, the two most important parameters are the service name and the domain. For AirLink, the service name is _airlink._tcp and the domain is local.

For most libraries, those two parameters should be all you need to plug in to start discovering AirLink devices. In some cases, the library may expect the full DNS service record name, which for AirLink is:

_airlink._tcp.local.

Note: there is a trailing dot at the end, and it is significant!

As mentioned above, it is possible to programatically find the name and IP address of AirLink devices on the local network using mDNS and DNS-SD. In the event that you only need to find out the IP address for one device, there are some alternatives that may be simpler.

AirLink devices identify themselves using a hostname of the form airlink-<did>, where did is the last six digits of the serial number. For example, for an AirLink device with a serial number of 001D0A100008, the hostname would be airlink-100008.

Via router admin page

When requesting an IP address via DHCP, the AirLink will identify itself to the router using the hostname described above. Some routers have built-in administrative pages that can be used to view a list of connected devices with their hostname and IP address.

Via mDNS

If your computer supports mDNS name resolution, you can also try accessing an AirLink device using its mDNS hostname, which is just the hostname with .local, e.g. airlink-100008.local.

Via WeatherLink.com

If you are the registered owner of the device on WeatherLink.com, you can find the device’s IP address on the “Health Data” page, listed as “AirLink IP Address”.

This may be found from the right “Wrench” tool icon, select registered AirLink device name, expand device name, and select “Health Data” from the top portion of the page.