OpenWeatherMap API Tutorial 2021

Поделиться
HTML-код
  • Опубликовано: 2 дек 2024
  • This video explains how you can use the OpenWeatherMap API and geolocation to create embedded weather data on your webpages for any location using the One Call API.
    The different APIs available through Open Weather Map APIs are also discussed.
    Code from video: gist.github.co...
    Bootstrap Framework Cards reference: getbootstrap.c...
    OpenWeatherMap API Plans: openweathermap...
    OpenWeatherMap One-Call reference: openweathermap...
    OpenWeatherMap Icon reference: openweathermap...

Комментарии • 59

  • @soniablanche5672
    @soniablanche5672 2 года назад +2

    I actually use that api to get city longitude/latitude, since I was too lazy to find a database, I used this API to fill the database automatically whenever we need the longitude/latitude of a city

  • @pompom.potayto
    @pompom.potayto 2 года назад +1

    gave me an idea to solve an issue with displaying the icons! thank you, great job!

  • @kllokoq
    @kllokoq 3 года назад +3

    This is great! Wow, I didn't know that we can limit the number of elements map returns! I needed it so many times. This is effectively like using break in a for loop! I think last time when I used this API, about 9 months ago, the free option did not have all this data. This is fantastic, I can now attempt a lot more complex weather app, perhaps this time using React, just for practice.

  • @visualbree
    @visualbree Год назад

    I haven't implemented this but i wanna thank you in advance. I'm bagging this degree no matter what!.

  • @rinatvaliullov3247
    @rinatvaliullov3247 2 года назад

    Thanks! Your video helped me a lot to understand how to work effectively with the OpenWeather API .

  • @koppix24
    @koppix24 Год назад +2

    Dear Steve, thank you for this video and providing such a well coded and explained example for a small html5 application. Knowledge transfer can be so easy and smart. I give you 5 of 5 stars! *****

  • @dkevin1553
    @dkevin1553 3 года назад +2

    Again a Wonderful Video from Steve. Kudos to your effort 👏👏👏

  • @jimlanpheer5281
    @jimlanpheer5281 2 года назад

    Great video and well-explained as always Steve! Thank you very much, i've learned a good deal from a few of your tutorials. Cheers!

  • @jimsteffes6826
    @jimsteffes6826 2 года назад

    Perfect! Just what I needed--short and to the point.

  • @Rainstorm121
    @Rainstorm121 Год назад

    Dear Sir, thanks for this.
    Do you recommend API for the weather forecaster on duty at a national weather office especially when answering calls to give a particular caller answers? How about information about a weather forecast, would that possible with API?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +1

      It's an excellent API for weather data.
      I don't know the specifics of that job or what data it needs so I can't comment about that.
      It depends on what information you want about a weather forecast. I would recommend reading the guide and faq on the website for more information - openweathermap.org/guide

    • @Rainstorm121
      @Rainstorm121 Год назад +1

      @@SteveGriffith-Prof3ssorSt3v3 Thanks

  • @hdm_vision
    @hdm_vision Год назад

    in the current => weather , i got morethan 1 weather, which one is the current weather?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад

      It is an array because there can be multiple things happening in the same area. Each type of current weather has a different icon and label.

  • @alkdsjfadsf
    @alkdsjfadsf 2 года назад

    I got error:
    Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
    at Object.init (index.html:20:7)
    at index.html:112:5

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад +1

      Whenever you see the error message "cannot read properties of null" look on the line where the error occurred at the keyword the browser was "reading". It means what ever was in front of the keyword is null.
      So, you are trying to access a variable or property that has not been declared or assigned yet. Maybe you are trying to access it before the page has finished loading / or before DOMContentLoaded. Maybe you are loading the script without defer or async and trying to run it before the page is ready.

    • @alkdsjfadsf
      @alkdsjfadsf 2 года назад +1

      @@SteveGriffith-Prof3ssorSt3v3 All fixed, thanks a lot!

  • @mahbubhasanrafi139
    @mahbubhasanrafi139 2 года назад

    Hey steve. I hope you are doing well. I am facing a problem. I want to show the timezone or you can say the city name. but it is not showing in the html template. I am using this into the return code that you have written ${timezone}. but not working. can you kindly give me a solution that how can I show the city name.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад

      It all depends on what you are putting into your variable timezone. Timezone is in a different part of the data that is returned. It is not inside "daily".

  • @ibugilang2748
    @ibugilang2748 2 года назад

    thanks sir, for the tutorial,
    Does openweather's review provide the Rainfall and Forecast values, for the territory of Indonesia... I want to make a WebGIS for Rainfall Distribution Map

  • @coryu.1022
    @coryu.1022 2 года назад

    Cant get it working due to the .js file button listener on line 5 (supposedly). I get an error in the console when I load the page saying Cannot read properties of null (reading 'addEventListener') citing app.js:5:5. I tried swapping out various values and api keys and variable syntax and concatenating methods, always the same error =(
    Watched every minute of the video too. Don't know what I'm missing but it's obviously a 'me' thing. Very nice looking ap. I just wish I could get it working.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад

      Are you loading the script and trying to add the event listener before the DOM is loaded? The error about null is telling you that it doesn't have a reference in the thing that is in front of addEventListener.

    • @coryu.1022
      @coryu.1022 2 года назад

      @@SteveGriffith-Prof3ssorSt3v3 I don't remember but I copy pasted verbatim from your git files while trying to fix - still got the same error

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад

      @@coryu.1022 are you running the page over not file:///

  • @neurosp
    @neurosp Год назад

    It gives an 401 error when I use onecall , but it works with weather and forecast

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +1

      401 means unauthorized. It means that your api key is not allowed to use onecall.
      Not sure which APIs are paid and which are free currently.

  • @xandertem
    @xandertem 2 года назад

    Hi Steve, thank you for your helpful tutorial.
    Question: in fetchWeather(), why do you use a promise chain and not the async/await method with a try/catch?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад +2

      I prefer the promise chain syntax.
      I like to be able to pass functions that are declared and used elsewhere into the then( ) methods, like this:
      fetch(url)
      .then(validate)
      .then(parseData)
      .then(buildHTML)
      .then(messageUser)
      .catch(console.warn);

    • @xandertem
      @xandertem 2 года назад +1

      @@SteveGriffith-Prof3ssorSt3v3 Got it. Thank you 🙏

  • @Omhange
    @Omhange 2 года назад

    can we retrieve historical or past weather data?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад

      As long as you pay for the right licence you can

    • @Omhange
      @Omhange 2 года назад

      @@SteveGriffith-Prof3ssorSt3v3 how to do that do you have any tutorial how to get past history weather data?

  • @zuhairtaha34
    @zuhairtaha34 3 года назад

    Can you please explain FinalizationRegistry and WeakRef

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 года назад

      Please add any tutorial requests in the comments here - ruclips.net/video/LCezax2uN3c/видео.html

  • @golddiamondbrgames4304
    @golddiamondbrgames4304 2 года назад

    Congratulations, great video, very well explained.
    I have a question, how could I do a direct search by city name instead of longitude and latitude?

  • @clentargerototing2792
    @clentargerototing2792 2 года назад

    Great Work Sir,
    Is there a way to automate the fetching base on the condition of the code?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад +1

      Sorry. I don't understand your question.

    • @clentargerototing2792
      @clentargerototing2792 2 года назад

      @@SteveGriffith-Prof3ssorSt3v3 sorry about that, thanks for the fast reply. I mean I want to use weather API for our capstone project, we need to get weather forecast from a weather API then we need to send the weather forecast, the problem is that we need to send the weather forecast for 15 different places at the same time, is there a way for me to automate the sending process to 15 different places?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  2 года назад +1

      @@clentargerototing2792 it would be 15 separate calls but you can wrap them all in a Promise.all call

    • @clentargerototing2792
      @clentargerototing2792 2 года назад +1

      @@SteveGriffith-Prof3ssorSt3v3 thanks so much

  • @rufaro003
    @rufaro003 3 года назад

    awesome video. is there a chance to get a different video using async and await?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 года назад

      The video is about the API. I won't be making a different version or multiple versions of the code. It can be written many different ways.
      I have a video on using async and await with fetch if you want to do that for yourself. ruclips.net/video/ycJOZp_wWak/видео.html

  • @HassnainAli
    @HassnainAli Год назад

    Hey Steve! I have used the code you have provided but it was giving me a 401 error so I replaced the one call api with the weather api so it's no longer giving me that error, but now it throws an error which says "caught (in promise) TypeError: Cannot read properties of undefined (reading 'map')
    at Object.showWeather (where-is-the-pub-crawl:1033:8)
    at where-is-the-pub-crawl:1004:13s"
    Can you please help me what I need to do to get rid of this error. Great Job you are making authentic content that's helping us newbies!

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад

      Yeah they changed the free version features after I made this video. So, you have to change which end points you use for free, which you already figured out. The different end points will have different properties. So, you have to call the map method on the right property. I would suggest that you just console out the response and look to see which property is the array. You can only call map on an Array.

  • @cristiandanielherrera4349
    @cristiandanielherrera4349 2 года назад

    Nice!

  • @DenysIvanov-z7c
    @DenysIvanov-z7c 2 года назад

    Thanks!!!

  • @AM-jw1lo
    @AM-jw1lo 2 года назад

    I hope by now you have gotten a mic that does not transmit all your keystrokes, very annoying.

  • @yasmeinSalem44
    @yasmeinSalem44 Год назад

    they changed their pricing, and what you can access in the free plan

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  Год назад +1

      they still have quite a bit you can use - current weather and 5 day forecast.

    • @yasmeinSalem44
      @yasmeinSalem44 Год назад +1

      @@SteveGriffith-Prof3ssorSt3v3 yes, thank you for the explaination

  • @ibugilang2748
    @ibugilang2748 2 года назад

    thanks sir, for the tutorial, Does openweather's review provide the Rainfall and Forecast values, for the territory of Indonesia... I want to make a WebGIS for Rainfall Distribution Map