Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 5: Real-time weather client
Lecture: Weather API overview

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's have a quick look at this real time
0:02 weather API that we're going to be using.
0:04 So, there's a lot of weather API endpoints out on the Internet.
0:08 In fact, one that I think is really cool is "openweathermap.org".
0:11 So if you're going to really try to create a live weather application,
0:14 go use theirs. This one is just for educational purposes,
0:18 has limited data and so on,
0:19 but it will give us the answers generally that we're looking for here.
0:23 So this is a HTTP RESTful
0:26 API. And what that means is we just make HTTP requests, like standard
0:30 web browsers do, and what we get back typically, not always,
0:33 but typically is some kind of formatted data called JSON.
0:37 So, what we can do is we can go over here and say "weather.talk
0:40 python.fm/api/weather"
0:45 and it requires that we pass some things.
0:46 So if we don't pass a city,
0:48 it says "missing field: City" so we could put "Boston", Sorry,
0:53 we could put "city = Boston" like this,
0:56 there we go. And apparently, the weather is mist.
0:59 Some kind of mist rain, I don't know.
1:01 It should be category: rain, description:
1:03 mist. Who knows? Here you can see,
1:04 we're getting the weather. It's right now 13 degrees Celsius because down here somewhere we
1:11 have our units are metric. If we wanted this to be in more US style
1:15 we could say
1:16 "units = imperial". Now all of a sudden
1:19 it's 55°F instead of whatever it was Celsius.
1:23 Okay, So what we do is we make a regular request and we get data
1:27 that looks like this back from it.
1:29 So this is called JSON, and we'll see how to play with it in Python
1:33 really soon. But it's a nice,
1:34 simple format That's very, very natural for us to work with over API.
1:38 And if we come back here,
1:40 you can see that we have a city,
1:41 right? This should have a question mark.
1:43 actually. It says that we have a city equals whatever we want,
1:46 but we can optionally pass a state,
1:49 if you want to disambiguate
1:50 say Portland, Maine, from Portland,
1:52 Oregon. We can pass a country we wanna disambiguate
1:55 Portland, Australia, from Portland,
1:57 USA. If you don't specify a country,
1:59 it defaults to the US, Just that way. I could type in short city names and
2:02 it's still gonna work. Then also you saw we can pass in units as metric,
2:05 imperial or standard, and it defaults to metric.
2:09 So this is the weather API that we're going to be working with.