openaq.OpenAQ.latest

OpenAQ.latest(**kwargs)[source]

Provides the latest value of each parameter for each location

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) – limit results by a specific parameter. 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.
  • limit (int) – change the number of results returned. Max is 10000. Default is 100.
  • page (int) – paginate through the results.
  • df (bool) – return results as a pandas DataFrame
  • index (string) – if returning as a DataFrame, set index to (‘utc’, ‘local’, None). The default is local
Returns:

dictionary containing the location, country, city, and number of measurements

Example:
>>> import openaq
>>> api = openaq.OpenAQ()
>>> status, resp = api.latest()
>>> resp['results']
[
    {
        "location": "Punjabi Bagh",
        "city": "Delhi",
        "country": "IN",
        "measurements": [
            {
                "parameter": "so2",
                "value": 7.8,
                "unit": "ug/m3",
                "lastUpdated": "2015-07-24T11:30:00.000Z"
            },
            {
                "parameter": "co",
                "value": 1.3,
                "unit": "mg/m3",
                "lastUpdated": "2015-07-24T11:30:00.000Z"
            },
            ...
        ]
        ...
    }
]