‫Till now.
‫We created the data classes and the API service interface.
‫Now let's move to the last part of retrofit, which is the retrofit instance.
‫Inside the retrofit package I'll create a new Java class.
‫I'll name it as retrofit instance.
‫And this class intended to create a retrofit instance with a specific base URL and Json converter factory.
‫It's a common practice to create a separate class like this, to encapsulate the configuration and creation
‫of retrofit instances in Android applications.
‫I'll start by creating the string your base URL equals to http, and here I need to specify the IP here
‫in our application the API.
‫If I look closer, we can see it's 127.0.00.1 slash quiz.
‫This is the base URL and this is the end .127.0.0.1.
‫It's similar to the local host.
‫This is the local host.
‫Later on I'll keep this 127.0.00.1 slash quiz.
‫Please pay attention to the link because it's case sensitive.
‫I need to create a method that it is used to create and return a configured retrofit instance.
‫I'll start with public.
‫It's returning type is a retrofit and it's named as get retrofit instance.
‫Inside this method you use retrofit dot builder method to construct a new retrofit instance.
‫So I'll return because I'm going to create and return.
‫So return new I'm creating a new retrofit dot builder.
‫I'm constructing a new retrofit instance dot base URL here.
‫This method sets the base URL for the retrofit instance.
‫All relative URLs in your API service interface will be resolved relative to this base URL, and the
‫base URL in our application is 127.0.0.1.
‫Slash quiz or localhost slash quiz.
‫This is our base URL dot add converter factory.
‫I'll use json converter factory dot create.
‫Here I am configuring the Json converter factory.
‫It tells retrofit to use the Json library to handle the serialization and deserialization of Json data.
‫Json is a popular library for working with Json in Java Android, and it's widely used with retrofit
‫to parse Json responses.
‫Then I need to finish this instance by calling the build method.
‫This method call finalizes the creation of the retrofit instance.
‫So this is how we create an instance of the retrofit.
‫And we're going to use this method to get a retrofit instance in the next videos.