Hi, in this video, I want to hand you an exercise that you need to solve now.
It's a challenging exercise, but even if you don't solve it, it will be excellent training in terms
of accessing APIs and working with Jason data.
So I will show you two things.
First of all, demonstrate you've expected output.
That's your script should generate.
And then I'll show you the API that you should use for this exercise so that you don't just go out in
the wild and search for APIs.
So I want to help you focus on this exercise.
So let's start with showing you first the expected output.
So I manually created this data dot, text, file and I place you a city comma time, comma temperature,
comma condition.
So please do the same.
This is the first step.
Just creates an empty file and then place the cursor in the next line.
Now, if I go to the bottom of this will run the main data profile where the scripts are.
That's I developed three sides, so I'll not show you the script, but I'll just executed and you'll
see what happens.
So as soon as I execute the script, it populates.
This does not file with Delta.
So these are the dots are they are added under the header.
So I had to place the cursor in here and Python adds the dots on, so it appends the data to this text
file.
For that, we use an open function.
We a flag, not a W flag.
So when we append delta to the X files, that's a clue.
So what is this?
Well, we have data for a city weather forecast data, and I use Aleppo, which is a city in Syria.
It's warm there.
So these are the full data points, which are repeated every three hours.
So we have the city, we have the time and date.
So time is for that.
And then we have degrees Celsius degrees, the temperature and then we have the condition of the sky.
It's over.
Gas clouds.
And this is a repeated every three hours and we have forecasts for the next five days.
So at an interval of three hours.
So we have a temperature.
We have the sky condition and so on.
Now how do we get those dots up?
This is what I explain you next.
So you should go to open weather map.
That's all.
And then go over to the API menu.
And if you scroll down, you'll see we have this five day, three hour forecast.
So you want to go to subscribe.
And then under the free plan, you want to get some API.
And then you want to fill in these data that will give you the API key.
So once you get your API.
Now I want to show you an example of a query to get a three hour weather forecast data for five days.
So this is an example of URL.
And this is the same URL that I'm using inside my Python script.
So we have this main URL up to forecasts question mark queue is equal to where you enter the city so
you can enter any city in here and then you have.
And API is equal to.
And this is your API key until this and symbol.
And then we have and units a sequel to Metric, you can also use FT, but for more information, you
can go back to the API menu page in here and go to the API doc and then you want to scroll down because
this is about getting data for a latitude and longitude.
If you scroll down, you'll see the documentation for getting data based on a city.
Here, built in API request by city name.
And that is the same, you are a format that I'm using that is a format that I show you.
In this example.
So that will give you data for the next five days and then you should store all those data in this text
file.
That's the existence now in the next video, I'll show you my version of the exercise to try to solve
it, because even if you don't solve it, you'll learn something and I'll see you in the next video.