GPLNature / pubgapi

Java Wrapper for the PUBG API
GNU General Public License v3.0
8 stars 7 forks source link

PUBG-API

Java wrapper for the PlayerUnknown's Battlegrounds (PUBG) API.

Contact Me

Overview

Note This project is being updated by a high school student. The API can change at anytime.

The project is based on mautini's pubgjava project. I'm using it with permission from him.

README.md is being updated frequently. Please let me know if there is anything else that needs to be added.

There are some things I didn't test In the event of an error, please open an issue and let me know.

This library supports the version 21.3.0 of the PUBG Official API

Maven Dependencies

Maven Central

You can use the pubgapi on the Maven Central.

PUBG-Java

Configuration

You can also provide an application.conf file as the project use typesafe for the configuration

Make reference.conf file in src/main/resource in your project folder as shown below.

{
    apiKey: Your Api key
}

or

public class main {
    public static final void main(String[] args) {
        PubgClient pubgClient = new PubgClient("Api Key");
    }
}

Make API Key

You can get an API key from PUBG Developer Site

API Call Example

PUBG API Documentation To search for player(s) by name(s) :

public class test {
    public static final void main(String[] args) throws PubgClientException {
        // Create a pubg client to make requests to the API
        PubgClient pubgClient = new PubgClient();

        // Get a list of players using their names in-game
        List<Player> playerList = pubgClient.getPlayersByNames(Platform.STEAM, "name", "name2");
        LOGGER.info(playerList.get(0).getPlayerAttributes().getName());

        // Get a list of players using their id in-game
        List<Player> playerList = pubgClient.getPlayersByIds(Platform.STEAM, "id", "id2");
        LOGGER.info(playerList.get(0).getPlayerAttributes().getName());

        // Get a single player using its id
        Player player = pubgClient.getPlayer(Platform.STEAM, "id");
        LOGGER.info(player.getPlayerAttributes().getName());
        LOGGER.info(player.getPlayerRelationships().getMatches().get(0).getId());
        // Player documentation
        // [https://documentation.pubg.com/en/players-endpoint.html]

        // Get a single match using its id
        // [https://documentation.pubg.com/en/matches-endpoint.html]
        MatchResponse match = pubgClient.getMatch(Platform.STEAM, "matchid");
        LOGGER.info(match.getData().getMatchAttributes().getGameMode());

        // Get the telemetry for a match
        // [https://documentation.pubg.com/en/telemetry.html]
        Telemetry telemetry = pubgClient.getTelemetry("Telemetry URL");
        LOGGER.info("{}", telemetry.getTelemetryEvents().size());
    }
}

Rate Limit

The PUBG API has a rate limit (currently it's 10 requests / minute). You can get information about this limit using the methods :

getRateLimitRemaining()
getRateLimit()
getRateLimitReset()

in your PUBG client.

Links

Promotion

Empty