Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kittinunf/Fuel
The easiest HTTP networking library for Kotlin/Android
https://github.com/kittinunf/Fuel
android http-client kotlin networking rest rxjava
Last synced: 8 days ago
JSON representation
The easiest HTTP networking library for Kotlin/Android
- Host: GitHub
- URL: https://github.com/kittinunf/Fuel
- Owner: kittinunf
- License: mit
- Created: 2015-06-04T04:03:33.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T09:52:27.000Z (6 months ago)
- Last Synced: 2024-05-22T13:08:28.526Z (6 months ago)
- Topics: android, http-client, kotlin, networking, rest, rxjava
- Language: Kotlin
- Homepage: https://fuel.gitbook.io/documentation/
- Size: 2.47 MB
- Stars: 4,503
- Watchers: 75
- Forks: 428
- Open Issues: 94
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-kotlin-android - Fuel - The easiest HTTP networking library for Kotlin/Android. (Libraries)
- awesome-kotlin - Fuel - The easiest HTTP networking library for Kotlin/Android. (Libraries)
- awesome-kotlin-android - Fuel - 最简单的 HTTP 网络库 🔥🔥🔥🔥🔥 (开源库 / 网络)
- awesome-kotlin-cn - Fuel - The easiest HTTP networking library for Kotlin/Android. (开源库和框架 / 网络)
- awesome-kotlin - Fuel - A complete network library with routing support. (Libraries / Network)
README
# Fuel
[![Kotlin](https://img.shields.io/badge/Kotlin-2.0-blue.svg)](http://kotlinlang.org)
[![MavenCentral](https://maven-badges.herokuapp.com/maven-central/com.github.kittinunf.fuel/fuel-jvm/badge.svg)](https://search.maven.org/search?q=com.github.kittinunf.fuel)
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io)
[![Run Gradle Push](https://github.com/kittinunf/fuel/actions/workflows/main.yml/badge.svg)](https://github.com/kittinunf/fuel/actions/workflows/main.yml)
[![Codecov](https://codecov.io/github/kittinunf/fuel/coverage.svg?branch=main)](https://codecov.io/gh/kittinunf/fuel/branch/main)The easiest HTTP networking library for Kotlin backed by Kotlinx Coroutines.
## Migration
From 3.x onwards, we are using [main](https://github.com/kittinunf/fuel/tree/main) as our new base branch. If you are finding the old version [2.x](https://github.com/kittinunf/fuel/tree/2.x), please take a look at our old branch.## Download
### For release version
```kotlin
implementation("com.github.kittinunf.fuel:fuel:3.0.0-alpha03")
```## Quick Start
use the `any http method` [suspend](https://kotlinlang.org/docs/reference/coroutines/basics.html) function:
```kotlin
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](https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/) configurations
```kotlin
val fuel = FuelBuilder().config(OKHttpClient()).build()
val string = fuel.get(request = { url = "https://publicobject.com/helloworld.txt" }).body.string()
```Apple uses [NSURLSessionConfiguration](https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration)
```kotlin
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](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro), [OkHttp](https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro) and [Okio](https://github.com/square/okio/blob/master/okio/src/jvmMain/resources/META-INF/proguard/okio.pro).
If you use the fuel-serialization modules, you may need to add rules for [Serialization](https://github.com/Kotlin/kotlinx.serialization#androidjvm).
If you use the fuel-moshi modules, you may need to add rules for [Moshi](https://github.com/square/moshi/blob/master/moshi/src/main/resources/META-INF/proguard/moshi.pro) and [Moshi-Kotlin](https://github.com/square/moshi/blob/master/kotlin/reflect/src/main/resources/META-INF/proguard/moshi-kotlin.pro)
## Other libraries
If you like Fuel, you might also like other libraries of mine;
* [Result](https://github.com/kittinunf/Result) - The modelling for success/failure of operations in Kotlin
* [Fuse](https://github.com/kittinunf/Fuse) - A simple generic LRU memory/disk cache for Android written in Kotlin
* [Forge](https://github.com/kittinunf/Forge) - Functional style JSON parsing written in Kotlin
* [ReactiveAndroid](https://github.com/kittinunf/ReactiveAndroid) - Reactive events and properties with RxJava for Android SDK## Credits
Fuel brought to you by [contributors](https://github.com/kittinunf/Fuel/graphs/contributors).
## Licenses
Fuel released under the [MIT](https://opensource.org/licenses/MIT) license.