Retrofit

适用于Android和Java的类型安全的HTTP客户端。(A type-safe HTTP client for Android and Java.)

Github星跟蹤圖

适用于Android和Java的类型安全的HTTP客户端。Retrofit 将您的 HTTP API 转换为 Java 接口。\r\n

public interface GitHubService {\r\n  @GET("users/{user}/repos")\r\n  Call<List<Repo>> listRepos(@Path("user") String user); \r\n}\r\n

Retrofit类生成GitHubService接口的实现。
\r\n

Retrofit retrofit = new Retrofit.Builder()\r\n    .baseUrl("https://api.github.com/")\r\n    .build();\r\nGitHubService service = retrofit.create(GitHubService.class);\r\n

来自创建的GitHubService的每个 call 都可以向远程Web服务器发送同步或异步HTTP请求。\r\n

Call<List<Repo>> repos = service.listRepos("octocat");\r\n

使用 annotations (注解)来描述HTTP请求:\r\n

    \r\n\t
  • URL参数替换和查询参数支持
  • \r\n\t
  • 对象转换为请求正文(例如,JSON,协议缓冲区)
  • \r\n\t
  • 多部分请求正文和文件上传
  • \r\n

主要指標

概覽
名稱與所有者square/retrofit
主編程語言HTML
編程語言Shell (語言數: 7)
平台
許可證Apache License 2.0
所有者活动
創建於2010-09-07 05:39:43
推送於2025-10-31 23:26:27
最后一次提交
發布數58
最新版本名稱3.0.0 (發布於 2025-05-16 00:27:16)
第一版名稱0.6.0-rc1 (發布於 2012-06-14 03:30:22)
用户参与
星數43.8k
關注者數1.5k
派生數7.3k
提交數2.7k
已啟用問題?
問題數2751
打開的問題數127
拉請求數1250
打開的拉請求數33
關閉的拉請求數396
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

Retrofit

Type-safe HTTP client for Android and Java by Square, Inc.

For more information please see the website.

Download

Download the latest JAR or grab from Maven central at the coordinates com.squareup.retrofit2:retrofit:2.7.1.

Snapshots of the development version are available in Sonatype's snapshots repository.

Retrofit requires at minimum Java 8+ or Android API 21+.

R8 / ProGuard

If you are using R8 the shrinking and obfuscation rules are included automatically.

ProGuard users must manually add the options from
this file.
(Note: You might also need rules for OkHttp and Okio which are dependencies of this library)

License

Copyright 2013 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.