Skip to content
moxon home

Instance

/health and /logs report on the state of an instance of the API rather than offering a utility. They sit at the root, outside any version.

Both routes are called without a version: https://api.moxon.dev/health, not /v6/health. They count towards the rate limits like any other request. GET / lists them with the other root routes, /logs only once it is configured.

Health

GET /health answers with the state of the instance: its version, how long it has been running and how much memory it uses. It needs no token, which makes it the route to point a monitoring probe at. The Try below sends it to api.moxon.dev when the page opens, so its answer is the live one.

gethttps://api.moxon.dev/health
Try itget/health
Sending…
  • statusstring

    Always ok: an instance that answers is up

  • uptimenumber

    Seconds since the instance started

  • versionstring

    Release of the API the instance runs

  • nodestring

    Version of Node.js

  • memory.rssstring

    Memory held by the process, in MB with one decimal

  • memory.heap_usedstring

    Part of the JavaScript heap in use, in MB

  • memory.heap_totalstring

    Size of the JavaScript heap, in MB

  • connectionsnumber

    Client addresses the rate limiter tracks in the current hour

  • logsnumber

    Entries held in the request log, up to 1,000

Logs

GET /logs returns the last 1,000 requests the instance answered, oldest first. It carries the traffic of every caller, so it is closed by default: it opens only once LOGS_TOKEN is set, and then asks for that value in the X-Logs-Token header.

gethttps://api.moxon.dev/logs
curl -H "X-Logs-Token: YOUR_LOGS_TOKEN" https://api.moxon.dev/logs
Response
[
    {
        "timestamp": 1792779323895,
        "level": "info",
        "method": "POST",
        "url": "/v6/hash",
        "status": 200,
        "duration": "0ms",
        "platform": "Android"
    },
    {
        "timestamp": 1792781601223,
        "level": "info",
        "method": "GET",
        "url": "/health",
        "status": 200,
        "duration": "5ms"
    },
    {
        "timestamp": 1792781714358,
        "level": "warn",
        "method": "GET",
        "url": "/statistics?values",
        "status": 404,
        "duration": "0ms"
    }
]
  • timestampnumber

    When the request was logged, in milliseconds since 1970

  • levelstring

    info below 400, warn from 400 to 499, error from 500

  • methodstring

    HTTP method of the request

  • urlstring

    Path of the request, with the names of its query parameters but not their values

  • statusnumber

    HTTP status of the answer, a 304 recorded as 200

  • durationstring

    Time taken to answer, such as 12ms

  • platformstring

    Operating system of the client, present only when the browser sends Sec-CH-UA-Platform

What Is Not Recorded

  • The values of the query parameters: ?text=secret is recorded as ?text.
  • The private tokens of the chat and tic-tac-toe paths, replaced by [redacted].
  • The bodies of the requests and of the answers.
  • The HEAD requests, and the calls to /logs itself.

The log lives in the memory of the process: it starts empty when the instance restarts.

Error Handling

  • 404Endpoint '/logs' does not exist.LOGS_TOKEN is not set on the instance: the route answers like an unknown path
  • 401Invalid token.The X-Logs-Token header is missing or differs from LOGS_TOKEN

Configuration

An instance you run yourself reads its settings from environment variables. One of them concerns this page:

VariableDefaultEffect
LOGS_TOKENnoneValue expected in the X-Logs-Token header; while it is unset, /logs answers 404

Keep the token secret

Whoever holds LOGS_TOKEN reads which endpoints every client calls, how often and from which system. Use a long random value, and send it only over HTTPS.