@leventhan/battlemetrics-ts
v1.0.0
Published
A TypeScript-first BattleMetrics API client with object-only endpoint methods.
Maintainers
Readme
@leventhan/battlemetrics-ts
A TypeScript-first BattleMetrics API client with object-only endpoint methods and typed JSON:API request and response documents.
Install
npm install @leventhan/battlemetrics-tsQuick Start
import { BattleMetrics } from "@leventhan/battlemetrics-ts";
const bm = new BattleMetrics({ token: process.env.BM_TOKEN });
const server = await bm.servers.info({
serverId: "10281405",
query: {
include: ["player"],
fields: { server: ["name", "ip", "port"] }
}
});
console.log(server.data.attributes?.name);API Shape
Every endpoint accepts a single object. Required path parameters and request bodies are required TypeScript properties, and query options are typed.
await bm.players.matchIdentifiers({
body: BattleMetrics.createIdentifierDocument("steamID", "76561198110941835")
});The package intentionally does not use Zod. Type safety is enforced with TypeScript and tsd; runtime behavior stays tolerant of BattleMetrics response changes.
Low-level Requests
Each namespace includes request for new or undocumented paths.
const result = await bm.servers.request("GET", "/servers", {
query: {
filter: { search: "rust" },
page: { size: 5 }
}
});Scripts
npm run typecheck
npm run test:unit
npm run build
npm run test:types
npm test