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.
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 [ { "id": 1, "content": "All abelian groups are solvable." }, { "id": 2, "content": "The only factorial that's also a square is 1." }, // … ]
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
| Parameter | Type | Required | Description |
|---|---|---|---|
exclude |
string |
No | Comma-separated list of fact IDs to exclude, e.g. 1,5,12 |
Response
// 200 OK { "id": 42, "content": "A monad is just a monoid in the category of endofunctors." } // 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
| Field | Type | Required | Description |
|---|---|---|---|
fact |
string |
Yes | The math fact to submit. Max 500 characters. |
Response
// 201 Created { "message": "Fact submitted for review. Thank you!" } // 400 Bad Request { "error": "'fact' field is required" }
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."}'
GET
/api/facts/:id
Get a fact by ID
Description
Returns a single fact by its numeric ID.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | integer | The fact's numeric ID |
Response
// 200 OK { "id": 42, "content": "A monad is just a monoid in the category of endofunctors." } // 404 — not found { "error": "Fact not found" }
cURL example
curl https://nulldev.org/mathfacts/api/facts/42
GET
/api/facts/search
Fuzzy search facts by text
Description
Searches facts using fuzzy text matching. Returns a best match and a ranked list of any other matching facts.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string |
Yes | The search phrase, e.g. monoidal category |
Response
// 200 OK { "bestMatch": { "id": 7, "content": "A monoid in a monoidal category..." }, "matches": [ { "id": 3, "content": "..." } ] } // 400 — missing parameter { "error": "'text' query parameter is required" } // 404 — no results { "error": "No matching facts found" }
cURL example
curl "https://nulldev.org/mathfacts/api/facts/search?text=monoidal+category"