Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on choice of API #1

Open
ooohfascinating opened this issue Jun 24, 2024 · 2 comments
Open

Question on choice of API #1

ooohfascinating opened this issue Jun 24, 2024 · 2 comments

Comments

@ooohfascinating
Copy link

ooohfascinating commented Jun 24, 2024

Why not use, https://aviationweather.gov/cgi-bin/data/metar.php?ids=${AirPortlocation}&format=json
Free api for METARS no need for a api key

this is possible with a slight change to the Update method:

update() {
Log.info(this.data.name + ": Fetching new METARs (" + this.config.airports.join(", ") + ")")
this.config.airports.forEach((airport)=> {
var updated = false;
Log.info(this.data.name + ": Fetching " + airport)
this.fetchData(https://aviationweather.gov/cgi-bin/data/metar.php?ids=${airport}&format=json)
.then((data) => {

                if(data[0].rawOb !== this.metars[airport]) {
                    this.metars[airport] = data[0].rawOb;
                    updated = true
                }
                //this.updateDom(300);
            })
            .catch((request) => {
                Log.error(this.data.name + ": unable to load:", request);
            })
            .finally(() => {
                if(updated) {
                    this.updateDom(300);
                }
            });
    });
    this.scheduleUpdate();
},

and the fetchData Method:
async fetchData(url) {
return performWebRequest(url,type = "json",true);
}

Feel free to tell me off, just curious

@calonmerc
Copy link
Owner

Apologies for not seeing this and responding earlier, @ooohfascinating ! Apparently I don't have notifications enabled on my Github.

The primary reason for API choice is that the aviationweather.gov source randomly changes with no notice to users. (In 10 years of trying to use it for random small projects like this, it's changed/broken at least 20 times). Additionally, and the primary benefit, is avwx.rest can get international airports. The .gov source may be able to get intl, nowadays, but I just tend to not trust it long-term and don't want to be messing with code on fun little projects like this all the time!

@calonmerc calonmerc reopened this Sep 4, 2024
@ooohfascinating
Copy link
Author

Understandable! I appreciate the response! Sorry for my opening. Closing. Reoping. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants