Everything You Need To Know About Retrofit and Moshi in Android | Get Data from an API

preview_player
Показать описание
In this video, you will learn about Retrofit in Android

This is a tutorial on how to get data from an API on your Android device. I will show you how to use Retrofit in order to make the request and parse the response.

Networking is a very important aspect of Android development. We often require to retrieve data or load images from a server to display on our application, this process is called networking.

To interact with data from the internet we need to make a request to the server, lets understand what a request is and what happens during the process.

There are two different parts to consider when making a request, the Client and the Server

A client can be any of your device's phone, tablet, laptop, or even a browser while the server can be any central computer or program that controls or provides the information that you need.

The client and server use the hypertext transfer protocol (HTTP) methods to communicate with each other. There are specific methods created to enable them to understand each other which includes:

- @GET - The get method is for reading data from the server
- @POST - The post method is to create or add data to a server
- @PUT - The put method is to update an already existing data
- @DELETE - The delete method is to remove an existing data

When the client makes any of these requests, the server processes it and reacts with a response. There are response codes that indicate the status of the request sent to the server.

- 100 - 1XX → This is an information response
- 200 - 2XX → This is a successful response
- 300 - 3XX → This is a redirection response
- 400 - 4XX → This is a client error
- 500 - 5XX → This is a server error

The most common response codes to encounter are **200** which is an **OK** response code meaning that your request was successful. **404** which is a **Not Found** error code meaning that the request sent by the client does not exist on the server. **503** is a **Service Unavailable** error code meaning that the server you are requesting information from is not available at the moment.

tutorialsEU offers you free video tutorials about programming and development for complete beginners up to experienced programmers.
This includes C#, Unity, Python, Android, Kotlin, Machine Learning, etc.
Рекомендации по теме
Комментарии
Автор

Hey Denis, Thank you for making this tutorial, one **critical** thing I must mention.

Those copy pastes didn't help at all, especially if I am just learning how to use retrofit. It is confusing and its removing concentration.
When I see you type it helps me think and my brain connects the written code to the task we are doing, however, when you copy paste I can't concentrate and its very hard to understand new subject like this.

Thanks again for the lesson!

MrDorperezz
Автор

I would recommend you add Moshi to your title as well, I have been looking for this everywhere and none has the clarity you had on implementing retrofit and moshi. Thank you Denis <3

eganathan.r
Автор

No, this is to many copy/paste, impossible look(((

stasleonov
Автор

hello sir, can you plz make a course on a advanced fitness app like app purchases is there in application and many more a app which is uploaded on play store whose name is workout from home application...sir plz make that video on that.

mysticmanish
Автор

Thanks for this video, but i see that you do not get all the characters, can you show a way on how to access more page(more characters)?

gerardomedellin
Автор

I followed exact instructure but is doesn't work, can you attach the code file?

farshad
Автор

I did not understand anything. Copy paste is hard to understand.

bilmiyorum
Автор

You can make new course about how to make a real project like amazon, ebay, facebook and netflix

muhmmadnabil
Автор

You can make video about dagger-hilt, Google and Facebook login?

khuenguyen
Автор

The tutorial is good but copy paste is a bad practice and hard to understand.

muhammadfarooq