On this page
Overview
Retrofit is an HTTP client for Android and the JVM that expresses API paths, parameters, and return values as Java or Kotlin interfaces.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Best fit
Fits clients that want an API contract at a typed, testable boundary
Android and JVM clients can consolidate scattered URL strings and manual parsing into one service interface. A localhost fixture verifies paths and converted results without external credentials.
Sources: [3]
Before adoption
Design transport policy and API error handling in the client
Retrofit is an HTTP client, not an API server. Timeouts, retries, credentials, HTTP errors, converter failures, and model compatibility remain OkHttp and application concerns. Pin the reviewed 3.0.0 release and Apache-2.0 scope.
Official sources
- [1]Retrofit README at commit 3724fff(2026-10-05)
- [2]Retrofit 3.0.0 release(2026-10-05)
- [3]Retrofit declarations documentation(2026-10-05)
- [4]Retrofit GitHub metadata(2026-10-05)
- [5]Retrofit Apache license at commit(2026-10-05)
Supplemental curator note
Retrofit fits Android and JVM teams that want HTTP API boundaries expressed as typed interfaces. Verify paths and conversion against a localhost fixture, then define timeout, authentication, and error-handling policy.
Try it in 3 steps
- 1
Pin Retrofit 3.0.0 and its JSON converter
Requires Java 17, Maven, Python 3, and curl. Create a POM with fixed dependencies in a temporary directory.
retrofit_demo_dir=$(mktemp -d "${TMPDIR:-/tmp}/retrofit-demo.XXXXXX") && cd "$retrofit_demo_dir" && printf '%s ' '<project xmlns="http://maven.apache.org/POM/4.0.0"><modelVersion>4.0.0</modelVersion><groupId>demo</groupId><artifactId>retrofit-demo</artifactId><version>1</version><properties><maven.compiler.release>17</maven.compiler.release></properties><dependencies><dependency><groupId>com.squareup.retrofit2</groupId><artifactId>retrofit</artifactId><version>3.0.0</version></dependency><dependency><groupId>com.squareup.retrofit2</groupId><artifactId>converter-gson</artifactId><version>3.0.0</version></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.14.1</version></plugin></plugins></build></project>' > pom.xml - 2
Compile a typed API interface
In the same directory, define GET /message and its JSON model, resolve dependencies, and compile.
mkdir -p src/main/java/demo && printf '%s ' 'package demo; import retrofit2.*; import retrofit2.converter.gson.*; import retrofit2.http.*; public class Main { record Message(String value){} interface Api{@GET("message") Call<Message> message();} public static void main(String[]a)throws Exception{var r=new Retrofit.Builder().baseUrl(a[0]).addConverterFactory(GsonConverterFactory.create()).build();var v=r.create(Api.class).message().execute().body();System.out.println(v.value());}}' > src/main/java/demo/Main.java && mvn -q dependency:copy-dependencies package - 3
Convert a real localhost response
Serve JSON from a directly owned loopback process and verify Retrofit converts it to typed-ok. The trap kills and waits for the PID on success or failure.
( set -eu; port=$(python3 -c 'import socket;s=socket.socket();s.bind(("127.0.0.1",0));print(s.getsockname()[1]);s.close()'); pid=''; cleanup(){ if [ -n "$pid" ];then kill "$pid" 2>/dev/null||true;wait "$pid" 2>/dev/null||true;fi;}; trap cleanup EXIT HUP INT TERM; printf '%s' '{"value":"typed-ok"}' > message; python3 -m http.server "$port" --bind 127.0.0.1 > server.log 2>&1 & pid=$!; i=0;until curl -fsS --max-time 1 "http://127.0.0.1:$port/message" >/dev/null;do i=$((i+1));[ "$i" -lt 20 ];sleep .25;done; out=$(java -cp 'target/classes:target/dependency/*' demo.Main "http://127.0.0.1:$port/");[ "$out" = typed-ok ];cleanup;pid='';python3 -c 'import errno,socket,sys;s=socket.socket();s.settimeout(1);r=s.connect_ex(("127.0.0.1",int(sys.argv[1])));raise SystemExit(0 if r==errno.ECONNREFUSED else 1)' "$port";trap - EXIT HUP INT TERM;printf '%s ' "$out" )
Growth
Growth trends · Last 30 days
43,936 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 17
- Open PRs
- 38
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- java
- android
- Stars
- 43,936
- Forks
- 7,332
- Watchers
- 1,542
- Open issues
- 114
- Contributors
- 163
- Owner type
- Organization
- Primary language
- Java
- License
- Apache-2.0
- Repository last updated
- Oct 2, 2026
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Apache HttpClient1,535 Stars
1 shared tag(s) · 2 shared category(s) · Same language
build Java HTTP/1.1 and HTTP/2 clients with connection management, authentication, cookies, and caching
Java - Faraday5,951 Stars
1 shared tag(s) · 2 shared category(s)
Use one Ruby HTTP API while composing adapters and middleware for each client workload
Ruby - Notion SDK for JavaScript5,670 Stars
1 shared tag(s) · 2 shared category(s)
Use typed Notion APIs for resources, agents, sessions, and webhooks
TypeScript - DBeaver51,958 Stars
1 shared tag(s) · 1 shared category(s) · Same language
operate many database systems from one desktop SQL workspace
Java - Netty35,065 Stars
1 shared tag(s) · 1 shared category(s) · Same language
Build high-connection protocol servers and clients in Java from event loops and channel pipelines
Java - Bruno47,340 Stars
2 shared tag(s) · 2 shared category(s)
manage API collections as local Bru files in Git and run them from desktop, CLI, or CI
JavaScript
Report incorrect information
Tell us if any listing information is incorrect or outdated.