Skip to content

Getting Started ​

Install ​

bash
npm install @kyizl/craftify

Create a client ​

ts
import { PikaNetworkClient } from '@kyizl/craftify';

const pika = new PikaNetworkClient();

No configuration is required. PikaNetworkClient ships with sensible defaults for rate limiting, retries, and caching. See the Rate Limiting guide before overriding any of them.

Fetch a leaderboard ​

ts
import { Gamemode, Stat } from '@kyizl/craftify';

const leaderboard = await pika.getLeaderboard({
  gamemode: Gamemode.BedWars,
  stat: Stat.BedWars.Kills,
  limit: 10,
});

for (const entry of leaderboard.entries) {
  console.log(entry.place, entry.id, entry.value);
}

Gamemode and Stat are ergonomic, autocomplete-friendly aliases for plain strings. See Ergonomic Constants. Raw strings work everywhere too.

Fetch a player's stats ​

ts
const stats = await pika.getProfileStats({
  username: 'divena',
  gamemode: Gamemode.BedWars,
});

const finalKills = stats.StatKey.BedWars.FinalKills;

Fetch a profile ​

ts
const profile = await pika.getProfile('divena');

Batch requests ​

Every list-returning method has a batched counterpart, bounded by concurrency and rate-limited underneath. See Batch Requests for the full contract.

ts
const profiles = await pika.getProfiles(['divena', 'Notch', 'jeb_']);

What's tracked ​

This build's generated enums currently cover 14 gamemodes and 105 distinct stats, pulled live from src/networks/pika-network/enums.ts at doc-build time, so this number never goes stale. See Gamemodes and Enums for how that's generated.

Handling errors ​

ts
import { NetworkBadRequestError, NetworkRateLimitError } from '@kyizl/craftify';

try {
  await pika.getLeaderboard({
    gamemode: 'opprison',
    stat: 'PRISON_TOKEN_BALANCE',
    mode: 'SOLO',
  });
} catch (error) {
  if (error instanceof NetworkBadRequestError) {
  }
}

See the full error hierarchy in the API Reference.

Distributed under the MIT License.