openaq / openaq-api-v2

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

Incorrect behavior of "parameter_id" in "v2/latest" endpoint ? #272

Closed kalisio-nicolas closed 9 months ago

kalisio-nicolas commented 9 months ago

Issue Description:

Hello, I am encountering unexpected behavior when using the parameter_id parameter in the v2/latest endpoint. Specifically, I am attempting to filter results for a specific parameter, such as Ozone mass concentration by providing its corresponding identifier, such as 3. However, the endpoint is returning measurements for other parameters, such as pm10 and co which should not be included.

Here is the URL I am using:

https://api.openaq.org/v2/latest?country_id=2&parameter_id=3

Expected Behavior:

Actual Behavior:

With the measurements endpoint, filtering by type works as expected, and in addition, the old parameters country and parameter still function. Especially, with the old parameter, we could include multiple parameters in a single request, such as pm10 and pm25 in one query. However, with the latest endpoint, we can only use parameter_id, which can only accept one variable per request, and it also does not behave as expected. https://api.openaq.org/v2/measurements?location_id=65998&limit=1000&date_from=2023-09-18T00:00:00Z&parameter=pm25&parameter=pm10

Am I missing something ? Or is this a bug ? thanks for your help.

russbiggs commented 9 months ago

@majesticio can you take a look at this?

majesticio commented 9 months ago

@kalisio-nicolas Hello, this is actually expected behavior. When you use parameter_id=3 it will return location objects that contain that parameter, it doesn't reshape the data for you. Likewise, when you call a location by its ID the API will return that location object, the parameter= query params won't reshape the data, but date_from and date_to will get the desired range of measurement objects from that location. Hope this helps!

russbiggs commented 9 months ago

closing since this is expected behavior in v2