0.0.1-beta.4 ⢠Published 5 years ago
pubg-client v0.0.1-beta.4
pubg-client
š A TypeScript wrapper for official PUBG API
š©š»āš» This project was setup by node-typescript-boilerplate
š pubg-client offers:
API Documentation
Installation
To start, just install the pubg-client into your node.js project.
use npm
npm install pubg-clientor yarn
yarn add pubg-clientImport module
You can import pubg-client module in two ways:
1. import the module and set api key
import api from 'pubg-client';
// or const api = require('pubg-client').default;
api.key = 'your_api_key';- create new instance
import { createInstance } from 'pubg-client';
// or const { createInstance } = require('pubg-client');
const api = new createInstance('your_api_key');Set environment
You can change API host and gzip compression option
// change API host to your custom API server
api.prefix = 'http://example.com'
// enable gzip compression on response
api.gzip = true
// disable gzip compression on response (default value: false)
api.gzip = falseUsage
Basic API example
Ex1. Search player 'leichtjoon' in 'steam' region
const res = await api.players('steam', 'leichtjoon')Ex2. Search one player by player's unique id
const res = await api.player('steam', 'account.183bc4b2c3404935baf3d56fb434b393')Ex3. Get all available seasons in 'xbox' region
const res = await api.seasons('xbox')
// api.seasons('kakao')
// api.seasons('console')
// api.seasons('steam')Ex4. Get player's lifetime stat
const res = await api.lifetime('steam', 'account.183bc4b2c3404935baf3d56fb434b393')Ex5. Get season stat of player
const res = await api.stat('steam', 'account.183bc4b2c3404935baf3d56fb434b393', 'division.bro.official.pc-2018-08')Ex6. Get leaderboard of season
const res = await api.leaderboards('pc-krjp', 'division.bro.official.pc-2018-08', 'solo')Functional API example
$platform and $user properties provide API calls through functional interfaces. See Documentation
Ex1. Search player 'leichtjoon' in 'steam' region
const res = await api.$platform('steam').players('leichtjoon')Ex2. Get match data
const res = await api.$platform('steam').match('f7d6e66d-6fab-42ee-82cd-65650251ca29')Ex3. Search one player by player's unique id
const res = await api.$platform('steam').$user('account.183bc4b2c3404935baf3d56fb434b393').json()Ex4. Get player's lifetime stat
const res = await api.$platform('steam').$user('account.183bc4b2c3404935baf3d56fb434b393').lifetime()Ex5. Get season stat of player
const res = await api.$platform('steam').$user('account.183bc4b2c3404935baf3d56fb434b393').stat('division.bro.official.pc-2018-08')Parameters
The range of values of the platform and region parameters follows the official PUBG document. See Making Requests
Development
šš½ pubg-client library was developed by using:
- TypeScript 4.0
- ESLint with some initial rules recommendation
- Jest for fast unit testing and code coverage
- Type definitions for Node.js and Jest
- Prettier to enforce consistent code style
- Simple example of TypeScript code and unit test
- .editorconfig for consistent file format
License
Licensed under the APLv2. See the LICENSE file for details.