An unofficial, robust JavaScript/TypeScript client for the OpenFront API.
npm install openfrontio-api-client
import { getGames, getGameInfo } from "openfrontio-api-client";
const now = new Date();
const yesterday = new Date(now - 86400000).toISOString();
const games = await getGames({
start: yesterday,
end: now.toISOString(),
});
BigInt to safely handle large numeric identifiers without precision loss.The library exposes TypeScript typings for all API responses. These types directly wrap the official game types, adjusting for optional properties where necessary to match the actual API behavior.
OpenFront API responses often contain large integer identifiers. By default, these are serialized as strings in JSON to prevent JavaScript number precision loss (IEEE 754).
This library offers optional BigInt support, allowing you to work with these identifiers as native BigInt primitives for mathematical operations or comparisons, rather than managing them as strings.
Contributions are welcome! Please ensure you have Node.js and npm installed before starting.
Clone the repository and install the dependencies:
git clone github.com/Tidwell/openfrontio-api-client
cd openfrontio-api-client
npm install
The following scripts are available in package.json to assist with development, building, and testing.
To build the package for production (transpiling TypeScript and bundling):
npm run build
This uses pkgroll to output the build artifacts to the dist/ directory.
This project uses Vitest for testing.
To run the standard unit test suite:
npm test
To run the end-to-end tests using the specific E2E configuration:
npm run test:e2e
If the API behavior changes or you need to record new responses for the E2E tests, use the write command:
npm run test:e2e:write
This sets the WRITE_API_RESPONSES environment variable to true during the test run.
To format the codebase using Prettier:
npm run format
To generate the API documentation using TypeDoc:
npm run docs
Distributed under the MIT License. See LICENSE for more information.