Multiplatform Kotlin library to work with the Curse (CurseForge) API using Ktor.
- Add the lib to your project's dependencies by copying one of the following lines depending on the platform:
- Groovy (replace
$cursekt_version
with the version you want):
implementation "net.pearx.cursekt:cursekt-metadata:$cursekt_version" // for Common
// or
implementation "net.pearx.cursekt:cursekt-jvm:$cursekt_version" // for JVM
// or
implementation "net.pearx.cursekt:cursekt-js:$cursekt_version" // for JS
- Kotlin (replace
$cursektVersion
with the version you want):
implementation("net.pearx.cursekt:cursekt-metadata:$cursektVersion") // for Common
// or
implementation("net.pearx.cursekt:cursekt-jvm:$cursektVersion") // for JVM
// or
implementation("net.pearx.cursekt:cursekt-js:$cursektVersion") // for JS
-
CurseKT uses coroutines! Ensure you've added kotlinx.coroutines as a dependency: https://github.com/Kotlin/kotlinx.coroutines#using-in-your-projects.
-
Don't forget to declare the JCenter Maven repository to your build script (required by Ktor):
repositories {
jcenter()
}
- Use the library and have fun!
You can get a brief example of how to work with the library at the Example Application section. To get all the methods available in CurseKT, take a look at the CurseClient.kt file.
This application will search for Minecraft 1.15.2 mods matching the "just enough items" filter, sort by download count and print them.
import kotlinx.coroutines.runBlocking
import net.pearx.cursekt.client.CurseClient
fun main() {
runBlocking {
val curse = CurseClient() // create a new CurseClient instance
val minecraftGame = curse.getGames(supportsAddons = true).first { it.slug == "minecraft" } // get Minecraft game
val modsSection = minecraftGame.categorySections.first { it.name == "Mods" } // get Minecraft Mods section
val addons = curse.searchAddons(gameId = minecraftGame.id, sectionId = modsSection.gameCategoryId, gameVersion = "1.15.2", searchFilter = "just enough items") // search for Minecraft 1.15.2 mods matching the "just enough items" filter
val addonsSorted = addons.sortedByDescending { it.downloadCount } // sort search results by download count
println(addonsSorted.joinToString(System.lineSeparator()) { "${it.name} - ${it.downloadCount.toInt()}" }) // print sorted search results
}
}