### Install RxJava 3 Adapter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/rxjava3/README.md
Add the required dependency to your project using Maven or Gradle.
```xml
com.squareup.retrofit2
adapter-rxjava3
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:adapter-rxjava3:latest.version'
```
--------------------------------
### Install Retrofit Mock via Maven
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-mock/README.md
Add this dependency to your pom.xml file to include the library in your project.
```xml
com.squareup.retrofit2
retrofit-mock
see.latest.version
```
--------------------------------
### Install Retrofit Mock via Gradle
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-mock/README.md
Add this implementation line to your build.gradle file to include the library in your project.
```groovy
implementation 'com.squareup.retrofit2:retrofit-mock:see.latest.version'
```
--------------------------------
### Generated keep rules
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-response-type-keeper/README.md
Examples of the ProGuard/R8 keep rules generated by the processor for different return types.
```text
-keep com.example.User
```
```text
-keep com.example.ApiResponse
-keep com.example.User
```
--------------------------------
### Define a Retrofit service method
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-response-type-keeper/README.md
Example of a service method where the return type might be stripped by R8 if unused.
```java
@GET("users/{id}")
Call getUser(
@Path("id") String id);
```
--------------------------------
### Define HTTP Request Method
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/declarations.md
Use built-in annotations like @GET or @POST to specify the request method and relative URL.
```java
@GET("users/list")
```
```java
@GET("users/list?sort=desc")
```
--------------------------------
### Build the project
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/contributing.md
Commands to verify that the code compiles before submission.
```bash
./gradlew build
```
```bash
gradlew.bat build
```
--------------------------------
### Initialize Retrofit and create service
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/index.md
Configure the Retrofit instance with a base URL and generate an implementation of the service interface.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.github.com/")
.build();
GitHubService service = retrofit.create(GitHubService.class);
```
--------------------------------
### Tag release version
Source: https://github.com/lysine-dev/retrofit/blob/trunk/RELEASING.md
Create a git tag for the new release version.
```bash
$ git tag -am "Version X.Y.Z" X.Y.Z
```
--------------------------------
### Add Dependency via Maven or Gradle
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/rxjava/README.md
Include the adapter library in your project build configuration.
```xml
com.squareup.retrofit2
adapter-rxjava
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:adapter-rxjava:latest.version'
```
--------------------------------
### Project License
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/contributing.md
The Apache License 2.0 terms applicable to the project.
```text
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.
```
--------------------------------
### Configure Retrofit with RxJavaCallAdapterFactory
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/rxjava/README.md
Register the adapter factory during the Retrofit instance construction.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
```
--------------------------------
### Configure Retrofit with kotlinx.serialization
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/kotlinx-serialization/README.md
Use asConverterFactory to integrate kotlinx.serialization into the Retrofit builder.
```kotlin
val retrofit = Retrofit.Builder()
.baseUrl("https://example.com/")
.addConverterFactory(
Json.asConverterFactory(
"application/json; charset=utf-8".toMediaType()))
.build()
```
--------------------------------
### Add Dependency via Maven or Gradle
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/rxjava2/README.md
Include the adapter-rxjava2 dependency in your project configuration.
```xml
com.squareup.retrofit2
adapter-rxjava2
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:adapter-rxjava2:latest.version'
```
--------------------------------
### Push release and tags
Source: https://github.com/lysine-dev/retrofit/blob/trunk/RELEASING.md
Push commits and tags to the remote repository to trigger the release workflow.
```bash
$ git push && git push --tags
```
--------------------------------
### Manage Request Headers
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/declarations.md
Use @Headers for static headers, and @Header or @HeaderMap for dynamic header values.
```java
@Headers("Cache-Control: max-age=640000")
@GET("widget/list")
Call> widgetList();
```
```java
@Headers({
"Accept: application/vnd.github.v3.full+json",
"User-Agent: Retrofit-Sample-App"
})
@GET("users/{username}")
Call getUser(@Path("username") String username);
```
```java
@GET("user")
Call getUser(@Header("Authorization") String authorization)
```
```java
@GET("user")
Call getUser(@HeaderMap Map headers)
```
--------------------------------
### Dynamic URL Manipulation
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/declarations.md
Use @Path for replacement blocks and @Query or @QueryMap for dynamic URL parameters.
```java
@GET("group/{id}/users")
Call> groupList(@Path("id") int groupId);
```
```java
@GET("group/{id}/users")
Call> groupList(@Path("id") int groupId, @Query("sort") String sort);
```
```java
@GET("group/{id}/users")
Call> groupList(@Path("id") int groupId, @QueryMap Map options);
```
--------------------------------
### Commit development version
Source: https://github.com/lysine-dev/retrofit/blob/trunk/RELEASING.md
Commit the update to the next snapshot version after the release.
```bash
$ git commit -am "Prepare next development version"
```
--------------------------------
### Add dependency to Gradle
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-response-type-keeper/README.md
Configuration for including the annotation processor in Java or Kotlin projects.
```groovy
annotationProcessor 'com.squareup.retrofit2:response-type-keeper:'
```
```groovy
kapt 'com.squareup.retrofit2:response-type-keeper:'
```
--------------------------------
### Configure Retrofit with GuavaCallAdapterFactory
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/guava/README.md
Register the factory during Retrofit instance construction to enable ListenableFuture support.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(GuavaCallAdapterFactory.create())
.build();
```
--------------------------------
### Add Dependency for Guava Adapter
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/guava/README.md
Include the adapter dependency in your project build configuration.
```xml
com.squareup.retrofit2
adapter-guava
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:adapter-guava:latest.version'
```
--------------------------------
### Add Moshi Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/moshi/README.md
Include the converter-moshi dependency in your project build configuration.
```xml
com.squareup.retrofit2
converter-moshi
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-moshi:latest.version'
```
--------------------------------
### Configure Retrofit with RxJava3CallAdapterFactory
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/rxjava3/README.md
Register the adapter during the Retrofit instance construction to enable support for RxJava 3 types.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build();
```
--------------------------------
### Add Dependency for Scala Adapter
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/scala/README.md
Include the adapter library in your project using Maven or Gradle.
```xml
com.squareup.retrofit2
adapter-scala
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:adapter-scala:latest.version'
```
--------------------------------
### Configure Retrofit with RxJava2CallAdapterFactory
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/rxjava2/README.md
Add the adapter factory to the Retrofit builder to enable support for RxJava 2 types.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
```
--------------------------------
### Add Wire Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/wire/README.md
Include the converter-wire dependency in your project build configuration.
```xml
com.squareup.retrofit2
converter-wire
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-wire:latest.version'
```
--------------------------------
### Add Retrofit dependency with Gradle
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/download.mdx
Use this implementation line in your build.gradle file to include the Retrofit library.
```kotlin
implementation("com.squareup.retrofit2:retrofit:2.11.0")
```
--------------------------------
### Define a GitHub API interface
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/index.md
Create a Java interface representing API endpoints using Retrofit annotations.
```java
public interface GitHubService {
@GET("users/{user}/repos")
Call> listRepos(@Path("user") String user);
}
```
--------------------------------
### Add Protocol Buffer Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/protobuf/README.md
Include the converter in your project using Maven or Gradle build tools.
```xml
com.squareup.retrofit2
converter-protobuf
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-protobuf:latest.version'
```
--------------------------------
### Configure Retrofit with GsonConverterFactory
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/configuration.md
Use this pattern to integrate Gson for deserializing API responses into Java objects.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.github.com/")
.addConverterFactory(GsonConverterFactory.create())
.build();
GitHubService service = retrofit.create(GitHubService.class);
```
--------------------------------
### Add dependency for kotlinx.serialization converter
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/kotlinx-serialization/README.md
Include the converter dependency in your project build configuration.
```xml
com.squareup.retrofit2
converter-kotlinx-serialization
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-kotlinx-serialization:latest.version'
```
--------------------------------
### Define Service Method with Future
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/scala/README.md
Service interface methods can now return a Future type.
```java
interface MyService {
@GET("/user")
Future getUser();
}
```
--------------------------------
### Add Jackson Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/jackson/README.md
Include the converter-jackson dependency in your project build configuration.
```xml
com.squareup.retrofit2
converter-jackson
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-jackson:latest.version'
```
--------------------------------
### Define Service Method with ListenableFuture
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/guava/README.md
Use ListenableFuture as the return type for service interface methods.
```java
interface MyService {
@GET("/user")
ListenableFuture getUser();
}
```
--------------------------------
### Add Simple XML Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/simplexml/README.md
Include the converter in your project using Maven or Gradle. Note that for Android, specific transitive dependencies must be excluded.
```xml
com.squareup.retrofit2
converter-simplexml
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-simplexml:latest.version'
```
--------------------------------
### Commit release version
Source: https://github.com/lysine-dev/retrofit/blob/trunk/RELEASING.md
Commit the changes made to version files and changelogs.
```bash
$ git commit -am "Prepare version X.Y.Z"
```
--------------------------------
### Add Gson Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/gson/README.md
Include the converter-gson dependency in your project build configuration.
```xml
com.squareup.retrofit2
converter-gson
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-gson:latest.version'
```
--------------------------------
### Add Retrofit dependency with Maven
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/download.mdx
Include this dependency block in your pom.xml file to manage Retrofit via Maven.
```xml
com.squareup.retrofit2
retrofit
2.11.0
```
--------------------------------
### Configure Retrofit with XML Converter
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/jackson/README.md
Requires the jackson-dataformat-xml dependency.
```java
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addConverterFactory(
JacksonConverterFactory.create(
new XmlMapper(),
MediaType.get("application/xml")))
.build();
```
--------------------------------
### Registering a Call Adapter Factory in Retrofit
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/README.md
Add a custom call adapter factory to the Retrofit builder to support alternative execution mechanisms like RxJava.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.example.com")
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
```
--------------------------------
### Execute an API call
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/index.md
Invoke a method on the service interface to obtain a Call object for performing requests.
```java
Call> repos = service.listRepos("octocat");
```
--------------------------------
### Configure Retrofit with CBOR Converter
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/jackson/README.md
Requires the jackson-dataformat-cbor dependency.
```java
import com.fasterxml.jackson.dataformat.cbor.databind.CBORMapper;
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addConverterFactory(
JacksonConverterFactory.create(
new CBORMapper(),
MediaType.get("application/cbor")))
.build();
```
--------------------------------
### Add Guava Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/guava/README.md
Include the converter in your project using Maven or Gradle.
```xml
com.squareup.retrofit2
converter-guava
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-guava:latest.version'
```
--------------------------------
### Add JAXB Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/jaxb/README.md
Include the JAXB converter dependency in your project build configuration.
```xml
com.squareup.retrofit2
converter-jaxb
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-jaxb:latest.version'
```
--------------------------------
### Add JAXB 3 Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/jaxb3/README.md
Include the converter dependency in your project using Maven or Gradle.
```xml
com.squareup.retrofit2
converter-jaxb3
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-jaxb3:latest.version'
```
--------------------------------
### Form-Encoded and Multipart Requests
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/declarations.md
Use @FormUrlEncoded with @Field for form data, or @Multipart with @Part for multipart requests.
```java
@FormUrlEncoded
@POST("user/edit")
Call updateUser(@Field("first_name") String first, @Field("last_name") String last);
```
```java
@Multipart
@PUT("user/photo")
Call updateUser(@Part("photo") RequestBody photo, @Part("description") RequestBody description);
```
--------------------------------
### Register a converter factory in Retrofit
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/README.md
Add a converter factory to the Retrofit builder to enable support for specific data formats.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.example.com")
.addConverterFactory(GsonConverterFactory.create())
.build();
```
--------------------------------
### Define Service Method with RxJava Type
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/rxjava2/README.md
Use supported RxJava types as return types in your Retrofit service interface.
```java
interface MyService {
@GET("/user")
Observable getUser();
}
```
--------------------------------
### Register ScalaCallAdapterFactory in Retrofit
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-adapters/scala/README.md
Add the factory to the Retrofit builder to enable Scala Future support.
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(ScalaCallAdapterFactory.create())
.build();
```
--------------------------------
### Define Request Body
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/declarations.md
Use the @Body annotation to specify an object as the HTTP request body.
```java
@POST("users/new")
Call createUser(@Body User user);
```
--------------------------------
### Add Scalars Converter Dependency
Source: https://github.com/lysine-dev/retrofit/blob/trunk/retrofit-converters/scalars/README.md
Include the converter-scalars dependency in your project build configuration.
```xml
com.squareup.retrofit2
converter-scalars
latest.version
```
```groovy
implementation 'com.squareup.retrofit2:converter-scalars:latest.version'
```
--------------------------------
### Kotlin Suspend Functions
Source: https://github.com/lysine-dev/retrofit/blob/trunk/website/src/content/docs/declarations.md
Interface methods support suspend functions to return Response objects or the body directly.
```kotlin
@GET("users")
suspend fun getUser(): Response
```
```kotlin
@GET("users")
suspend fun getUser(): User
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.