Secretlab Api

The SecretLab Api integration provides easy interaction and data handling with the: https://api.scpslgame.com

Usage

All functions for the Secretlab Api are located in the io.github.vxrpenter.secretlab.SecretLab class, and can easily imported with one line:

import io.github.vxrpenter.secretlab.SecretLab

The SecretLab class has to be supplied with the servers api-key and it's account-id before making any requests. This is a short representation of correct SecretLab invocation:

import io.github.vxrpenter.secretlab.SecretLab

val api = "API_KEY"
val accountId = "1235644644"
    
val secretLab = SecretLab(api, accountId)    

Exceptions

All functions that are contained in the SecretLab class throw a CallFailureException inherited from a SecretLabException when a call to the api fails for any reason. You can could catch it like this:

try {
  val secretLab = SecretLab(api, accountId).ip()
} catch (e: Exception) {
  println("An error has occured during an secretlab api call")
  return
}

Examples

Fetching server information through the Secretlab Api. This returns a Server object:

import io.github.vxrpenter.secretlab.SecretLab

fun main() {
    // The server-specific api key can be obtained by typing !api show into the server console
    val api = "API_KEY"
    // The account id can be optained by the same way
    val accountId = "ACCOUNT_ID"
    
    // Get current online players using the SecretLab Api
    val players = SecretLab(api, accountId).serverInfo(false, players = true)?.servers?.get(0)?.players
}

Last updated