Skip to content

A Java/Kotlin wrapper for the Metron API.

License

Notifications You must be signed in to change notification settings

Buried-In-Code/Kalibak

Repository files navigation

Kalibak

Java Version Kotlin Version Status

Gradle Ktlint

Github - Version Github - License Github - Contributors

Github Action - Testing

A Java/Kotlin wrapper for the Metron API.

Getting started

To get started with Kalibak, add the JitPack repository to your build.gradle.kts.

repositories {
    maven("https://jitpack.io")
}

Then, add Kalibak as a dependency.

dependencies {
    implementation("com.github.Buried-In-Code:Kalibak:0.2.3")
}

Usage

import github.buriedincode.kalibak.Metron
import github.buriedincode.kalibak.SQLiteCache
import github.buriedincode.kalibak.AuthenticationException
import github.buriedincode.kalibak.ServiceException

fun main() {
    try {
        val session = Metron("Username", "Password", cache=SQLiteCache())

        // Get all Marvel comics for the week of 2021-06-07
        val thisWeek = session.listIssues(params = mapOf(
            "store_date_range_after" to "2021-06-07", 
            "store_date_range_before" to "2021-06-13", 
            "publisher_name" to "marvel"
        ))
        // Print the results
        thisWeek.forEach {
            println("${it.id} ${it.name}")
        }

        // Retrieve the detail for an individual issue
        val asm68 = session.getIssue(id = 31660)
        // Print the issue Description
        println(asm68.description)

  } catch (ae: AuthenticationException) {
      println("Invalid Metron Username/Password.")
  } catch (se: ServiceException) {
      println("Unsuccessful request: ${se.message}")
  }
}

For a complete list of available query parameters, refer to Metron's API docs.

Socials

Social - Fosstodon
Social - Matrix