Mobile apps · Library

OkHttp and Retrofit

The usual pair of libraries Android apps use to talk to web servers: OkHttp sends the HTTP requests, and Retrofit turns an API into simple Kotlin functions.

Android building blocks · Open source · updated

How it works

OkHttp, from Square, is an HTTP client that handles connection reuse, HTTP/2, compression, caching, retries, timeouts and WebSockets. Interceptors let an app add an auth header to every request, log traffic or refresh an expired token in one place, and certificate pinning can restrict which server certificates the app trusts.

Retrofit sits on top: you write an interface with one annotated function per endpoint (for example @GET with a path), and Retrofit generates the networking code, turning JSON into Kotlin objects through a converter such as kotlinx.serialization, Moshi or Gson. Both target the JVM and Android, so Kotlin Multiplatform code usually uses Ktor's HTTP client for the same job.

OkHttp and Retrofit pricing

Open source

Free (Apache 2.0).

Approximate, checked September 2026.What the other tools cost

More in Mobile apps

Android building blocks

All 34 Mobile apps terms

Crafted in the dark. Shipped to the world.

Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.