Introduction
Chess Now! API & Package Documentation
Welcome to the Chess Now! developer docs. Here you'll find everything you need to use the Chess Now! API.
API Reference
The API Reference has every single available and public HTTP endpoint. It's all auto-generated from the live OpenAPI spec. Meaning that it's always up-to-date with the latest API changes.
While there is public WebSocket events available, they are not documented there. The best documentation for them is in the WebSocket Events and the WebSocket Messages reference made for the @chess-now/api package.
Package Reference
The @chess-now/api npm package is the official TypeScript wrapper. It handles authentication, validation, and WebSocket events for you.
- Client:
ChessNowClientclass with HTTP methods and WebSocket events - Types: All types used in the API
- Errors: Error classes thrown by the client
- WebSocket Messages: Messages the client sends to the server through the ws connection
- WebSocket Events: Events and response payloads received from the server through the ws connection
Quick start
import { ChessNowClient } from "@chess-now/api";
const api = new ChessNowClient();
api.setDefaultToken("main-account-token");
const user = await api.getAccountInfo(); // To use the previously set default token
const match = await api.getMatch(42, "another-account-token"); // To use a specific token
// WebSocket
api.connect();
api.subscribe(); // subscribes you to all events you are authorized to receive with the default token
// or
api.subscribe(["challenge", "match"]); // subscribes you to specific events with the default token
// or
api.subscribe("another-account-token"); // subscribes you to all events you are authorized to receive with "another-account-token"
// or
api.subscribe("another-account-token", ["challenge", "match"]); // subscribes you to specific events with "another-account-token"
api.on("challenge:request", ({ payload }) => {
console.log("New challenge from", payload.challenge.from);
});