Zerochan API client for kotlin
Add the kotlinx-coroutines-core
dependency from JetBrains and the zerochan client dependency to your build.gradle.kts
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_corroutines_version") // required
implementation("io.github.magonxesp:zerochan-client:1.0.0")
}
First you need to have a Zerochan account created, then you need to create a new instance of ZerochanClient
class
and call a method.
Get items by one tag
import io.github.magonxesp.zerochanclient.ZerochanClient
runBlocking {
val client = ZerochanClient("<your app name>", System.getenv("ZEROCHAN_USERNAME"))
val items = client.getByTag("Non non biyori") {
// you can limit the results and
page(1)
limit(15)
// sort by id
sort(Sort.ID)
// and more options, autocomplete with your IDE
}
items.forEach { println(it.source) }
}
Get items by multiple tag
import io.github.magonxesp.zerochanclient.ZerochanClient
runBlocking {
val client = ZerochanClient("<your app name>", System.getenv("ZEROCHAN_USERNAME"))
val items = client.getByTag(arrayOf("Non non biyori", "Genshin impact")) {
// you can limit the results and
page(1)
limit(15)
// sort by id
sort(Sort.ID)
// and more options, autocomplete with your IDE
}
items.forEach { println(it.source) }
}
Get a single item by id
import io.github.magonxesp.zerochanclient.ZerochanClient
runBlocking {
val client = ZerochanClient("<your app name>", System.getenv("ZEROCHAN_USERNAME"))
val singleItem = client.getById(4114336)
println(singleItem.large) // show the item image with large size
}