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
Related terms
More in Mobile apps
Android building blocks