Regarding the showing weather data using Weatherbit api

Can someone please share the code for how to get the weather description from the api

Hi @ansh_10 Our team is looking into this. You may expect a reply soon.


Kindly refer to this python code:

import requests

url = ""

headers = {}

response = requests.request("GET", url, headers=headers, data=payload)


Replace your API key in the placeholder.

Kindly follow this documentation for further details Weatherbit | Current Weather API Documentation

function show_temp()
    city = document.getElementById("city").value

    httpRequest = new XMLHttpRequest();
    url = ""+city+"&key=0fa8c8977a384bb7afe54310cfeee21d""GET", url)

    httpRequest.onreadystatechange = function(){
        if(this.readyState == 4 && this.status == 200)
            user_data = JSON.parse(this.responseText);
            document.getElementById("temp").innerHTML =[0].temp;
            document.getElementById("description").innerHTML =[0].weather.description
            document.getElementById("humidity").innerHTML =[0].rh;
            document.getElementById("wind").innerHTML =[0].wind_spd;
            document.getElementById("obv_time").innerHTML =[0].ob_time;
            document.getElementById("name").innerHTML = city
This is my code, can you tell me how to embed that snippet in this code?


Your code seems correct. You don’t need to embed my python script into your JS code. You have done correctly.

Are you able to get weather description?

1 Like

Yaa, I am able to get the description now but before the description area always showed undefined.

1 Like