FCC Weather API icon not showing because icon info in the wrong form in JSON

FCC Weather API icon not showing because icon info in the wrong form in JSON
0

#1

When I attempted to check the data on my location the icon was not showing. This is because there is no url in the place of the icon name when it was snowing. I’m not sure if this is an isolated instance or more widespread so decided to point it out.

/ 20171229142838
// https://fcc-weather-api.glitch.me/api/current?lat=45&lon=-93

{
“coord”: {
“lon”: -93,
“lat”: 45
},
“weather”: [
{
“id”: 721,
“main”: “Haze”,
“description”: “haze”
},
{
“id”: 600,
“main”: “Snow”,
“description”: “light snow”,
“icon”: “13d”
}
],
“base”: “stations”,
“main”: {
“temp”: -16.84,
“pressure”: 1028,
“humidity”: 70,
“temp_min”: -18,
“temp_max”: -16
},
“visibility”: 4023,
“wind”: {
“speed”: 5.7,
“deg”: 330
},
“clouds”: {
“all”: 90
},
“dt”: 1514578800,
“sys”: {
“type”: 1,
“id”: 1573,
“message”: 0.0042,
“country”: “US”,
“sunrise”: 1514555407,
“sunset”: 1514587160
},
“id”: 5039587,
“name”: “North Saint Paul”,
“cod”: 200
}


Weather App API very Laggy
#2

That’s an intentional part of the design and was taken from the old weather API we used to use.

Think about how you can use that code to pull in any icons that suit your design.

A list of all the codes can be found here: https://www.openweathermap.org/weather-conditions

Edit

You can use their icons, of course, but their design is pretty rubbish. Using the code and doing some hunting for other icons you like produces nicer results.

Here’s mine, using some other icons: https://jacksonbates.github.io/fcc-local-weather/


#3

fcc-weather-api isn’t consistent. Sometimes that icon value is a URL. Such as the example provided right on the front page of https://fcc-weather-api.glitch.me/ : https://fcc-weather-api.glitch.me/api/current?lat=35&lon=139

It’s also a URL for my coordinates in Kota Kinabalu, MY : https://fcc-weather-api.glitch.me/api/current?lat=5&lon=116

I know they claim in GitHub posts that the data comes from OpenWeatherMap, but OpenWeatherMap doesn’t have this problem.

I added different locations for major cities to my implementation and that’s when I saw the problem. Note that my implementation uses OpenWeatherMap and requires the user to provide their own API key.


#4

That’s an annoying quirk for the api I hadn’t seen before.

However, at least it’s a consistent quirk. Part of working with 3rd party APIs requires thinking about how to handle edge cases if the API doesnt dekiever exactly what you want each time: programming is problem solving…

Since the icon data is inconsistent, one could base icon choices on the conditions descriptions instead.


#5

“main”: “Haze”

huh, they have so awfully a lot of descriptions though… i have personally set with showing only icons for clouds, rain, thunderstorm, drizzle, snow and clear (this one differs for day and night) making it that it simply doesn’t add html for ico image if the condition is something else like i dunno earthquake, lol, or some haze. i mean i wanted to add more stuff but for instance the aforementioned haze is in the atmosphere group and i had no idea how it would be displayed in json till i saw it in this thread right now, i aimed at weather[0].main because the amount of descriptions for all the weather is just too many


#6

I was struggling with how to change the icons to something outside the original api so the inconsistecy with the api data seemed like a roadblock. Thank you for helping me realize that I could use the descriptions I was using to change the background could also be used to change the icons.