ApiClient

This library is a wrapper on top of Ktor-Client and FluidJson to facilitate both manual and
automatic
deserialization when working with APIs that are not well formatted.
Works on Android 5.0+ (API level 21+) and Java 8+.
Take for example the following JSON response:
{
"data": {
"user": {
"info": {
"name": "John",
"email"
Manual deserialization
val apiClient = ApiClient(baseUrl = "https://example.com/")
launch {
val user = apiClient.get(
endpoint = "user"
) { json ->
User(
name = json["data"]["user"]["info"]["name"].string,
email = json["data"]["user"]["info"]["email"].string
)
}
user.name
}
val apiClient = ApiClient(baseUrl = "https://example.com/")
launch {
val user = apiClient.put(
endpoint = "user",
body = jsonObjectBody {
obj["name"] = "Doe"
}
) { json ->
User(
name = json["data"]["name"].string,
email = json["data"]["email"].string
)
}
}
Automatic deserialization
Don't forget to apply the Kotlin Serialization plugin
Setup
The latest release is available on Maven Central.
implementation("net.mready.apiclient:core:1.1.1")
License
Copyright 2025 mReady Solutions SRL.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance the License.
You may obtain a copy of the License at
https:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.