explaingit

square/retrofit

Analysis updated 2026-06-20

43,907HTMLAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Java and Android library that turns a typed interface into a working REST API client automatically, describe your endpoints with annotations and Retrofit generates all the networking code.

Mindmap

mindmap
  root((Retrofit))
    What it does
      Typed HTTP client
      Auto serialization
      Interface to code
    Serialization
      Gson JSON
      Moshi JSON
      Protobuf XML
    Async models
      Kotlin coroutines
      RxJava
      Java Futures
    Platforms
      Android apps
      JVM backend
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Call a REST API from an Android app by defining endpoints as a Kotlin interface with annotations, no manual URL building or JSON parsing needed.

USE CASE 2

Automatically serialize request bodies and deserialize JSON responses using Gson or Moshi with zero boilerplate code.

USE CASE 3

Integrate async API calls into an Android or JVM project using Kotlin coroutines, RxJava, or Java Futures.

USE CASE 4

Catch API contract mistakes at compile time because endpoints are expressed as typed Java or Kotlin method signatures.

What is it built with?

JavaKotlinOkHttp

How does it compare?

square/retrofitdocker/awesome-composetabler/tabler
Stars43,90745,14141,017
LanguageHTMLHTMLHTML
Setup difficultyeasyeasyeasy
Complexity2/51/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min
Free to use for any purpose including commercial, as long as you include the Apache 2.0 license notice.

In plain English

Retrofit is a type-safe HTTP client library for Android and the Java Virtual Machine (JVM), developed and open-sourced by Square. The problem it solves is making REST API calls in Java and Android cleaner and safer. Without a library like Retrofit, calling a web API requires manually constructing URLs, building HTTP requests, sending them, parsing the raw JSON or XML response, and handling errors, all low-level, repetitive, and error-prone work. Retrofit lets you describe your entire API as a Java or Kotlin interface using annotations. Each method in the interface represents one API endpoint: you annotate it with the HTTP method and URL path, annotate the parameters to indicate which become URL segments, query parameters, or request body fields, and specify the return type. Retrofit then generates the actual implementation of that interface at runtime, handling URL construction, serialization, and deserialization automatically. Because the API contract is expressed as a regular Java/Kotlin interface with typed method signatures, your IDE can autocomplete method calls and your compiler can catch mistakes, for example, passing the wrong type of argument or forgetting a required parameter, before you ever run the code. This is what "type-safe" means in this context. Retrofit works with multiple serialization backends (converters) to handle different data formats: Gson, Jackson, Moshi, and others for JSON, as well as Protobuf and XML. For asynchronous calls it integrates with RxJava, Kotlin coroutines, and Java Futures, so you can choose the concurrency model that fits your project. Networking is built on top of Square's OkHttp library. Android developers and backend Java/Kotlin service developers reach for Retrofit whenever they need to consume a REST API. It is one of the most widely adopted networking libraries in the Android ecosystem. It requires Java 8 or newer, or Android API level 21 and above. It is distributed via Maven Central and licensed under Apache 2.0.

Copy-paste prompts

Prompt 1
Show me how to set up Retrofit in an Android project to call a paginated REST API, using Kotlin coroutines and Moshi for JSON serialization.
Prompt 2
I'm using Retrofit with OkHttp. How do I add an interceptor that injects a Bearer token into every API request header automatically?
Prompt 3
Help me define a Retrofit interface for a REST API that has GET, POST, and DELETE endpoints with path parameters and optional query parameters.
Prompt 4
How do I handle Retrofit API errors in Kotlin, catching HTTP error codes and parsing error response bodies into a typed error object?
Prompt 5
Set up Retrofit with RxJava in an Android project to make two parallel API calls and combine their results into a single response.

Frequently asked questions

What is retrofit?

Java and Android library that turns a typed interface into a working REST API client automatically, describe your endpoints with annotations and Retrofit generates all the networking code.

What language is retrofit written in?

Mainly HTML. The stack also includes Java, Kotlin, OkHttp.

What license does retrofit use?

Free to use for any purpose including commercial, as long as you include the Apache 2.0 license notice.

How hard is retrofit to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is retrofit for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub square on gitmyhub

Verify against the repo before relying on details.