Are there Any Free Weather APIs? Instead of the Static One Provided by Free Code Camp?

Hi folks! How are yall? Are there any free weather APIs that one can use instead of the one that Free Code Camp provides that only displays a static weather result per Shunzeji?? Thanks for the help in advance!

This is my weather app here:
I’m tired of seeing my web app with this static weather result!

You are seeing those static results, because you hard coded Japan longitude and latitude coordinates.

As far as your first call (see below), what are you expecting to get with this call? Nothing in the API instructions say anything about adding /json/ on the end of the API call.

In fact it tells you to specify and longitude and latitude. You need to figure out how to supply it one for the user’s current location.

1 Like

Oh wow! Aha! Thanks for that tidbit! Back to the drawing board I go!

you can use the government weather api …
here is a bare bones use of it.
Weather Pen

1 Like

@Xiija, it gets the temperature wrong though…it’s like 30 degrees off haha

@RandellDawson, I want that wherevever a person is, the weather automatically adjusts for that location, similar to my smartphone.

How can I integrate this into my code to get an entire information readout…city, windspeed, etc…?

if ("geolocation" in navigator) {
  // check if geolocation is supported/enabled on current browser
   function success(position) {
     // for when getting location is a success
     console.log('latitude', position.coords.latitude, 
                 'longitude', position.coords.longitude);
  function error(error_message) {
    // for when getting location results in an error
    console.error('An error has occured while retrieving
                  location', error_message)
} else {
  // geolocation is not supported
  // get your location some other way
  console.log('geolocation is not enabled on this browser')


Inside the above function you can make a call to a weather API which lets you pass latitude and longitude coordinates and retrieve various weather information.

The example shown on the site shows you the syntax of the url. Then you could use $.getJSON with that url and get any info that the API provides.

@RandellDawson thanks man!