networkinkt alternatives and similar libraries
Based on the "Http Clients" category.
Alternatively, view networkinkt alternatives based on common mentions on social networks and blogs.
-
httpmocker
HttpMocker is a simple HTTP mocking library written in Kotlin to quickly and easily handle offline modes in your apps -
Asynkio
Write your asynchronous Network / IO call painlessly in Kotlin !!
Appwrite - The Open Source Firebase alternative introduces iOS support
Do you think we are missing an alternative of networkinkt or a related project?
Popular Comparisons
README
networkinkt 
This is a lightweight HTTP client for Kotlin. It relies on coroutines on both JS & JVM platforms.
Here is a simple GET
request:
val text = HTTP.get("http://httpbin.org/status/200").getText() // suspending call
...and a POST
request with HTTP headers and body:
val text = HTTP.post("http://httpbin.org/headers",
headers = mapOf("MyLibraryHeader" to "networkinkt"),
body = "param=value")
.getText()
See the usage section for more examples.
Getting started
The project uses Gradle to manage dependencies.
Common JVM & JS build.gradle
:
allprojects {
repositories {
// ...
maven { url 'https://jitpack.io' }
}
}
dependencies {
// ...
compile "com.egorzh.networkinkt:networkinkt:$networkinkt_version"
}
yourproject-jvm/build.gradle
:
dependencies {
// ...
compile "com.egorzh.networkinkt:networkinkt-jvm:$networkinkt_version"
}
yourproject-js/build.gradle
:
dependencies {
// ...
compile "com.egorzh.networkinkt:networkinkt-js:$networkinkt_version"
}
You can always check which version is up-to-date on the releases page
Usage
How to make a request:
- Obtain an instance of [
HTTPRequest
](networkinkt-common/src/main/kotlin/com/egorzh/networkinkt/HTTPRequest.kt) from an [HTTPClient
](networkinkt-common/src/main/kotlin/com/egorzh/networkinkt/HTTPClient.kt) (the default one isDefaultHTTPClient
or simplyHTTP
) - Send the request and receive an [
HTTPResponse
](networkinkt-common/src/main/kotlin/com/egorzh/networkinkt/HTTPResponse.kt), which encapsulates the response code and text - Use
code
andtext
properties of a response object
import com.egorzh.networkinkt.*
// 1:
val request /* : DefaultHTTPRequest */ = HTTP.get(url = "http://httpbin.org/status/200")
// 2: (from a suspend function or coroutine)
val response /* : DefaultHTTPResponse */ = HTTP.sendRequest(request)
// 3:
val code = response.code
val text = response.text
Customization
You can easily create your own implementations of [HTTPClient
](networkinkt-common/src/main/kotlin/com/egorzh/networkinkt/HTTPClient.kt),
for example, to provide caching or error handling functionality.
[Apache adapter](networkinkt-adapter-apache/src/main/kotlin/com/egorzh/networkinkt/adapters/apache/apache.kt)
is an example of using custom HTTPClient
.