PUBG API wrapper written in Kotlin. Requires Java 1.8+.
The releases are pushed to maven central. Include the latest release in your build file.
<dependency>
<groupId>de.kevcodez.pubg</groupId>
<artifactId>pubg-api-wrapper</artifactId>
<version>1.0.0</version>
</dependency>
compile "de.kevcodez.pubg:pubg-api-wrapper:1.0.0"
If you do not have an API key yet, go to the Official API Page and register.
val apiClient = ApiClient("my-key", OkHttpClient())
val match = apiClient.getMatch(Platform.STEAM, "id")
println(match.duration)
You can configure the OkHttp3 Client to register proxies or interceptors.
You can search for players by their ID/name or get information about a specific player.
val playerResponse = apiClient.getPlayers(Platform.STEAM, PlayerFilter(playerNames = listOf("shroud")))
playerResponse.players.forEach {
println(it.id)
}
val playerResponse = apiClient.getPlayer(Platform.STEAM, "<id>")
playerResponse.players.forEach {
println(it.id)
}
You can only search for concrete matches by ID.
val apiClient = ApiClient("my-key", OkHttpClient())
val match = apiClient.getMatch(Platform.STEAM, "id")
println(match.duration)
val apiClient = ApiClient("my-key", OkHttpClient())
val tournaments = apiClient.getTournaments()
val apiClient = ApiClient("my-key", OkHttpClient())
val tournament = apiClient.getTournament("<id>")
val apiClient = ApiClient("my-key", OkHttpClient())
val seasons = apiClient.getSeasons(Platform.STEAM)
val apiClient = ApiClient("my-key", OkHttpClient())
val season = apiClient.getSeason(Platform.STEAM, "account-id", "seasonId")
val status = apiClient.isStatusOk()
println(status) // bool
Check the de.kevcodez.pubg.model.telemetry package for all structures. The telemetry data contains a list of telemetry events.
val telemetryData = apiClient.getTelemetryData("url")
telemetryData.filter { it is PlayerKill }.map { it as PlayerKill }.forEach {
println("Kill at ${it.timestamp}")
println("Killer: ${it.killer}")
println("Victim: ${it.victim}")
}
Prints
Kill at 2018-04-15T15:13:08.912Z Killer: Character(name=sen10za, teamId=44, health=100.0, location=Location(x=415623.0, y=465934.06, z=3607.5898), ranking=0, accountId=account.116f300334ef4310bdbe2e5e51253663) Victim: Character(name=sen10za, teamId=44, health=100.0, location=Location(x=415623.0, y=465934.06, z=3607.5898), ranking=0, accountId=account.116f300334ef4310bdbe2e5e51253663) Kill at 2018-04-15T15:13:55.544Z Killer: Character(name=Muzhik_Raketa, teamId=15, health=100.0, location=Location(x=408639.56, y=456094.12, z=4953.4897), ranking=0, accountId=account.6083879a56a1403c964af920e2b6534e) Victim: Character(name=Muzhik_Raketa, teamId=15, health=100.0, location=Location(x=408639.56, y=456094.12, z=4953.4897), ranking=0, accountId=account.6083879a56a1403c964af920e2b6534e) Kill at 2018-04-15T15:14:53.828Z Killer: Character(name=kavek, teamId=15, health=90.0, location=Location(x=408673.34, y=457988.9, z=4938.0), ranking=0, accountId=account.00044da12eda458d9d493ae7f7cf87db) Victim: Character(name=kavek, teamId=15, health=90.0, location=Location(x=408673.34, y=457988.9, z=4938.0), ranking=0, accountId=account.00044da12eda458d9d493ae7f7cf87db)
The OkHttp3 client is used as HTTP client. During the creation of the API client, you can register your own OkHttpClient and register interceptors, proxies, etc.
For parsing the JSON responses, Jackson FasterXML is used.