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

Version 2.0.0 #30

Merged
merged 13 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/jest.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ yarn.lock
# Custom
/lib
index.js
test.ts
test.js
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Release 2.0.0

- Rename multiple methods to their full names
- Update the methods the API data is processed
- Move some functions and types to hive-bedrock-data

# Release 1.0.8

- Add the getGameMetadata method
Expand Down
78 changes: 37 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hive Bedrock API

An API wrapper for the Hive Minecraft Bedrock Edition server. Which allows you to get stats for leaderboards, players, cosmetics and total unique player counts.
An API wrapper for the Hive Minecraft Bedrock Edition server. Which allows you to get stats for leaderboards, players, cosmetics, unique player counts, maps and metadata.

## Getting started

Expand All @@ -16,78 +16,65 @@ See [API.md](docs/API.md) for detailed documentation.
### Fetch Player Infomation

```ts
import { getPlayerInfo } from "hive-bedrock-api";
import { getPlayerInformation } from "hive-bedrock-api";

// Returns player, cosmetics, server statistics and profile infomation
const { data, error } = await getPlayerInfo("ucdfiddes");
const { data, error } = await getPlayerInformation("player");
```

### Fetch All-Time Player Statistics

```ts
import { getAllTimeStats, GAME } from "hive-bedrock-api";
import { getAllTimeStatistics, Game } from "hive-bedrock-api";

// Returns all games
const { data, player, error } = await getAllTimeStats("ucdfiddes");

// Returns multiple specific games
const { data, player, error } = await getAllTimeStats("ucdfiddes", [GAME.Deathrun, GAME.TheBridge]);
const { data, error } = await getAllTimeStats("player");

// Returns a single game
const { data, error } = await getAllTimeStats("ucdfiddes", GAME.HideAndSeek);
const { data, error } = await getAllTimeStats("player", Game.HideAndSeek);
```

### Fetch Monthly Player Statistics

```ts
import { getMonthlyStats, GAME } from "hive-bedrock-api";
import { getMonthlyStatistics, Game } from "hive-bedrock-api";

// Returns all games
const { data, error } = await getMonthlyStats("ucdfiddes");

// Returns multiple specific games
const { data, error } = await getMonthlyStats("ucdfiddes", [GAME.Deathrun, GAME.TheBridge]);
const { data, error } = await getMonthlyStats("player");

// Returns a single game
const { data, error } = await getMonthlyStats("ucdfiddes", GAME.BlockDrop);
const { data, error } = await getMonthlyStats("player", Game.BlockDrop);

// Returns a single game in a previous month (can return muliple games)
const { data, error } = await getMonthlyStats("ucdfiddes", GAME.BlockDrop, {
year: 2023,
month: 1, // January
});

// Same as before, but with a Date object
const previousMonth = new Date();
previousMonth.setMonth(0); // January
const { data, error } = await getMonthlyStats("ucdfiddes", GAME.BlockDrop, {
date: previousMonth,
const { data, error } = await getMonthlyStats("player", Game.BlockDrop, {
year: 2023,
month: 1, // January
});
```

### Fetch All-Time Leaderboard

```ts
import { getAllTimeLeaderboard, GAME } from "hive-bedrock-api";
import { getAllTimeLeaderboard, Game } from "hive-bedrock-api";

// Returns a single game
const { data, error } = await getAllTimeLeaderboard(GAME.TreasureWars);
const { data, error } = await getAllTimeLeaderboard(Game.TreasureWars);
```

### Fetch Monthly Leaderboard

```ts
import { getMonthlyLeaderboard, GAME } from "hive-bedrock-api";
import { getMonthlyLeaderboard, Game } from "hive-bedrock-api";

// Returns a single game
const { data, error } = await getMonthlyLeaderboard(GAME.TreasureWars);
const { data, error } = await getMonthlyLeaderboard(Game.TreasureWars);

// Returns a single game from a previous month
const { data, error } = await getMonthlyLeaderboard(GAME.BlockParty, {
year: 2023,
month: 11, // November
amount: 50,
skip: 20, // Sum of skip and amount must be <=100
const { data, error } = await getMonthlyLeaderboard(Game.BlockParty, {
year: 2023,
month: 11, // November
amount: 50,
skip: 20, // Sum of skip and amount must be <=100
});
```

Expand All @@ -103,20 +90,29 @@ const { data, error } = await getGlobalStatistics();
### Fetch Maps

```ts
import { getMaps, GAME } from "hive-bedrock-api";
import { getMaps, Game } from "hive-bedrock-api";

// Returns data for a specific game's currently active maps
const { data, error } = await getMaps(Game.TreasureWars);
```

### Fetch Metadata

```ts
import { getMetadata, Game } from "hive-bedrock-api";

// Returns data for a specific game's currently active maps
const { data, error } = await getMaps(GAME.TreasureWars);
const { data, error } = await getMetadata(Game.TreasureWars);
```

## API Response Changes

Different API responses are edited by the wrapper to provide more data:

- Game responses have a new value "id" showing the parent game
- "first_played" values are converted into a Date object
- A new value for "losses" is provided
- A new value for "kdr" is provided
- "xp" is converted and a "level" is provided
- Game responses have a new value "id" showing the parent game
- A new value for "losses" is provided
- A new value for "kdr" is provided
- "xp" is converted and a "level" is provided
- "total_ratings" for just build is provided

See [API.md](docs/API.md#game-statistics-types) for specific fields and their corresponding types per game.
Loading