RestClientKot24 is a modern, extensible, and testable REST client library built in Kotlin using OkHttp. It wraps complex HTTP handling into a fluent, configurable API designed for Android and JVM-based apps.
π Version 1.0.2 β Initial public release published via GitHub Packages.
- β
Fluent
Requestobject builder - β Supports GET, POST, PUT, PATCH, DELETE
- β Configurable headers, body (JSON, form, multipart, etc.)
- β
Built-in coroutine support (
suspend fun executeRequestSuspend()) - β
Multiple callback support:
MultiResponseCallback(success, failure, retry, cache)ProgressCallbacks(start/end)
- β
Persistent caching using SQLite via
CacheManager - β Support for Gzip decoding
- β Request debugging: log headers, payloads, response
- β SSL & HostnameVerifier injection
- β Optional in-memory cookie jar support
- β Full unit test suite with JUnit 4, MockK, and AndroidX
You can integrate RestClientKot24 using GitHub Packages.
In your project-level settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/SupunIsharaWK/AndroidRestClientKot24")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
}
}
}
}In your app-level build.gradle.kts:
dependencies {
implementation("com.github.SupunIsharaWK:restclientkot24:1.0.2")
}val request = Request.fromUrl("https://api.example.com", Request.Method.POST).apply {
setBody(JSONObject().put("name", "TestBody"))
addHeader(Header("Authorization", "Bearer token"))
enableResponseCaching(60000)
}
val restClient = RestClient(context)
restClient.setConfig(ConfigBuilder().debugPrintInfo().build())
restClient.executeRequest(request,
multiCallback = object : MultiResponseCallback() {
override fun onSuccess(response: Response) {
Log.d("API", response.responseBody)
}
override fun onFailure(exception: Throwable) {
Log.e("API", "Failed", exception)
}
}
)
The project includes comprehensive unit tests for:
- RestClient
- Request
- Response
- Header, CacheData
- RestClientException, ConnectionException
- CacheManager with DatabaseHelper
Run tests using:
./gradlew test
π¦ restclientkot24/
βββ java/com/supunishara/restclientkot24/
β βββ RestClient.kt
β βββ Request.kt
β βββ Response.kt
β βββ cache/
β βββ configs/
β βββ callbacks/
β βββ exceptions/
β βββ data_classes/
β βββ helpers/
βββ test/ # Unit tests
βββ androidTest/ # Instrumented tests
MIT License. Feel free to fork and contribute.
Pull requests are welcome! Please write unit tests for any new features and ensure all existing tests pass.
Supun Weerasekara π§ Email: supun266@gmail.com π GitHub: SupunIsharaWK