1 00:00:00,640 --> 00:00:05,670 So or at a place where we have our search term in here and it's really time to go ahead and make an 2 00:00:05,670 --> 00:00:11,670 API request so let's do a little bit of investigation on the API that we're going to use to fetch this 3 00:00:11,670 --> 00:00:14,280 weather data in my browser. 4 00:00:14,280 --> 00:00:26,280 I'm going to open up a new tab and I'm going to navigate to open weather map dot org slash forecast 5 00:00:26,620 --> 00:00:32,350 five or so open weather maps or forecast five. 6 00:00:33,660 --> 00:00:40,860 If you can't find it that way you can also just search for open weather map forecast API and it's probably 7 00:00:40,860 --> 00:00:45,250 going to be one of the first results up on here. 8 00:00:46,380 --> 00:00:47,060 OK. 9 00:00:47,250 --> 00:00:49,640 So this is what we're looking for. 10 00:00:49,710 --> 00:00:57,510 This is a API that we can use to grab forecasts and weather data in the next five days for a particular 11 00:00:57,510 --> 00:00:58,140 city. 12 00:00:58,170 --> 00:01:01,010 Basically exactly what we want here. 13 00:01:01,080 --> 00:01:05,050 So this is a free API while we do have to sign up for it. 14 00:01:05,070 --> 00:01:11,070 It is completely free and we do have to sign up for it to get a actual API so we can make a request 15 00:01:11,070 --> 00:01:13,580 to the server here. 16 00:01:14,730 --> 00:01:19,590 This endpoint right here this by city name is in point that we're going to end up using. 17 00:01:19,620 --> 00:01:27,960 So you can see here me dial up the font size a little eyes and big you can see the general format of 18 00:01:27,960 --> 00:01:30,170 the requests that we need to make. 19 00:01:30,300 --> 00:01:36,870 We're going to make a request to API open weather mapped out or data 2.5 forecast and then we've got 20 00:01:36,930 --> 00:01:42,660 our query string here which is everything after the question mark and the part that we really need to 21 00:01:42,660 --> 00:01:44,550 supply here is. 22 00:01:44,560 --> 00:01:45,570 Q equals. 23 00:01:45,570 --> 00:01:53,160 Which basically means queery is the city name Khama country code. 24 00:01:53,190 --> 00:01:55,650 So pretty straightforward pretty you know simple endpoint here. 25 00:01:55,650 --> 00:02:00,240 We really just got to hit this address right here with a particular city name. 26 00:02:00,270 --> 00:02:04,350 And we should get the weather data that we really care about. 27 00:02:04,410 --> 00:02:07,690 They've got a sample request right here that we can click on. 28 00:02:07,950 --> 00:02:11,320 I'm going to do that and you can see that it's a forecast for London. 29 00:02:11,490 --> 00:02:19,740 But in the U.S. So not London in the U.K. for I have no idea why they did this. 30 00:02:19,740 --> 00:02:23,170 It's like London in Texas or something like that something weird. 31 00:02:23,170 --> 00:02:26,370 Anyways it's going to click that link open up and a new tab. 32 00:02:26,640 --> 00:02:30,220 You'll notice that this is SML. 33 00:02:30,660 --> 00:02:31,930 We're not going to work with SML. 34 00:02:31,950 --> 00:02:34,660 We're gonna end up working with Jaison. 35 00:02:34,980 --> 00:02:38,200 So the response that we get back is going to look a lot more like this. 36 00:02:38,250 --> 00:02:42,700 You can view the Jaison if you want by just deleting that SML part and then you are l. 37 00:02:42,870 --> 00:02:47,280 But if you don't have a URL for or excuse me a Jaison formatter is probably going to end up a little 38 00:02:47,280 --> 00:02:48,250 bit ugly here. 39 00:02:48,420 --> 00:02:53,190 So if yours is showing up ugly you might want to go back to just looking at the Exham else. 40 00:02:53,190 --> 00:02:56,580 Right now we're just going to look at this response for a little bit. 41 00:02:56,580 --> 00:03:01,300 So you know if you want to just check out my screen here and no problem whatsoever. 42 00:03:01,320 --> 00:03:01,810 All right. 43 00:03:01,920 --> 00:03:09,510 So again this is the response for a query for the City of London which again I'm telling you I'm pretty 44 00:03:09,510 --> 00:03:13,410 sure it's in Texas not not in the UK. 45 00:03:13,980 --> 00:03:18,320 Anyways let's check out the response here at the very top level. 46 00:03:18,330 --> 00:03:25,050 We have a city object and the city returns the name of the city that we just search for. 47 00:03:25,050 --> 00:03:29,880 So this is actually really important right here because we might have a user's search for some city 48 00:03:29,880 --> 00:03:33,190 that doesn't exist or they might misspell it in some fashion. 49 00:03:33,270 --> 00:03:37,890 And so it's actually really important to make sure that we get back from the server a confirmation of 50 00:03:38,100 --> 00:03:42,010 you know hey I think you meant London is is this actually what you meant. 51 00:03:42,030 --> 00:03:42,610 Right. 52 00:03:42,840 --> 00:03:44,850 Maybe we left off an oh. 53 00:03:45,110 --> 00:03:50,340 Or is this me an and on at the end so I'm going to delete that and let's see what happens now. 54 00:03:50,340 --> 00:03:54,360 So we still got London so it's pretty darn intelligent the searching here which is going to be very 55 00:03:54,360 --> 00:03:56,400 nice for us. 56 00:03:56,400 --> 00:04:01,800 So anyway as the very top level we have the city object which gives us the name and also gives us some 57 00:04:01,800 --> 00:04:06,840 coordinates the longitude and latitude and this is pretty important we'll come back to these coordinates 58 00:04:06,840 --> 00:04:14,070 later on in the course next if we scroll down just a little bit here we get this list object and the 59 00:04:14,070 --> 00:04:17,650 list is an array of objects. 60 00:04:17,670 --> 00:04:24,780 So you can see if I hover over this right here we've got just about from up here to down here is a single 61 00:04:24,780 --> 00:04:27,180 entry in that array. 62 00:04:27,480 --> 00:04:31,470 And in this array there are many many many many such objects totally identical. 63 00:04:31,710 --> 00:04:36,250 So what these objects are are they are snapshots of weather data. 64 00:04:36,480 --> 00:04:38,420 Three hours at a time. 65 00:04:38,540 --> 00:04:40,590 So you'll see this. 66 00:04:40,930 --> 00:04:42,800 This is time stamped right here. 67 00:04:42,990 --> 00:04:53,850 So for 2016 January 3rd at 0 0 0 the weather in London is expected to be 271 degrees and that's Kelvin 68 00:04:53,940 --> 00:04:56,320 not you know Fahrenheit or Celsius. 69 00:04:56,580 --> 00:05:03,150 If you don't if you're not familiar with Kelvin it's just a different unit for temperature. 70 00:05:03,650 --> 00:05:08,860 You know you can google how to convert from Kelvin to Celsius or Fahrenheit if you like. 71 00:05:08,870 --> 00:05:16,590 Anyways the temperature at you know basically midnight right here is going to be 200 71 degrees and 72 00:05:16,590 --> 00:05:19,300 then three hours later. 73 00:05:19,320 --> 00:05:27,070 So you can see 1 0 3 at 3 a.m. The temperature's going to be 268. 74 00:05:27,270 --> 00:05:33,390 And then at 6:00 a.m. It's going to be 267 and so on and so on and so on five days worth of that data 75 00:05:33,390 --> 00:05:35,310 . 76 00:05:35,640 --> 00:05:42,370 So this list right here is really the prime unit you know the data that we really care about for a search 77 00:05:42,390 --> 00:05:50,990 that we get back we really care about what the temperature the humidity and the pressure are in all 78 00:05:51,030 --> 00:05:56,180 those three properties sit inside of this main object. 79 00:05:56,190 --> 00:05:56,570 OK. 80 00:05:56,610 --> 00:06:00,120 So we've got kind of a better idea of what's going on with this response here. 81 00:06:00,120 --> 00:06:04,740 We'll come back to the response in the future and talk a lot more about how we're going to pluck out 82 00:06:05,190 --> 00:06:07,800 all the different little pieces of data in here that we need. 83 00:06:07,830 --> 00:06:10,290 So I'm not going to close this response just yet. 84 00:06:10,320 --> 00:06:14,940 You know I'm going to keep it open a little bit so we can reference it again in the future. 85 00:06:15,600 --> 00:06:15,900 OK. 86 00:06:15,900 --> 00:06:18,160 So that's pretty much the end point that we're going to use. 87 00:06:18,240 --> 00:06:24,180 Now we have to do is sign up for it just so we can get our API. 88 00:06:24,930 --> 00:06:30,490 If you notice in the response over here the documentation doesn't actually stated very clearly. 89 00:06:30,540 --> 00:06:36,870 But it did include a app I.D. right here which is basically are the API key that we're going to need 90 00:06:36,870 --> 00:06:37,770 . 91 00:06:37,860 --> 00:06:40,040 This is a public key right here. 92 00:06:40,050 --> 00:06:42,860 You know if you want to play it risky you could try using this key. 93 00:06:42,870 --> 00:06:48,050 But really I recommend you sign up for your own account and get your own API key. 94 00:06:48,810 --> 00:06:50,080 So let's do that now. 95 00:06:50,460 --> 00:06:52,040 Back to the documentation. 96 00:06:52,080 --> 00:06:53,930 I'm going to click on sign up 97 00:06:57,840 --> 00:07:02,610 and then I'm going to just put in the User Name of you know I don't ascribe or own five 98 00:07:06,520 --> 00:07:07,200 my e-mail 99 00:07:12,230 --> 00:07:13,050 and then a password 100 00:07:16,770 --> 00:07:24,900 and then right away I get dumped at a kind of like an Account settings page and it says you've sign 101 00:07:24,900 --> 00:07:25,890 it successfully. 102 00:07:25,890 --> 00:07:26,890 Fantastic. 103 00:07:27,210 --> 00:07:31,040 And if I scroll down to a little bit here you'll see that right here on this page. 104 00:07:31,140 --> 00:07:33,570 They really know what we really care about right. 105 00:07:33,570 --> 00:07:35,200 We just care about the API key. 106 00:07:35,460 --> 00:07:39,710 So you can double click the key right here and then copy it. 107 00:07:40,710 --> 00:07:44,730 And we're going to save this key right away so we don't lose it. 108 00:07:44,770 --> 00:07:46,900 I'm going go back over to my code editor. 109 00:07:47,270 --> 00:07:56,460 I'm going to open the actions folder click on index us and we're going to save this key as Konst API 110 00:07:56,520 --> 00:07:57,930 underscore key. 111 00:07:58,560 --> 00:08:03,200 And then inside of a string we'll paste our key semi-colon. 112 00:08:03,850 --> 00:08:04,990 Ok cool. 113 00:08:05,010 --> 00:08:09,760 So this is the API key that we're going to make use of when we make the actual request. 114 00:08:09,780 --> 00:08:12,720 Let's go ahead and continue in the next section.