pubg-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-beta.4 • Public • Published

TypeScript version Node.js version

pubg-client

🚀 A TypeScript wrapper for official PUBG API

👩🏻‍💻 This project was setup by node-typescript-boilerplate

🌟 pubg-client offers:

API Documentation

see Generated document

Installation

To start, just install the pubg-client into your node.js project.

use npm

npm install pubg-client

or yarn

yarn add pubg-client

Import 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';
  1. 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 = false

Usage

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.

Package Sidebar

Install

npm i pubg-client

Weekly Downloads

31

Version

0.0.1-beta.4

License

(MIT OR Apache-2.0)

Unpacked Size

170 kB

Total Files

32

Last publish

Collaborators

  • leichtjoon