Skip to content
moxon home

Getting Started

Welcome to the moxon API v6 documentation. This API provides a comprehensive collection of utility endpoints for developers.

Base URL

All API requests should be made to:

https://api.moxon.dev/v6

Quick Example

Try itget/v6/infos
Sending…

Using the npm package

The HTTP API available at https://api.moxon.dev needs no package: a plain request is enough. The @moxon/api npm package is useful to call the same utilities straight from Node.js, without going through the network.

npm install @moxon/api

The package requires Node.js 22.12 or newer. It ships as ESM, but remains usable from CommonJS: Node has been able to require() an ESM module since 22.12, which is why that is the floor.

import { evaluate } from '@moxon/api'; // ESM
const { evaluate } = require('@moxon/api'); // CommonJS

Available imports

The root import always resolves to the latest version. Use a subpath (/v4 to /v6) to pin a specific one.

ImportContents
@moxon/apiLatest version, equivalent to @moxon/api/v6
@moxon/api/v4The v4 functions
@moxon/api/v5The v5 functions
@moxon/api/v6The v6 functions
@moxon/api/serverThe API's HTTP server, with all its versions, started on import
@moxon/api/manifestDescription of the endpoints as data (experimental)

The server loads its plugins asynchronously: from CommonJS, it must be imported rather than required.

await import('@moxon/api/server'); // from CommonJS

Usage example

// Latest version, equivalent to '@moxon/api/v6'
import { color, evaluate, username } from '@moxon/api';

// Or a specific version
import { color as colorV4 } from '@moxon/api/v4';

// Evaluate a math expression
const expr = evaluate('sin(pi / 2) + sqrt(4)', 5);
console.log(expr.result); // 3
console.log(expr.expression); // 'sin(pi / 2) + sqrt(4)'

// Generate a random color, converted to every common notation
const c = color();
console.log(c.hex, c.rgb, c.hsl, c.hsv, c.hwb, c.cmyk);

// Generate a random username
const user = username();
console.log(user.username);

Tip

To describe the endpoints as data (method, path, parameters, example), see the Manifest, an experimental export of the package. If your project still uses the former package name, the migration guide explains the rename.

Rate Limiting

Some endpoints have rate limiting to prevent abuse. If you exceed the rate limit, you'll receive an error response:

{
    "message": "Too Many Requests",
    "error": "You have exceeded the limit of 2000 requests per hour.",
    "status": 429
}

Depending on the endpoint and limiter, the error message may also be:

  • Global rate limit exceeded.
  • Rate limit exceeded. Try again in X seconds.

Error Handling

Changed in 6.0.0

status is now a number. It used to be a string ("400"), it is now 400. A client comparing it to a string will stop matching.

All endpoints return consistent error responses:

{
    "message": "Bad Request",
    "error": "Description of the error",
    "status": 400
}

Requesting an endpoint that doesn't exist also returns a structured JSON error:

{
    "message": "Not Found",
    "error": "Endpoint '/v6/doesnotexist' does not exist.",
    "status": 404
}

Other Versions

New in 6.1.0

Every documentation page has one address per version and language: /v6/hash for the Hash page in English, /fr/v6/hash in French, /v5/hash for v5. Old addresses such as /v6/en/hash or /v6/fr/hash redirect automatically to the new ones, anchors included.