CodeForAfrica / sensors.AFRICA-api

The sensors.AFRICA API receiving, storing, and processing data received from sensors across the continentent. Accessible at https://api.sensors.africa/
https://api.sensors.africa/
18 stars 7 forks source link

Data for all cities #23

Closed karimkawambwa closed 5 years ago

karimkawambwa commented 5 years ago

Description

Changed format for retrieved data.

GET /air/data/ (has 1 value_type dict object 24 hour average):

{
    'next': None,
    'previous': None,
    'count': 2,
    'results': [{
        'city_slug': 'dar-es-salaam',
        'P1': {
            'average': 0.0,
            'minimum': 0.0,
            'maximum': 0.0,
            'start_datetime': '2019-02-18T17:00:00Z',
            'end_datetime': '2019-02-18T17:00:00Z'
        },
        'P2': {
            'average': 2.75,
            'minimum': 0.0,
            'maximum': 8.0,
            'start_datetime': '2019-02-18T14:00:00Z',
            'end_datetime': '2019-02-18T17:00:00Z'
        }
    },{
        'city_slug': 'nairobi',
        'P1': {
            'average': 0.0,
            'minimum': 0.0,
            'maximum': 0.0,
            'start_datetime': '2019-02-18T17:00:00Z',
            'end_datetime': '2019-02-18T17:00:00Z'
        },
        'P2': {
            'average': 2.75,
            'minimum': 0.0,
            'maximum': 8.0,
            'start_datetime': '2019-02-18T14:00:00Z',
            'end_datetime': '2019-02-18T17:00:00Z'
        }
    }]
}

GET /air/data/dar-es-salaam (has 1 value_type object 24 hour average):

{
    'next': None,
    'previous': None,
    'count': 1,
    'results': {
        'city_slug': 'dar-es-salaam',
        'P1': {
            'average': 0.0,
            'minimum': 0.0,
            'maximum': 0.0,
            'start_datetime': '2019-02-18T17:00:00Z',
            'end_datetime': '2019-02-18T17:00:00Z'
        },
        'P2': {
            'average': 2.75,
            'minimum': 0.0,
            'maximum': 8.0,
            'start_datetime': '2019-02-18T14:00:00Z',
            'end_datetime': '2019-02-18T17:00:00Z'
        }
    }
}

GET /air/data/dar-es-salaam?from=<>&to=<> (has multiple value_type objects for each day average):

{
    'next': None,
    'previous': None,
    'count': 1,
    'results': {
        'city_slug': 'dar-es-salaam',
        'P1': [{
            'average': 0.0,
            'minimum': 0.0,
            'maximum': 0.0,
            'start_datetime': '2019-02-18T17:00:00Z',
            'end_datetime': '2019-02-18T17:00:00Z'
        }],
        'P2': [{
            'average': 2.75,
            'minimum': 0.0,
            'maximum': 8.0,
            'start_datetime': '2019-02-18T14:00:00Z',
            'end_datetime': '2019-02-18T17:00:00Z'
        }, {
            'average': 1.5,
            'minimum': 1.0,
            'maximum': 2.0,
            'start_datetime': '2019-02-16T17:00:00Z',
            'end_datetime': '2019-02-16T17:00:00Z'
        }]
    }
}

Added GET /cities:

http://staging.api.sensors.africa/v2/cities/

[
    {
        "latitude": "-6.79240000000",
        "longitude": "39.20830000000",
        "slug": "dar-es-salaam",
        "name": "Dar es Salaam",
        "country": "Tanzania",
        "label": "Dar es Salaam, Tanzania",
        "map_link": "https://map.aq.sensors.africa/#12/-6.79240000000/39.20830000000"
    },
    {
        "latitude": "-1.29210000000",
        "longitude": "36.82190000000",
        "slug": "nairobi",
        "name": "Nairobi",
        "country": "Kenya",
        "label": "Nairobi, Kenya",
        "map_link": "https://map.aq.sensors.africa/#12/-1.29210000000/36.82190000000"
    },
    {
        "latitude": "6.52440000000",
        "longitude": "3.37920000000",
        "slug": "lagos",
        "name": "Lagos",
        "country": "Nigeria",
        "label": "Lagos, Nigeria",
        "map_link": "https://map.aq.sensors.africa/#12/6.52440000000/3.37920000000"
    }
]

Type of change

Please delete options that are not relevant.

Checklist:

cc @kilemensi @nerdlet