openaq.OpenAQ.cities

OpenAQ.cities(**kwargs)[source]

Returns a listing of cities within the platform.

Parameters:
  • country (string or array of strings) – limit results by a certain country
  • limit (number) – limit results in the query. Default is 100. Max is 10000.
  • page (number) – paginate through the results. Default is 1.
  • order_by (string or list of strings) – order by one or more fields (ex. order_by=[‘country’, ‘locations’]). Default value is ‘country’
  • sort (string) – define the sort order for one or more fields (ex. sort=’desc’)
  • df (bool) – convert the output from json to a pandas DataFrame
  • index (string) – if returning as a DataFrame, set index to (‘utc’, ‘local’, None). The default is ‘local’
Returns:

dictionary containing the city, country, count, and number of locations

Example:
>>> import openaq
>>> api = openaq.OpenAQ()
>>> status, resp = api.cities()
>>> resp['results']
[
    {
        "city": "Amsterdam",
        "country": "NL",
        "count": 21301,
        "locations": 14
    },
    {
        "city": "Badhoevedorp",
        "country": "NL",
        "count": 2326,
        "locations": 1
    },
    ...
]