https://github.com/rybalkinsd/kohttp
Kotlin DSL http client
https://github.com/rybalkinsd/kohttp
dsl http-client http-dsl kotlin kotlin-dsl networking
Last synced: 2 months ago
JSON representation
Kotlin DSL http client
- Host: GitHub
- URL: https://github.com/rybalkinsd/kohttp
- Owner: rybalkinsd
- License: apache-2.0
- Created: 2018-07-20T22:48:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-22T15:29:29.000Z (almost 5 years ago)
- Last Synced: 2025-01-23T21:31:46.099Z (about 1 year ago)
- Topics: dsl, http-client, http-dsl, kotlin, kotlin-dsl, networking
- Language: Kotlin
- Homepage: https://kohttp.gitbook.io
- Size: 8.96 MB
- Stars: 480
- Watchers: 19
- Forks: 40
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-java - Kohttp
README
# Introduction

[](https://travis-ci.org/rybalkinsd/kohttp) [](https://maven-badges.herokuapp.com/maven-central/io.github.rybalkinsd/kohttp) [](https://codecov.io/gh/rybalkinsd/kohttp) [](https://www.codacy.com/app/yan.brikl/kohttp?utm_source=github.com&utm_medium=referral&utm_content=rybalkinsd/kohttp&utm_campaign=Badge_Grade) [](https://kotlinlang.org) [](https://github.com/KotlinBy/awesome-kotlin) [](https://gitter.im/kohttp/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[](https://github.com/rybalkinsd/kohttp)
Kotlin DSL http client
## Features
🔹 Developers Experience-driven library without verbosity.
🔹 Native way to use http client in Kotlin.
🔹 HTTP [`GET`](gitbook/core/synchronous-calls/get.md)/[`POST`](gitbook/core/synchronous-calls/post.md)/[`PUT`](gitbook/core/synchronous-calls/put.md)/[`HEAD`](gitbook/core/synchronous-calls/head.md)/[`DELETE`](gitbook/core/synchronous-calls/delete.md)/[`PATCH`](gitbook/core/synchronous-calls/patch.md) requests.
🔹 [Asynchronous](gitbook/core/asynchronous-calls/) and [blocking](gitbook/core/synchronous-calls/) requests.
🔹 [Upload files](gitbook/core/synchronous-calls/upload-files.md).
🔹 [Logging](gitbook/core/interceptors.md#logging-interceptor-a-request-logging-interceptor) - easily dump your http requests or convert them to cURL commands.
🔹 Minimal footprint.
## Quick start
```kotlin
// Use String or URL extensions send simple request
val response = "https://my-host.com/users?admin=true".httpGet()
// Parse response with your favorite library
val users = response.toJson()
// Use sync or async methods to send your requests
// Configure method params, headers, cookies and body in a concise way
val notifications: List> = users.forEach { user ->
httpPostAsync {
url("https://my-host.com/friends/push")
param {
"userId" to user[id]
"eventType" to NewFriend
}
header {
"locale" to "en_EN"
cookie {
"user_session" to "toFycNV"
"authToken" to "d2dwa6011w96c93ct3e3493d4a1b5c8751563217409"
}
}
}
}
```
## Samples
- [Android application](/samples/android)
- [Spring Boot application](/samples/spring)
## About kohttp
* [Kotlin weekly](https://mailchi.mp/kotlinweekly/kotlin-weekly-124) mentioned us
* [Android weekly \(CN\)](https://androidweekly.io/android-dev-weekly-issue-208/) mentioned us
* [Kotlin http client. Making kohttp 0.11.0](https://medium.com/@sergei.rybalkin/kotlin-http-client-making-kohttp-0-11-0-af16fb702c86?source=friends_link&sk=e0284c5f8028034eafd433ff5fcfcf47) - medium post
* [Write your Android network as Kotlin DSL](https://medium.com/datadriveninvestor/write-your-android-networking-as-a-kotlin-dsl-330febae503f) - medium post
* [Upload files to Google Drive with Kotlin](https://medium.com/@sergei.rybalkin/upload-file-to-google-drive-with-kotlin-931cec5252c1) - medium post
* [Production Kotlin DSL \(RU + subtitles\) ](https://youtu.be/4m9bS0M0Nww) - Kotlin/Everywhere talk, YouTube
## Installation
### Gradle
Kotlin DSL:
```kotlin
implementation(group = "io.github.rybalkinsd", name = "kohttp", version = "0.12.0")
```
Groovy DSL:
```groovy
implementation 'io.github.rybalkinsd:kohttp:0.12.0'
```
### Maven:
```markup
io.github.rybalkinsd
kohttp
0.12.0
```
## Table of contents
* [Synchronous calls](gitbook/core/synchronous-calls/)
* [GET](gitbook/core/synchronous-calls/get.md)
* [POST](gitbook/core/synchronous-calls/post.md)
* [PUT](gitbook/core/synchronous-calls/put.md)
* [HEAD](gitbook/core/synchronous-calls/head.md)
* [DELETE](gitbook/core/synchronous-calls/delete.md)
* [PATCH](gitbook/core/synchronous-calls/patch.md)
* [Upload files](gitbook/core/synchronous-calls/upload-files.md)
* [Generic requests](gitbook/core/synchronous-calls/generic-requests.md)
* [Asynchronous calls](gitbook/core/asynchronous-calls/)
* [async GET](gitbook/core/asynchronous-calls/async-get.md)
* [async POST](gitbook/core/asynchronous-calls/async-post.md)
* [async PUT](gitbook/core/asynchronous-calls/async-put.md)
* [async HEAD](gitbook/core/asynchronous-calls/async-head.md)
* [async DELETE](gitbook/core/asynchronous-calls/async-delete.md)
* [async PATCH](gitbook/core/asynchronous-calls/async-patch.md)
* [async Upload files](gitbook/core/asynchronous-calls/async-upload-files.md)
* [async Generic requests](gitbook/core/asynchronous-calls/generic-requests.md)
* [Response usage](gitbook/core/response-usage.md)
* [Interceptors](gitbook/core/interceptors.md)
* [Customisation](gitbook/core/customisation.md)
* [Experimental features](gitbook/core/experimental-features.md)
* [Changelog](gitbook/history/changelog.md)