Kotlin MIT

fuel

The easiest HTTP networking library for Kotlin/Android

K

kittinunf

Dernière activité 31 août 2026
kittinunf/fuel

4,6 k

étoiles

439

forks

99

issues ouvertes

androidhttp-clientkotlinnetworkingrestrxjava

Ce README est souvent en anglais.

Fuel

Kotlin MavenCentral ktlint Run Gradle Push Codecov

The easiest HTTP networking library for Kotlin backed by Kotlinx Coroutines.

Migration

From 3.x onwards, we are using main as our new base branch. If you are finding the old version 2.x, please take a look at our old branch.

Download

For release version

implementation("com.github.kittinunf.fuel:fuel:3.0.0-alpha04")

Quick Start

use the any http method suspend function:

runBlocking {
    val string: String = Fuel.get("https://publicobject.com/helloworld.txt").body.string()
    println(string)
}

runBlocking {
    val string: String = "https://publicobject.com/helloworld.txt".httpGet().body.string()
    println(string)
}

runBlocking {
    val fuel = FuelBuilder().build()
    val string: String = fuel.get(request = { url = "https://publicobject.com/helloworld.txt" }).body.string()
    println(string)
}

Custom Configuration

JVM uses OkHttpClient configurations

val fuel = FuelBuilder().config(OKHttpClient()).build()
val string = fuel.get(request = { url = "https://publicobject.com/helloworld.txt" }).body.string()

Apple uses NSURLSessionConfiguration

val fuel = FuelBuilder().config(NSURLSessionConfiguration.defaultSessionConfiguration).build()
val string = fuel.get(request = { url = "https://publicobject.com/helloworld.txt" }).body.string()

Please note it will throw Exceptions. Make sure you catch it on the production apps.

Fuel requires Java 8 byte code.

Requirements

  • If you are using Android, It needs to be Android 5+.
  • Java 8+

R8 / Proguard

Fuel is fully compatible with R8 out of the box and doesn't require adding any extra rules.

If you use Proguard, you may need to add rules for Coroutines, OkHttp and Okio.

If you use the fuel-serialization modules, you may need to add rules for Serialization.

If you use the fuel-moshi modules, you may need to add rules for Moshi and Moshi-Kotlin

Other libraries

If you like Fuel, you might also like other libraries of mine;

  • Result - The modelling for success/failure of operations in Kotlin
  • Fuse - A simple generic LRU memory/disk cache for Android written in Kotlin
  • Forge - Functional style JSON parsing written in Kotlin
  • ReactiveAndroid - Reactive events and properties with RxJava for Android SDK

Credits

Fuel brought to you by contributors.

Licenses

Fuel released under the MIT license.

Projets similaires

A meticulous HTTP client for the JVM, Android, and GraalVM.

Kotlinandroidgraalvmjava
Llysine-dev
47,1 k étoiles9,3 k

A type-safe HTTP client for Android and the JVM

Javaandroidjava
Llysine-dev
43,9 k étoiles7,3 k

🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀

Javaandroidandroid-libraryawesome
Aamitshekhariitbhu
5,9 k étoiles979