Docs

Retrofit

Type-safe HTTP client.

What is Retrofit

Retrofit turns a Kotlin interface into a working HTTP client using annotations.

Install

gradle
kotlin
implementation("com.squareup.retrofit2:retrofit:2.11.0")

Usage

kotlin
kotlin
interface Api {
    @GET("users/{id}")
    suspend fun user(@Path("id") id: Int): User
}

Docs

Official documentation: Retrofit.