CanAirIO fixed stations API for fetch published data


The current fixed stations are stored in an InfluxDB database service, each station write a data series time in separated tables. We will change it to different schema soon. For now the next endpoints are enabled.

Data visualization

For now, the shared series time of each stations could be listed in our Grafana dashboard here:

CanAirIO grafana

Mobile track visualization

Data endpoint

Each series time could be fetched via the next endpoint:

the full documentation of InfluxDB query syntax could be consulted here

For example:


curl -G '' --data-urlencode 'q=select * from "PM25_Berlin_CanAirIO_v2" WHERE time >= now() - 12h' > PM25_Berlin_CanAirIO_v2.json

Linux - New Data Model

curl -G '' --data-urlencode "q=select \"name\", \"mac\", \"geo3\", \"pm25\" from fixed_stations_01 WHERE \"name\"='6MCESP32DE8CBC2' and time >= now() - 1m" > data_specific_station_last_minute.json

Python - New Data Model


import requests

parameters = {'q': "select \"name\", \"mac\", \"geo3\", \"pm25\" from fixed_stations_01 WHERE \"name\"='6MCESP32DE8CBC2' and time >= now() - 1m", 'db':database}
response = requests.get(endpoint, params=parameters)


curl -Headers @{"accept"="application/json"}  '' -Body @{"q" = 'select * from "PM2.5_BOG_TUN_EstacionTunal" WHERE time >= now() - 12h'}  -OutFile PM2.5_BOG_TUN_EstacionTunal.json

If you want to get the data with a specific time resolution, you need a agregation function in the select section of the query and group the results by the resolution time, in the next example we use the agregation function mean() for all the variables, you can use the same or one of median(), count(), min(), max(), sum(), first(), last(), spread() or stddev().

Note the last part of the query, we add the sql clause GROUP BY time(resolution_time)

curl -G '' --data-urlencode 'q=select mean(*) from "PM25_Berlin_CanAirIO_v2" WHERE time >= now() - 12h GROUP BY time(1m)' > PM25_Berlin_CanAirIO_v2.json

The last couple of examples return the data in json format, if you want to get the data in CSV format you need to add the header “Accept: application/csv” to the curl request using the parameter -H like show the next example:

curl -H 'Accept:application/csv' -G '' --data-urlencode 'q=select mean(*) from "PM25_Berlin_CanAirIO_v2" WHERE time >= now() - 12h GROUP BY time(1m) FILL(none)' > PM25_Berlin_CanAirIO_v2.csv

Fixed stations names

For get the complete list of fixed stations names:

curl -G '' --data-urlencode 'q=show measurements'

But the more important stations of CanAirIO with more stable data is listed here.

Python example

In your OS please install before the python3-virtualenv package, then:

create and activate your virtual space:

virtualenv venv && source venv/bin/activate

install the next package for run the test:

pip3 install influxdb ipython


enter to ipython console with the command ipython and execute the next lines for import the influxDb client and instance it:

from influxdb import InfluxDBClient
client = InfluxDBClient(host='', port=8086, database='canairio')

after that, run a query:

client.query('select * from "PM2.5_BOG_FON_Hayuelos_E01" WHERE time >= now() - 10m')

you should have an output similar to next:

python output from fixed station query

Stations names

for get the all names of fixed stations:


All tracks request

For now we don’t have this development, CanAirIO is a opensource initiative and you able to send any pull request for help us in improve our API. For now we have published some backups of last one year, for example:

CanAirIO full snap - fixed stations

Please read the README file in the link for details.

Tags: api