Skip to content
Ricardo Alanis edited this page May 5, 2016 · 5 revisions

Welcome to the api-calidad-aire wiki!

curl -i -F name=test -F [email protected] http://respiraciudad.org:8000/

GET /countries

Returns all the countries.

Response body example:

{
    "data": [
        {
            "id": "564eacf73372c318b2aee2df",
            "id_country": null,
            "latitude": null,
            "level": "country",
            "longitude": null,
            "name": "M\u00e9xico",
            "timezone": "GMT +6"
        },
        {
            "id": "564eacf73372c318b2aee2df",
            "id_country": null,
            "latitude": null,
            "level": "country",
            "longitude": null,
            "name": "M\u00e9xico",
            "timezone": "GMT +6"
        }
    ],
    "has_more": false
}

GET /countries/:country_name

Returns the specified country.

Response body example:

/countries/?name=M%C3%A9xico

{
    "data": [
        {
            "id": "564eacf73372c318b2aee2df",
            "id_country": null,
            "latitude": null,
            "level": "country",
            "longitude": null,
            "name": "M\u00e9xico",
            "timezone": "GMT +6"
        }
    ],
    "has_more": false
}

GET /cities

Returns all the cities.

Response body example:

/cities/

{
    "data": [
        {
            "id": "564ead563372c318b2aee2e0",
            "id_city": null,
            "id_country": "MX",
            "latitude": null,
            "level": "city",
            "longitude": null,
            "name": "Ciudad de M\u00e9xico",
            "timezone": "GMT +6"
        },
        {
            "id": "564ead703372c318b2aee2e1",
            "id_city": null,
            "id_country": "MX",
            "latitude": null,
            "level": "city",
            "longitude": null,
            "name": "Monterrey",
            "timezone": "GMT +6"
        }
    ],
    "has_more": false
}

GET /cities/:city_name

Returns the specified city.

Response body example:

/cities/?name=Monterrey

{
    "data": [
        {
            "id": "564ead703372c318b2aee2e1",
            "id_city": null,
            "id_country": "MX",
            "latitude": null,
            "level": "city",
            "longitude": null,
            "name": "Monterrey",
            "timezone": "GMT +6"
        }
    ],
    "has_more": false
}

GET /stations

Returns all the stations.

Response body example:

/stations/

{
    "data": [
        {
            "id": "564eae1f3372c3924116b886",
            "id_city": "CDMX",
            "id_country": "MX",
            "id_station": null,
            "latitude": null,
            "level": "station",
            "longitude": null,
            "name": "Tacubaya",
            "timezone": "GMT +6"
        },
        {
            "id": "564eae383372c3924116b887",
            "id_city": "MTY",
            "id_country": "MX",
            "id_station": null,
            "latitude": null,
            "level": "station",
            "longitude": null,
            "name": "Cerro de la Campana",
            "timezone": "GMT +6"
        }
    ],
    "has_more": false
}

GET /stations/:station_name

Returns the specified station.

Response body example:

/stations/?name=Cerro de la Campana

{
    "data": [
        {
            "id": "564eae383372c3924116b887",
            "id_city": "MTY",
            "id_country": "MX",
            "id_station": null,
            "latitude": null,
            "level": "station",
            "longitude": null,
            "name": "Cerro de la Campana",
            "timezone": "GMT +6"
        }
    ],
    "has_more": false
}

GET /methods

Returns all the methods.

Response body example: /methods/

{
    "data": [
        {
            "id": "564ea8313372c318b2aee2dd",
            "method_device": "Supermaquin\u00f3n 1",
            "method_id": "met1",
            "method_protocol": "Pasito 1, Pasito 2, Pasito tun tun",
            "method_shortdescription": null
        },
        {
            "id": "564ea8313372c318b2aee2dd",
            "method_device": "Supermaquin\u00f3n 2",
            "method_id": "met1",
            "method_protocol": "Pasito 1, Pasito 2, Pasito tun tun",
            "method_shortdescription": null
        },
    ],
    "has_more": false
}

GET /methods/:method_id

Returns the specified method.

Response body example:

/methods/?method_id=met1

{
    "data": [
        {
            "id": "564eae383372c3924116b887",
            "id_city": "MTY",
            "id_country": "MX",
            "id_station": null,
            "latitude": null,
            "level": "station",
            "longitude": null,
            "name": "Cerro de la Campana",
            "timezone": "GMT +6"
        }
    ],
    "has_more": false
}

GET /pollutants

Returns all the pollutant values.

Response body example: /pollutants/

{
    "data": [
        {
            "id": "564ea9543372c318b2aee2de",
            "pollutant_average": null,
            "pollutant_id": "CO2",
            "pollutant_unit": "ug",
            "pollutant_update_time": "10/12/2014",
            "pollutant_value": "36",
            "station_id": "Tac"
        },
        {
            "id": "564ea9543372c318b2aee2de",
            "pollutant_average": null,
            "pollutant_id": "CO2",
            "pollutant_unit": "ug",
            "pollutant_update_time": "12/12/2014",
            "pollutant_value": "41",
            "station_id": "Tac"
        }
    ],
    "has_more": false
}

GET /pollutants/:pollutant_id

Returns the specified pollutant values.

Response body example:

/pollutants/?pollutant_id=CO2

{
    "data": [
        {
            "id": "564ea9543372c318b2aee2de",
            "pollutant_average": null,
            "pollutant_id": "CO2",
            "pollutant_unit": "ug",
            "pollutant_update_time": "10/12/2014",
            "pollutant_value": "36",
            "station_id": "Tac"
        }
    ],
    "has_more": false
}

GET /cities-pollutant-timeline/:greographical_zone?dateUnit='day' | 'week' | 'month' | 'year'&now?= '0' | '1'

Returns the specified pollutant values for the geographical zone specified and dateUnited specified. If the now flag is set to 1, returns the last value observed. The geographical zone can be either a Country_id, City_id or a Station_id.

Response body example:

/cities-pollutant-timeline?geographical_zone=MXMEX-ACO&dateUnit=hour

possible date units: hour, day, month, year

{
   "geographical_zone":"MXMEX-ACO",
   "pollutants":[
      {
         "timeline":[
            {
               "value":"65.0",
               "time":"2015-12-15T02"
            },
            {
               "value":"71.0",
               "time":"2015-12-15T04"
            },
            {
               "value":"74.0",
               "time":"2015-12-15T05"
            }
         ],
         "pollutant":"Hum"
      },
      {
         "timeline":[
            {
               "value":"52.8211284514",
               "time":"2015-12-15T02"
            },
            {
               "value":"52.8211284514",
               "time":"2015-12-15T04"
            },
            {
               "value":"54.0216086435",
               "time":"2015-12-15T05"
            }
         ],
         "pollutant":"PM10"
      },
      {
         "timeline":[
            {
               "value":"16.8",
               "time":"2015-12-15T02"
            },
            {
               "value":"15.7",
               "time":"2015-12-15T04"
            },
            {
               "value":"15.1",
               "time":"2015-12-15T05"
            }
         ],
         "pollutant":"Temp"
      }
   ],
   "dateUnit":"hour"
}