This library provides a Kotlin multiplatform API for interacting with Marzban V2ray panel. It supports both JVM and Native targets, allowing you to interact with the Marzban API from your Kotlin applications on various platforms.
- Comprehensive API coverage: This library offers a wide range of API endpoints for managing users, nodes, subscriptions, system settings, and more.
- Multiplatform Support: Works on both JVM and JS targets, allowing you to use it in your Android, Desktop, or Web applications.
- Easy to Use: Simple and intuitive API for interacting with the Marzban panel.
- Type-Safe and Kotlin-First: Leverages Kotlin's type system and idioms to provide a safe and efficient development experience.
Add the library to your project's dependencies.
Create a MarzbanConfig
object with your Marzban panel URL and optional authentication token.
Use the provided API endpoints to interact with the Marzban panel.
import io.github.alisalimik.marzban.MarzbanClient
import io.github.alisalimik.marzban.MarzbanConfig
import io.github.alisalimik.marzban.api.User
import kotlinx.coroutines.runBlocking
fun main() {
// Initialize MarzbanConfig
val marzbanConfig = MarzbanConfig(
url = "https://your-marzban-panel.com",
token = "your-auth-token"
)
val client = MarzbanClient(marzbanConfig)
// Get user information
runBlocking {
val result = client.admin.get()
when (result) {
is ApiResult.Success -> {
println("Admin Information: ${result.data}")
}
is ApiResult.ErrorResponse -> {
println("Error: ${result.response}")
}
is ApiResult.Error -> {
println("Error: ${result.exception.message}")
}
}
}
}