openaq / openaq-api-v2

OpenAQ API
https://api.openaq.org
39 stars 9 forks source link

Time window bug for `v2/averages` #329

Open majesticio opened 5 months ago

majesticio commented 5 months ago

It appears that if requesting averages in a time window less than ~4 months the data will return 0 results:

locations_id = 635657

url = f"https://api.openaq.org/v2/averages"

params = {
    "parameters_id": 2,
    "date_from": "2023-05-01",
    "date_to": "2023-09-30",
    "locations_id": locations_id,
    "limit": 1000
}
res = requests.get(url, params=params )
data = res.json()
results = data["results"]
print(data["meta"])

-> {'name': 'openaq-api', 'license': '', 'website': '/', 'page': 1, 'limit': 1000, 'found': 0}

Increasing the time window, for instance to "date_to: "2024-01-01" returns results which also include the original time window.