Welcome back and this video, we are going to check out the open weather map API before we get started
with the project itself.
So the idea is that we are going to check out this specific API because it's for free and because it
offers a lot of great functionality for free that we can use in order to practice our skills and then
apply those to other APIs that are made available for all kinds of things.
For example, if you were to build a football app which has the latest information about football matches
and teams and scores and everything, you could check out football data, drug, for example, and use
their API or whatever you come up with.
I mean, there are a bunch of different apps that you can use and you will have to work with APIs quite
often as a developer as well.
So very many projects require you to access data from an API and then display it in your application.
And that is what we're going to learn in this whole chapter, which is really important, as I said.
So you will learn how to access the data, download the data, bring the data in the right format,
and then display the data on your device with a UI that looks great.
And as it takes quite some effort in order to gather all this data, for example, the data about matches
to data about whether whatever those services usually are not for free.
Many websites do offer a free version or a certain part of it for free.
For example, here, the current weather data is what we can get for free so you can see available for
free and then all other paid accounts.
Then you have already forecast, which is new, but this one is only available for the paid users,
so to speak and so forth.
All right.
So they have many different options that you can choose from here, a bunch of different APIs.
But we are going to work with this current weather data so you can always check out the API document.
And that is generally what I would recommend you do, because you need to understand what the API is
giving you as information and how you can call the API so you can see an API call would be this is an
example here where you have this city name or you could add the city name plus the country code, or
you could search whether by ID or by city ID, but therefore you need of course, to know the city IDs.
Then you can see you can download the whole file, which contains all of the city IDs, and then use
your code in order to find out which side the city has that you want to know about and so forth.
But we're going to use this one here by geographic coordinates where we are going to pass in the latitude
and longitude.
And based on that, we will get the weather forecast or actually the current weather for this particular
location.
So let's open this up.
You can see when you start such a call, that is what you get.
You get this kind of information.
So it's a lot of JSON code here.
And if we use that on JSON viewer, then view that you can see that this is how we get the data.
So we get adjacent object, which contains another JSON object, which contains a list of Drayson objects.
And then you can see it goes further and further.
So this is basically how the data will be sent to us and we can then use this data in order to display
it.
So you can see we get caught, whether main wind clouds and this and all of these would be classes that
we can, of course, use as data classes in our project.
So we will need to set that up in our project in order to have the right models and then use JSON,
as we have seen before, in order to get the data in a super easy format and then displayed rather quickly
without much hassle.
Then there is something else that you can see here when doing the API call, so we have the link, then
we have data slash 2.5 slash and then you can see this keyword.
Whether then what's important is this question mark.
So we want to get the weather and then after the question mark is where we send information.
So here, for example, I'm setting the latitude of 35, the longitude of one hundred and thirty nine,
the app ID, which is the key that they have here.
So you need to pass in the API key that you have.
So this one is only available for testing.
So you cannot copy this API key and use it for yourself, but you can register on this website in order
to get an API key and we are going to need that.
And you're going to need your own API key, of course, for testing purposes.
And as it is with three versions, usually they are limited to a certain degree, not only to the usage.
In terms of the different features and functionalities, but also in terms of the amount of calls that
you can do, so you cannot do unlimited calls with this, I guess.
So if you check it out, you will learn more about it.
So here you can learn everything about this API, but usually it is really limited to a certain amount
of responses.
And maybe when it's free, the response will be slower and so forth.
So when it comes to making this a project, you would of course, need to make some money with your
project as well, for example, through ads or through it being a paid application or a subscription
model that you could use for this and so forth.
Of course, for Weatherup, that's probably not the best choice because nobody's going to pay that because
there are a bunch of free versions for it.
But if you use, for example, a football app where people get very specific information that they wouldn't
get otherwise and you have the best UI design and so forth, then it could be a different story.
All right.
So it really depends on the value that you deliver with your application.
There is another thing that I would very quickly like to talk about, and that is that we cannot only
use Jason, but we can also use XML or we can get the data in XML format.
So let me search, for example, here and show you real quick.
So this is how the response would be in XML format.
OK, we're not going to look into XML because we're going to use Jason.
And I wanted to just quickly show you that there are different types of formats, how you can get data
when using APIs.
So there are APIs which require you to use XML, but usually the newer ones will offer Jason as well.
OK, so you can see current is the highest level.
Then you have the city with the ID and name, the court with the latitude and longitude to country time
zone and so forth.
So you basically get the data in a slightly different manner.
But I really prefer the way Jason sends me the data or gives me the data, because then we can work
with it very quickly, we can understand different objects that there are and so forth.
All right, so now please go ahead and sign up here, so register and once you're signing sign up,
you can log in and then you can go to your API here and there you will find your API key.
So in my case, I have two keys here and you can just copy that key and then use it in your application.
And I will show you later on where we need to put that key and that will be done in one of the next
videos.
OK.
So I'd say let's go over to our project and start building it from the ground up.
And as you might have guessed, we will use a bunch of third party libraries.
For example, we're going to use Dextre, we're going to use Jaeson.
And then we're also going to use.
Retrofit, which is a tool that allows us to get data rather quickly from the website that we want to
use, and it will be super useful.
So let's get started in the next video.