How do we detect F or C in the data returned in the weather app?

How do we detect F or C in the data returned in the weather app?
0.0 0

#1

I’ve been sitting here writing everything out in my notebook and when looking at the example provided of the JSON data that will be returned I noticed the temperature for that location is 22 degrees… yet it’s light rain rather than snow, which tells me it’s naturally returned as C or F based on the coordinates provided in the request. Is there anything in the data that indicates whether it’s C or F that I can check logically to know which symbol to display and base the logic of my toggle button? I haven’t seen anything that stands out to me showing that. I could make some switch cases or if conditions to work out the logic of 22 degrees of rain rather than snow must mean C, but it can be a “clear sunny day” on a cold 22 degree F day. How can we know this to compensate for it? It would help a lot with toggling the photos we use for the background too.


#2

I assume it’s returning celsius always. Science tends to prefer the metric system.


#3

Some APIs return the default units , I remember a similar question for thedark sky API

For this case however, I’m not sure of the API you are using so can not say. Easy check to see if the API is using static or variable temp units is to manually set the coordinates to the U.S and
see if it returns in Fahrenheit, if so the API probably will also return the default units.


#4

Openweathermap and Dark Sky APIs allows you to include units=*** in the query string.