npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

mkcentral-api

v2.0.0

Published

API wrapper for Mario Kart Central

Downloads

9

Readme

mkcentral-api

TypeScript/Node.js SDK for Mario Kart Central’s public API.

Public entry points: Player, Players, Team, Teams. Filters: PlayerFilter, TeamFilter. Registries: CountryCode, Game, GameMode, Language, Platform.

Installation

Requires Node.js 16+.

npm install mkcentral-api

Quick start

CommonJS:

const { Player, Players, Team, Teams } = require('mkcentral-api');

// Get a single player by id
(async () => {
  const player = await Player.Get(1655);
  console.log(player.Name);

  // Search players by name
  const results = await Players.Get('Rollo');
  console.log(`Found ${results.Count} players`);

  // Get a team by id
  const team = await Team.Get(35);
  console.log(`${team.Name} [${team.Tag}]`);
})();

ESM/TypeScript:

import { Player, Players, Team, Teams } from 'mkcentral-api';

const p = await Player.Get(1655);
console.log(p.Name);

Beginner-friendly examples

These mirror what’s in src/examples.ts and use the current API surface.

Players

  • Search by name:
const players = await Players.Get('Rollo');
console.log(`Found ${players.Count}`);
if (players.length) {
  console.log(`${players[0].Name} (ID: ${players[0].Id})`);
}
  • Get by id and inspect details:
const player = await Player.Get(1655);
console.log(player.Name);
console.log(player.CountryCode);
console.log(player.Discord?.Username);
console.log(`#FCs: ${player.FriendCodes.length}`);
console.log(`#Rosters: ${player.Rosters.length}`);
  • Filter with PlayerFilter (or new Players.Filter(...)):
const filter = new Players.Filter({
  Country: Players.CountryCode.Germany,
  NameOrFC: 'Alex',
  Page: 1,
});
const filtered = await Players.Get(filter);
console.log(`Total matching players: ${filtered.PlayerCount}`);
console.log(`Pages: ${filtered.PageCount}`);
  • Hydrate a partial player to full using Load():
const list = await Players.Get('Alex');
if (list.length) {
  const partial = list[0];
  await partial.Load();
  console.log(`Loaded ${partial.Rosters.length} rosters`);
}
  • Pagination helpers on the list:
const page1 = await Players.Get(new Players.Filter({ NameOrFC: 'Anna', Page: 1 }));
console.log(`Page 1 count: ${page1.length}`);
if (await page1.LoadNextPage()) {
  console.log(`Page 2 count: ${page1.length}`);
}

// Load everything
const all = await Players.Get(new Players.Filter({ Country: Players.CountryCode.Chile }));
await all.LoadAllPages();
console.log(`Total Chilean players: ${all.length}`);

Teams

  • Search by name/tag and get by id:
const teamsByName = await Teams.Get('HD');
console.log(`Found ${teamsByName.Count} teams`);

const team = await Team.Get(35);
console.log(`${team.Name} [${team.Tag}]`);
console.log(`Managers: ${team.Managers.length}`);
console.log(`#Rosters: ${team.Rosters.length}`);
  • Filter with TeamFilter (or new Teams.Filter(...)):
const tf = new Teams.Filter({
  NameOrTag: 'Racing',
  Game: Teams.Game.MK8dx,
  Mode: Teams.GameMode.CC150,
  Language: Teams.Language.EnglishSimplified,
  Page: 1,
});
const filteredTeams = await Teams.Get(tf);
console.log(`Total teams: ${filteredTeams.TeamCount}`);
console.log(`Page 1 shows: ${filteredTeams.Count}`);
  • Hydrate team and inspect roster players:
const partialTeams = await Teams.Get('Test');
if (partialTeams.length) {
  const t = partialTeams[0];
  await t.Load();
  for (const r of t.Rosters) {
    console.log(`${r.Game?.DisplayName} ${r.Mode} — players: ${r.Players?.length ?? 0}`);
  }
}
  • Pagination and load-all helpers:
const teamPages = await Teams.Get(new Teams.Filter({ Page: 1 }));
console.log(`Pages: ${teamPages.PageCount}`);
if (await teamPages.LoadNextPage()) {
  console.log(`Page 2 teams: ${teamPages.Count}`);
}

const all200cc = await Teams.Get(new Teams.Filter({ Game: Teams.Game.MK8dx, Mode: Teams.GameMode.CC200 }));
await all200cc.LoadAllPages();
console.log(`Total 200cc teams: ${all200cc.Count}`);

Error handling

Network and HTTP issues surface as typed errors. Catch them as needed:

try {
  await Player.Get(99999999);
} catch (err) {
  console.log('Failed to fetch player:', (err as Error).message);
}

Development (repo)

  • Build: npm run build (emits to dist/)
  • Test: npm test (hits live MKC endpoints; needs internet)
  • Lint/format: npm run lint, npm run format

Run the bundled examples locally:

npm install
npm run build
node dist/examples.js

Notes

  • Players.Get(filter|string) and Teams.Get(filter|string) build API URLs and set sensible defaults (detailed results, page=1, etc.).
  • Load() on Player/Team preserves object identity and fills in full details.
  • Remote asset paths are normalized to absolute HTTPS URLs when applicable.