‫After we have successfully created the model classes.
‫We are going now to create the API client that makes that connection using their retrofit web API.
‫And with that our app.
‫So lets fetch the data according to the API calls.
‫Before we start any question, please listed below comment in the comments in order to add to support
‫you and answer it.
‫And if you want to learn more about the retrofit, please go to this section of retrofit and learn deeply
‫about that.
‫Let's create another package called API.
‫And inside this package I will create a Java class called it will name it as API client.
‫And this is the class inside the API package.
‫Okay.
‫So I will define that API interface also.
‫Inside this class.
‫So I will start here where the public interface, API interface.
‫Define get a request with query string parameter as page number.
‫So here we need to use gapped and what we need to get we need to get that movie slash popular.
‫This is the link where we have discussed it before.
‫So this is the link.
‫This is the end point link.
‫And the base you are al here inside the deals which is here.
‫So if we put API the movie debate that slash three slash movie slash popular and then we will send the
‫request here.
‫So I will import the get at first and now I will make a single of the movie movie response.
‫Olympus entered to import the class and I'll get more vs by page and this is where we need to use the
‫paging.
‫Okay.
‫And here using the rc rs our X Java three and now we are going to put the query here, query page and
‫name it as page.
‫Okay.
‫This is how we are going to depend on the pages where using that paging line.
‫So now let's use this interface.
‫And now I'm going to change the strategy of making a dependent interface.
‫I implemented it directly inside this class.
‫You can make it as a standalone interface.
‫It's up to you.
‫But I'm making it for not confusing and segment and many of the.
‫API says okay now.
‫API interface API in third.
‫Interface.
‫Okay.
‫Create the retrofit instance.
‫Retrofit the instance.
‫Public static API.
‫It returns an API interface and it's called get interface.
‫And inside this would be if API interface equal or equal to now, then what to do?
‫Create an object type client.
‫You can make a retrofit request or call, but since I want to from you to learn all kinds of of calls,
‫all all kinds of client creation.
‫So I'm going to use okay at every client dot builder.
‫This is a different way from the previous videos that we have created in order to allow you to understand
‫that there are different types of creating that clients that okay, HTP clients and so on.
‫Now adding interceptor to add API key as query string parameter to each request.
‫So client dot AB interceptor chain and this chain will give us this request origin.
‫Now this is the chain that request this is the base request.
‫Okay, that's the ATP.
‫You are al our original a.p.
‫You are l equal to the original dot.
‫You are asked.
‫Okay.
‫I will import this.
‫Import the class.
‫And here
‫now, actually, I'm using the different, different libraries.
‫Okay.
‫Actually, Tipi, which has an embedded inside that are retrofit this is another type and usage of of
‫retrofit library.
‫Okay you are al original adjusted import and you go there and here we add the API key as query string
‫parameter.
‫So add query, but meet that which is an API underscore key and it is an API key.
‫Underscore key.
‫Dot build.
‫I will import the API key here.
‫Static content from the utils class that I have create.
‫So this will make me be used.
‫Okay.
‫Request the builder to request builder the equal to or original dot new builder the u r l u r.
‫L.
‫Okay, and request a request equal to the new request of the builder.
‫Both the return.
‫Return the chain.
‫Not proceed.
‫I know this is this is more complicated than using directly that retrofit.
‫But I should remember you that I'm using this in order to make things.
‫Happens directly with you.
‫Making sure that you are having all the ideas.
‫And making sure that your connection and your clients are not and not subjected to errors or any things
‫that interrupt data.
‫Receiving?
‫No.
‫Create the retrofit instance.
‫We can create that instance by creating the retrofit.
‫Retrofit equal to new retrofit dot builder.
‫Don't
‫base your r l base your r l this is in your tin i we have imported the client.
‫Client which is the client not built here we are creating our custom client.
‫So we have used this client.
‫But it's the client.
‫And we have invented here and used it here.
‫Okay, so this is a custom client.
‫You can skip it and you can make it.
‫But I preferred making it custom as I have done it.
‫Okay.
‫Not create.
‫And now our exit java support for retrofit add call adapter factory or x.
‫Java three hour x Java City Coal Adapter Factory.
‫Maybe I have missed it in the dependencies.
‫So let me go to here to.
‫To our as our ex java.
‫Okay.
‫Here.
‫Forex Java three
‫implementation of Android.
‫Com the square of the trip referred to as adapter.
‫I think here it is for the retrofit.
‫Adapter and retro retrofit adapter for our java wear.
‫And this is the adapter I need from this adapter to implement RSX Java three and the latest version
‫of retrofit is 2.9 points here.
‫Let's sink now.
‫And wait for Grendel.
‫Okay.
‫Let's go here.
‫And now alt plus.
‫Enter an import package.
‫And this solves the error.
‫Now create.
‫We need to call the method build and now initiate the API interface.
‫So I interface equal to retrofit dot create API interface dot class.
‫In this way we have created our API client now returning that API interface.
‫Okay.
‫So this is all about creating this API interface.
‫We have called that get method.
‫We have created that get movies by page in order to call it later on the next videos.
‫We depend on the page, which is the query and it's an integer.
‫And these are the calls for that retrofit call that execute, executed and make it the bridge between
‫the API and the recycler view date.