Mathematical Facts at Your Fingertips

A simple REST API serving a curated collection of mathematical facts. Free to use, no auth required.

Base URL: https://nulldev.org/mathfacts/
Interactive Demo
Random Fact
Fetches a random fact. Seen facts are tracked and excluded automatically.
Press the button to get a fact…
Seen IDs:
All Facts
Loads the full list of facts from the database.
    Submit a Fact
    Suggest a new math fact for review. It will be added if approved.
    0 / 500
    Get by ID
    Fetch a specific fact by its numeric ID.
    Enter an ID and press Fetch…
    Search Facts
    Fuzzy search for facts by keyword or phrase.
    Suggest a Revision
    Propose a revision to an existing fact. It will be applied if approved.
    0 / 500
    API Documentation
    GET /api/facts Retrieve all facts
    Description

    Returns the complete list of math facts, including original seed facts and any admin-approved submissions.

    Response
    // 200 OK — array of fact objects ("proof" omitted when not set)
      [
        { "id": 1, "content": "All abelian groups are solvable." },
        { "id": 2, "content": "The only factorial that's also a square is 1.", "proof": "https://example.org/proof.pdf" },
        // …
      ]
    cURL example
    curl https://nulldev.org/mathfacts/api/facts
    GET /api/facts/random Get a random fact
    Description

    Returns a single fact chosen at random. Pass exclude to skip specific fact IDs — useful for cycling through facts without repetition.

    Query Parameters
    ParameterTypeRequiredDescription
    exclude string No Comma-separated list of fact IDs to exclude, e.g. 1,5,12
    Response
    // 200 OK — "proof" included when set
      { "id": 42, "content": "A monad is just a monoid in the category of endofunctors.", "proof": "https://ncatlab.org/nlab/show/monad" }
    
      // 404 — all facts excluded
      { "error": "No facts available" }
    cURL example
    curl "https://nulldev.org/mathfacts/api/facts/random?exclude=1,5,12"
    POST /api/facts/submit Submit a fact for review
    Description

    Submits a new math fact for admin review. Approved facts are added to the public list.

    Request Body
    FieldTypeRequiredDescription
    fact string Yes The math fact to submit. Max 500 characters.
    proof string No Optional http/https URL pointing to a proof or source. Max 500 characters.
    Response
    // 201 Created
      { "message": "Fact submitted for review. Thank you!" }
    
      // 400 Bad Request
      { "error": "'fact' field is required" }
      { "error": "Proof must be a valid URL" }
    cURL example
    curl -X POST https://nulldev.org/mathfacts/api/facts/submit \
        -H "Content-Type: application/json" \
        -d '{"fact": "Every prime greater than 2 is odd.", "proof": "https://example.org/proof.pdf"}'
    GET /api/facts/:id Get a fact by ID
    Description

    Returns a single fact by its numeric ID.

    Path Parameters
    ParameterTypeDescription
    idintegerThe fact's numeric ID
    Response
    // 200 OK — "proof" included when set
      { "id": 42, "content": "A monad is just a monoid in the category of endofunctors.", "proof": "https://ncatlab.org/nlab/show/monad" }
    
      // 404 — not found
      { "error": "Fact not found" }
    cURL example
    curl https://nulldev.org/mathfacts/api/facts/42
    POST /api/facts/:id/revise Submit a revision for an existing fact
    Description

    Proposes a revision to an existing fact. The revision is queued for admin review. If approved, the fact's text is updated.

    Path Parameters
    ParameterTypeDescription
    idintegerThe ID of the fact to revise
    Request Body
    FieldTypeRequiredDescription
    content string Yes The revised text for the fact. Max 500 characters.
    proof string No Optional http/https URL to propose alongside the revision. Max 500 characters.
    Response
    // 201 Created
      { "message": "Revision submitted for review. Thank you!" }
    
      // 400 Bad Request
      { "error": "'content' field is required" }
      { "error": "Proof must be a valid URL" }
    
      // 404 — fact not found
      { "error": "Fact not found" }
    cURL example
    curl -X POST https://nulldev.org/mathfacts/api/facts/42/revise \
        -H "Content-Type: application/json" \
        -d '{"content": "A monad is a monoid in the category of endofunctors.", "proof": "https://ncatlab.org/nlab/show/monad"}'