freeCodeCamp Weather API (https://fcc-weather-api.glitch.me) Celsius or Fahrenheit

Hi all

I am using the suggested freeCodeCamp API for the weather app (https://fcc-weather-api.glitch.me).
However, I am not 100% sure in what unit (Celsius or Fahrenheit) the temperature is returned?

Can one determine this from the JSON response?
Or does it change dynamically based on the location?

Thanks!

Couldn’t you just put your own lat and lon in and see what it looks like?

When I put in mine, I get 17.1 degrees. I’m not freezing so it’s not Fahrenheit. And I’m not dead so it can’t be Kelvin or Rankin. I guess that leaves Celsius. :wink:

1 Like

Yes, I am trying something along those lines!

However, my location is in Celsius.
I tested with a US location (San Francisco) and it seems to be also returning in Celsius.
One would assume that the US would be in Fahrenheit.

That is why I just want to make sure.
I would prefer if the API could provide the same unit no matter what the location is.

Thanks!

Yup Indeed, it will return the same unit of measurement regardless of location…thats why San Fran shows the temp in C and not in F like you noticed. And actually, it would not make sense for it to change depending on location because the API is giving you raw data and its up to you to manipulate that information it to display the way that you want… like with the F/C toggle that you need to create for this project.

The API I used was in Kelvin… I was so lost it was unreal cause there was no way it was F or C, but I had no idea what and kept thinking I was pulling the wrong info. I hadnt heard of Kelvin since high school chemistry class LOL once I figured out what it was I was good to go, but I was frustrated for the better half of an afternoon wondering why it was showing me temperatures on Neptune :laughing:

:grinning:
I suppose Kelvin would be a more scientific approach to the problem.

Thanks to everyone!

I have submitted my project using Celsius as the default unit.

I tested with a US location (San Francisco) and it seems to be also returning in Celsius.
One would assume that the US would be in Fahrenheit.

I would expect it to always give the same unit. What if someone from France wanted to get weather for New York? What if someone from St Louis wanted to get the weather in Tokyo?

You can’t just assume that location will dictate what units they want - what if someone from Peru is on vacation in San Francisco?

So if you design an API like this, you have to make a choice. You can choose a set of units to use, and hopefully explain it in the documentation and let the requester convert it however they want Or, you can have the user tell you what units you want and you convert it for them.

To me, the first option is easiest. And the metric system is standard for most of the world so that would be the way to go.

Yes, that makes sense!

SI units are probably the correct way to go.