mstdmstd's avatar

How to get UV index value from openweathermap api ?

Checking docs on current weather on https://openweathermap.org/current#name

I need to get high levels of precipitation and high UV index values I found precipitation data with description :

precipitation precipitation.value Precipitation, mm. Please note that only mm as units of measurement are > available for this parameter. precipitation.mode Possible values are 'no", name of weather phenomena as 'rain', 'snow'

and

rain 1h(where available)Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter snow 1h(where available) Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter

But I did not found anything like "UV index"

Do you know what is it ? Maybe I need other services to get these data ?

0 likes
6 replies
mstdmstd's avatar

@Rebwar Thanks!

Running the request like :

$s = 'https://api.openweathermap.org/data/2.5/weather?q=' . $location . '&appid=' . $openWeatherMapKey . '&units=metric';

I got data :

353d1af15c8cadf26c8305ee3359ef7b"{"coord":{"lon":-0.1257,"lat":51.5085},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"base":"stations","main":{"temp":6.47,"feels_like":3.6,"temp_min":5.59,"temp_max":7.3,"pressure":1024,"humidity":78,"sea_level":1024,"grnd_level":1019},"visibility":10000,"wind":{"speed":4.12,"deg":280},"rain":{"1h":0.4},"clouds":{"all":91},"dt":1734965441,"sys":{"type":2,"id":2075535,"country":"GB","sunrise":1734941093,"sunset":1734969269},"timezone":0,"id":2643743,"name":"London","cod":200}"

for "London"

I see key

"main":"Rain"

but nothing like "precipitation" or "UV index" - but I see them in response description.

If I have to add some keys for my request to get these values ? I did not find which keys ?

maxxd's avatar

You're still calling to version 2.5 in your URL. Change it to 3.0.

1 like
mstdmstd's avatar

I generated new 3 call key and got next results:

But I did not find any "precipitation", but found "humidity" - seems that is not the same ? or "UV index" data.

mstdmstd's avatar

I managed to read data from one call 3 and I asked at https://openweathermap.org/support-centre :

Retrieving data with one call 3 I wonder

  1. wich level of precipitation is considered as dangerous ? But actually I do not see “precipitation” key in “current” data I retrieve
  2. wich level of UV index(I suppose that “uvi” index in “current” data I retrieve) is considered as dangerous ?

And the answer of the bot :

The OpenWeather One Call API 3.0 does not directly specify which level of precipitation is considered dangerous within the documentation provided. Since the "precipitation" key is not explicitly mentioned in the "current" data section of the One Call API 3.0 documentation, it might not be directly available or might be included under different conditions or parameters. For assessing dangerous levels of precipitation, it typically depends on the context, such as the rate of precipitation over time and the specific conditions of an area (e.g., prone to flooding). It's advisable to consult local weather advisories for specific thresholds of dangerous precipitation levels.

Regarding the UV index ("uvi" in the "current" data), the UV Index scale recommended by the World Health Organization is as follows:

Low: 0 to 2 Moderate: 3 to 5 High: 6 to 7 Very High: 8 to 10 Extreme: 11+ A UV index of 6 or above is generally considered "high" and can be dangerous, especially without proper skin protection. Prolonged exposure during times when the UV index is 6 or higher can increase the risk of skin damage and other harmful effects. It's recommended to take protective measures such as wearing sunscreen, sunglasses, and protective clothing when the UV index reaches high levels.

For more information on how to interpret the UV index and take appropriate precautions, it's advisable to refer to health or meteorological organizations' guidelines.

For more detailed information and to access the full documentation, please visit: this link

With request I got next data :

stdClass Object
(
    [dt] => 1735127066
    [sunrise] => 1735113933
    [sunset] => 1735142145
    [temp] => 282.26
    [feels_like] => 280.26
    [pressure] => 1033
    [humidity] => 92
    [dew_point] => 281.03
    [uvi] => 0.58
    [clouds] => 100
    [visibility] => 10000
    [wind_speed] => 3.6
    [wind_deg] => 250
    [weather] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 804
                    [main] => Clouds
                    [description] => overcast clouds
                    [icon] => 04d
                )

        )

)

I have “uvi” key with value and no “precipitation”/“rain” keys. From the bot answer that is not clear in which cases these keys “precipitation”/“rain” are in returned data.

I am tryin to google “Weather 25 december high precipitation” - trying to find a city with high precipitation - but no success yet.

A lot of links to my city : https://prnt.sc/1EdrQmCKHnNV

Any hints how to find a city with high precipitation in a world? Then I would use in one call 3 request...

Please or to participate in this conversation.