Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Structure Overhaul #4

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
PUBG_API_KEY: ${{secrets.PUBG_API_KEY}}

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: yarn install --frozen-lock

- name: Build
run: yarn build

test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: yarn install --frozen-lock

- name: Build
run: yarn build:prod

- name: Test
run: yarn test
123 changes: 80 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
- ❗ Stirctly typed
- ⚡ Request batching
- ✍️ Verbose documentation
- 🪝 Hooks support
- ⚠️ Error handling

## 🚀 Install
Expand Down Expand Up @@ -58,73 +57,111 @@ You'll first need to [sign up on the PUBG developer API site](https://developer.

With an account created, you can [create a new developer application](https://developer.playbattlegrounds.com/apps/new?locale=en) that will provide you with your API key.

### Make something!
### Basic

Here's a few small examples of what you can do with this library
As a basic example here's how to fetch player data:

```typescript
import { Client, Shard } from "pubg.ts";
import { getPlayer } from "pubg.ts";

const client = new Client({
apiKey: "your_key_goes_here",
shard: Shard.STEAM, // Optional (Default: Steam)
const { data, error } = await getPlayer({
value: "YOUR_NAME_HERE",
});

// Get a single or multiple player(s) using their name or ID
const { data: player } = await api.getPlayer({
skipFailed: false, // Optional: fail silently (Default: false)
value: "single_name_or_id_or_array_of_such",
});
console.log({ data, error });
```

## 📕 Documentation

Here is a breakdown of all modules that the package provides & how to use them:

<details>
<summary>Match</summary>

## Match

Get a match from a specificed match id.

---

// Fetch a data from a single match
const { data: match } = await client.getMatch({
Get started using the module function:

```typescript
import { getMatch } from "pubg.ts";

const { data, error } = await getMatch({
apiKey: "...",
id: "a036c694-be29-4dea-833d-b6ff84323de7",
});
```

// Get the current active season
const { data: activeSeason } = await client.getSeason();
Or using the client:

```typescript
import { Client } from "pubg.ts";

const client = new Client({
apiKey: "...",
});

// Get season stats for a specific player
const { data: playerSeason } = await client.getPlayerSeason({
player: player.id,
season: activeSeason,
ranked: false, // Optionally gets stats for ranked gamemodes
const { data, error } = await getMatch({
id: "a036c694-be29-4dea-833d-b6ff84323de7",
});
```

Using individual fetchers
</details>

<details>
<summary>Player</summary>

## Player

Get player(s) by a given name(s) or id(s).

---

Get started using the module function:

```typescript
import { Shard, getPlayer, getMatch, getSeason } from "pubg.ts";

// Get a single or multiple player(s) using their name or ID
const { data: player } = await getPlayer({
apiKey: "your_key_goes_here",
shard: Shard.STEAM, // Optional: for all hooks (Default: Steam)
skipFailed: false, // Optional: fail silently (Default: false)
value: "single_name_or_id_or_array_of_such",
import { getPlayer } from "pubg.ts";

// Using a player name
const { data, error } = await getPlayer({
apiKey: "...",
value: "YOUR_NAME_HERE",
});

// Fetch a data from a single match
const { data: match } = await getMatch({
apiKey: "your_key_goes_here",
id: "a036c694-be29-4dea-833d-b6ff84323de7",
// Using a player ID
const { data, error } = await getPlayer({
apiKey: "...",
id: true,
value: "account.ABC123",
});
```

Or using the client:

```typescript
import { Client } from "pubg.ts";

// Get the current active season
const { data: activeSeason } = await getSeason({
apiKey: "your_key_goes_here",
const client = new Client({
apiKey: "...",
});

// Using a player name
const { data, error } = await getPlayer({
value: "YOUR_NAME_HERE",
});

// Get season stats for a specific player
const { data: playerSeason } = await getPlayerSeason({
apiKey: "your_key_goes_here",
player: player.id,
season: activeSeason,
ranked: false, // Optionally gets stats for ranked gamemodes
// Using a player ID
const { data, error } = await getPlayer({
id: true,
value: "account.ABC123",
});
```

</details>

## ❤️ Credits

- [ickerio](https://github.com/ickerio): This project was heavily inspired by [pubg.js](https://github.com/ickerio/pubg.js)
13 changes: 0 additions & 13 deletions example/index.html

This file was deleted.

Binary file removed example/public/favicon.png
Binary file not shown.
123 changes: 0 additions & 123 deletions example/src/App.vue

This file was deleted.

37 changes: 0 additions & 37 deletions example/src/components/Button.vue

This file was deleted.

Loading