openaq.OpenAQ.measurements

OpenAQ.measurements(**kwargs)[source]

Provides data about individual measurements

Parameters:
  • city (string) – Limit results by a certain city. Defaults to None.
  • country (string) – Limit results by a certain country. Should be a 2-digit ISO country code. Defaults to None.
  • location (string) – Limit results by a city. Defaults to None.
  • parameter (string, array, or tuple) – Limit results by one or more parameters. Options include [ pm25, pm10, so2, co, no2, o3, bc]
  • has_geo (bool) – Filter items that do or do not have geographic information.
  • coordinates (string) – center point (lat, long) used to get measurements within a certain area. (Ex: coordinates=40.23,34.17)
  • radius (int) – radius (in meters) used to get measurements. Must be used with coordinates. Default value is 2500.
  • value_from (number) – Show results above a value threshold. Must be used with parameter.
  • value_to (number) – Show results below a value threshold. Must be used with parameter.
  • date_from (date) – Show results after a certain date. Format should be Y-M-D.
  • date_to (date) – Show results before a certain date. Format should be Y-M-D.
  • sort (string) – The sort order (asc or desc). Must be used with order_by.
  • order_by (string) – Field to sort by. Must be used with sort.
  • include_fields (array) – Include additional fields in the output. Allowed values are: attribution, averagingPeriod, and sourceName.
  • limit (number) – Change the number of results returned. Max is 10000 and default is 100.
  • page (number) – Paginate through the results
  • df (bool) – return the results as a pandas DataFrame
  • index (string) – if returning as a DataFrame, set index to (‘utc’, ‘local’, None). The default is local
Returns:

a dictionary containing the date, parameter, value, unit, location, country, city, coordinates, and sourceName.

Example:
>>> import openaq
>>> api = openaq.OpenAQ()
>>> status, resp = api.measurements(city = 'Delhi')
>>> resp['results']
{
    "parameter": "Ammonia",
    "date": {
        "utc": "2015-07-16T20:30:00.000Z",
        'local': "2015-07-16T18:30:00.000-02:00"
    },
    "value": "72.9",
    "unit": "ug/m3",
    "location": "Anand Vihar",
    "country": "IN",
    "city": "Delhi",
    "coordinates": {
        "latitude": 43.34,
        "longitude": 23.04
    },
    "attribution": {
        "name": "SINCA",
        "url": "http://sinca.mma.gob.cl/"
    },
    {
        "name": "Ministerio del Medio Ambiente"
    }
    ...
}