Skip to content

Multiplatform Kotlin library to work with the Curse (CurseForge) API using Ktor.

License

Notifications You must be signed in to change notification settings

pearxteam/cursekt

Repository files navigation

CurseKT Maven Central Maven Central Maven Central

License Discord Release Build Status Develop Build Status

Multiplatform Kotlin library to work with the Curse (CurseForge) API using Ktor.

Setup

  1. 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
  1. CurseKT uses coroutines! Ensure you've added kotlinx.coroutines as a dependency: https://github.com/Kotlin/kotlinx.coroutines#using-in-your-projects.

  2. Don't forget to declare the JCenter Maven repository to your build script (required by Ktor):

repositories {
    jcenter()
}
  1. Use the library and have fun!

How to Use the Library

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.

Example Application

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
    }
}

About

Multiplatform Kotlin library to work with the Curse (CurseForge) API using Ktor.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages