Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Consuming Rest Api with retrofit in Android

Consuming Rest Api with retrofit in Android

consuming dog api with retrofit

ValentineRutto

May 08, 2021
Tweet

More Decks by ValentineRutto

Other Decks in Programming

Transcript

  1. @ValentineRutto, Android Engineer Consuming Rest APIs in Android

  2. ValentineRutto Android Engineer-@Dlight Twitter | Linkedin | Medium | Github

    | Instagram @valentinerutto
  3. API(application programming interface). It is a set of rules that

    allow programs to talk to each other. REST(“Representational State Transfer”) -Determines how the API looks like -It is a set of rules that developers follow when they create their API What is Rest API?
  4. None
  5. A client library developed by square that is used to

    create HTTP Requests and process HTTP responses from a REST API Retrofit library
  6. • Retrofit Interface An interface that defines HTTP operations @GET("api/breeds/image/random")

    suspend fun getRandomDogImage(): DogImageResponse • Retrofit class Creates an instance of retrofit and implements the retrofit interface methods val apiClient: ApiService= Retrofit.Builder() .baseUrl("https://dog.ceo") .client(OkHttpClient()) .addConverterFactory(GsonConverterFactory.create()) .build() .create(ApiService::class.java) • Retrofit Converters Defines format that data will be represented in. GSON is JSON mapping. Retrofit Classes
  7. Resources DOGAPI Documentation Consuming dog api

  8. Demo Github Code https://github.com/valentineRutto/RandomdogImages

  9. Thank You Twitter | Linkedin | Medium | Github @valentinerutto