1
00:00:00,510 --> 00:00:05,550
Hi, in this video, I want to hand you an exercise that you need to solve now.

2
00:00:06,030 --> 00:00:12,510
It's a challenging exercise, but even if you don't solve it, it will be excellent training in terms

3
00:00:12,510 --> 00:00:17,160
of accessing APIs and working with Jason data.

4
00:00:18,090 --> 00:00:19,540
So I will show you two things.

5
00:00:19,740 --> 00:00:22,620
First of all, demonstrate you've expected output.

6
00:00:22,980 --> 00:00:25,350
That's your script should generate.

7
00:00:25,950 --> 00:00:32,640
And then I'll show you the API that you should use for this exercise so that you don't just go out in

8
00:00:32,640 --> 00:00:34,890
the wild and search for APIs.

9
00:00:35,550 --> 00:00:38,190
So I want to help you focus on this exercise.

10
00:00:38,430 --> 00:00:42,240
So let's start with showing you first the expected output.

11
00:00:43,680 --> 00:00:53,430
So I manually created this data dot, text, file and I place you a city comma time, comma temperature,

12
00:00:53,430 --> 00:00:54,420
comma condition.

13
00:00:55,080 --> 00:00:56,670
So please do the same.

14
00:00:57,450 --> 00:00:58,470
This is the first step.

15
00:00:58,830 --> 00:01:04,200
Just creates an empty file and then place the cursor in the next line.

16
00:01:04,560 --> 00:01:10,050
Now, if I go to the bottom of this will run the main data profile where the scripts are.

17
00:01:10,060 --> 00:01:16,230
That's I developed three sides, so I'll not show you the script, but I'll just executed and you'll

18
00:01:16,290 --> 00:01:17,250
see what happens.

19
00:01:17,490 --> 00:01:22,200
So as soon as I execute the script, it populates.

20
00:01:23,510 --> 00:01:26,150
This does not file with Delta.

21
00:01:27,170 --> 00:01:31,430
So these are the dots are they are added under the header.

22
00:01:31,790 --> 00:01:39,560
So I had to place the cursor in here and Python adds the dots on, so it appends the data to this text

23
00:01:39,560 --> 00:01:39,950
file.

24
00:01:40,430 --> 00:01:42,410
For that, we use an open function.

25
00:01:42,650 --> 00:01:45,890
We a flag, not a W flag.

26
00:01:46,250 --> 00:01:49,640
So when we append delta to the X files, that's a clue.

27
00:01:50,590 --> 00:01:51,430
So what is this?

28
00:01:51,700 --> 00:02:00,400
Well, we have data for a city weather forecast data, and I use Aleppo, which is a city in Syria.

29
00:02:00,940 --> 00:02:01,870
It's warm there.

30
00:02:02,890 --> 00:02:11,080
So these are the full data points, which are repeated every three hours.

31
00:02:11,260 --> 00:02:14,890
So we have the city, we have the time and date.

32
00:02:15,760 --> 00:02:18,310
So time is for that.

33
00:02:19,420 --> 00:02:27,880
And then we have degrees Celsius degrees, the temperature and then we have the condition of the sky.

34
00:02:28,690 --> 00:02:29,290
It's over.

35
00:02:29,620 --> 00:02:30,790
Gas clouds.

36
00:02:32,110 --> 00:02:39,790
And this is a repeated every three hours and we have forecasts for the next five days.

37
00:02:40,180 --> 00:02:42,850
So at an interval of three hours.

38
00:02:43,840 --> 00:02:44,870
So we have a temperature.

39
00:02:44,890 --> 00:02:47,260
We have the sky condition and so on.

40
00:02:47,950 --> 00:02:50,560
Now how do we get those dots up?

41
00:02:50,590 --> 00:02:52,660
This is what I explain you next.

42
00:02:53,530 --> 00:02:56,570
So you should go to open weather map.

43
00:02:56,610 --> 00:02:57,430
That's all.

44
00:02:57,850 --> 00:03:00,850
And then go over to the API menu.

45
00:03:03,660 --> 00:03:10,350
And if you scroll down, you'll see we have this five day, three hour forecast.

46
00:03:10,860 --> 00:03:12,660
So you want to go to subscribe.

47
00:03:13,680 --> 00:03:17,900
And then under the free plan, you want to get some API.

48
00:03:18,630 --> 00:03:24,240
And then you want to fill in these data that will give you the API key.

49
00:03:25,510 --> 00:03:26,730
So once you get your API.

50
00:03:27,130 --> 00:03:35,620
Now I want to show you an example of a query to get a three hour weather forecast data for five days.

51
00:03:35,920 --> 00:03:38,140
So this is an example of URL.

52
00:03:39,500 --> 00:03:44,150
And this is the same URL that I'm using inside my Python script.

53
00:03:44,990 --> 00:03:55,580
So we have this main URL up to forecasts question mark queue is equal to where you enter the city so

54
00:03:55,580 --> 00:03:59,420
you can enter any city in here and then you have.

55
00:04:00,510 --> 00:04:03,690
And API is equal to.

56
00:04:03,900 --> 00:04:09,570
And this is your API key until this and symbol.

57
00:04:10,720 --> 00:04:19,360
And then we have and units a sequel to Metric, you can also use FT, but for more information, you

58
00:04:19,360 --> 00:04:30,160
can go back to the API menu page in here and go to the API doc and then you want to scroll down because

59
00:04:30,370 --> 00:04:33,870
this is about getting data for a latitude and longitude.

60
00:04:33,910 --> 00:04:41,830
If you scroll down, you'll see the documentation for getting data based on a city.

61
00:04:46,020 --> 00:04:48,930
Here, built in API request by city name.

62
00:04:49,110 --> 00:04:54,240
And that is the same, you are a format that I'm using that is a format that I show you.

63
00:04:54,870 --> 00:04:55,890
In this example.

64
00:04:57,090 --> 00:05:05,010
So that will give you data for the next five days and then you should store all those data in this text

65
00:05:05,100 --> 00:05:05,490
file.

66
00:05:07,130 --> 00:05:13,100
That's the existence now in the next video, I'll show you my version of the exercise to try to solve

67
00:05:13,100 --> 00:05:18,380
it, because even if you don't solve it, you'll learn something and I'll see you in the next video.

