dakboard / Cloud-Platform

Feature requests, enhancements and anything you'd like to see in DAKboard!
https://dakboard.com
168 stars 39 forks source link

Support queries for specific AQI/Weather stations via waqi.info #1954

Closed cocarrig closed 1 year ago

cocarrig commented 1 year ago

Migrating this into an issue.

Please add to the air quality block the ability to enter a station ID manually to query against:

Reveal and hide corresponding fields 'Station ID' or 'Location' in existing format with example text below.

Discussed in https://github.com/dakboard/Cloud-Platform/discussions/1951

Originally posted by **phaseburn** November 7, 2023 Your implementation of the waqi.info API is incomplete. It appears that DAKboard is implementing only a part of the API rather than the full API, and only supporting geolocation lookups by lat/long. The API specifically allows queries to "https://api.waqi.info/feed/" with lat/long args, in which case the API will return city-level data from the nearest city-level station to the provided geolocation parameters. For example, based on the data I've configured into my DAKboard, you would be querying the following URL: https://api.waqi.info/feed/geo:%LAT%;%LONG%/?token=%TOKEN% The API also specifically allows queries to "https://api.waqi.info/feed/" with the station ID, in which case the API will return station-level data from the specified station provided by the station parameter. For example, because my station ID is @123456, you would need to query the following URL: https://api.waqi.info/feed/A123456/?token=%TOKEN% I would suggest the following: Allow the "Location" field to specify either an address to translate into lat/long, or, specifically a station ID (which always begin with the @ symbol). Then translate that field to call the API endpoint with either "geo:%LATLONG%" or "A%STATIONID%" appended to the URL base, based on if the Location field begins with an @ symbol or not. The API will return the data from either a geolocation-searched endpoint or a specific station ID in the same format, so zero change in output handling is required.
Dan-Peck commented 1 year ago

The API documentation appears to be here: https://aqicn.org/json-api/doc/

Note: As it is not mentioned in these API docs, I am unclear where it was mentioned to use "A" in place of the "@" (or its urlencoded version, "%40"), but, the "A" does work, where the others do not. Will utilize that method in the implementation.

Dan-Peck commented 1 year ago

Merged in @ dc32a37 and added to the queue for upcoming release to the live site.