Java library to interface with the PUBG developer API.
The library can be downloaded from maven central.
compile "com.github.softwaresandbox:pubg-api-client:0.1.0"
<dependency>
<groupId>com.github.softwaresandbox</groupId>
<artifactId>pubg-api-client</artifactId>
<version>0.1.0</version>
</dependency>
There are two ways to authenticate to the PUBG developer API, choose the one you find the most convenient:
- Provide the key as an argument in the main constructor of the
PubgApiClient
class - Place the key in the predefined location shown below
If you provide keys via both channels, the key provided in the constructor argument of the
PubgApiClient
class will take precedence.
To retrieve an API key, visit the PUBG developer API website and follow the instructions.
Provide the api key in the constructor of the PubgApiClient
class.
import be.swsb.pubgclient.PubgApiClient;
public class DemoTime {
public static void main(String[] args) {
PubgApiClient pubgApiClient = new PubgApiClient("<api-key>");
// ..
}
}
Place the property development=<api-key>
in a .key/pubgapi.key
file in your user's home directory:
- Execute the following commands:
cd ~ mkdir .key nano .key/pubgapi.key
- Add
development=<api-key>
to the opened file
Create an instance of the PubgApiClient
class and call retrieve the desired information by calling the corresponding methods.
Example usage:
import be.swsb.pubgclient.PubgApiClient;
import be.swsb.pubgclient.PubgApiClientException;
import be.swsb.pubgclient.model.DataList;
import be.swsb.pubgclient.model.player.MatchId;
import be.swsb.pubgclient.model.player.PlayerResponse;
public class DemoTime {
public static void main(String[] args) {
String playerName = "shroud";
PubgApiClient pubgApiClient = new PubgApiClient();
Optional<PlayerResponse> potentialPlayerResponse = pubgApiClient.getPlayerByName(playerName, "pc-na");
DataList<MatchId> matchIds = potentialPlayerResponse
.map(playerResponse -> playerResponse.getPlayer().getPlayerRelationships().getMatchIds())
.orElseThrow(() -> new IllegalArgumentException("Player " + playerName + " not found!"));
System.out.println(matchIds.getData().size() + " epic matches found for player " + playerName);
}
}
- getPlayerByName
- getPlayerById
- getPlayersByName
- getPlayersById
- getMatch
- getPlayerSeasonResponse
- getSeasons
- getSamples
- getTelemetry
- getStatus
Made with ❤️ by Cegeka