The Numbers API gives you REST access to every number tool on Math Tools — number theory checks, numeral system conversions, cardinal/ordinal/currency spelling, base conversion, digits of pi, and more. Every response is JSON.
Advertisement
Every request is made against:
https://math.tools/api/numbers
Every endpoint on this page requires a Sanctum personal access token — there is no free or anonymous tier. Subscribing to one of the plans below issues one automatically; sign in first if you haven't already. Manage or cancel an existing subscription from your subscriptions page. Send your token as a bearer token on every request:
Authorization: Bearer <your-token>
A missing or invalid token returns a 401:
{
"error": { "code": 401, "message": "Unauthorized" }
}
Advertisement
A trivia fact about a number, if one is known — otherwise a fact derived from its number-theory properties (triangle, cube, square, and several classes of prime).
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to look up. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 11,
"fact": "11 is the fifth prime and first palindromic multi-digit number"
}
}
One or more random integers in a range.
| Parameter | Required | Description |
|---|---|---|
| min | No | Lower bound. Default 1. |
| max | No | Upper bound. Default is PHP's own getrandmax(). |
| total | No | How many numbers to return, up to 100 (a higher value is silently capped, not rejected). Default 1. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"numbers": [9, 4, 8, 4, 3],
"min": 1,
"max": 10,
"requested": 5,
"returned": 5
}
}
Today's number of the day and its full set of properties, facts, and number systems — the same daily pick shown on the /numbers/number-of-the-day/ page.
| Parameter | Required | Description |
|---|---|---|
| category | No | Number-of-the-day category shortname. Default "nod". |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"nod": {
"category": {
"name": "Number of the day",
"description": "Number of the day and its properties, facts and anything else you may want to know about.",
"background": ""
},
"numbers": {
"number": "27982",
"uuid": "27982",
"id": "27982",
"names": { "nominal": { "name": "nominal", "description": "Nominal", "value": 27982, "display": "27982" }, "...": "..." },
"bases": { "binary": { "name": "binary", "description": "Base 2 (Binary)", "value": "110110101001110", "display": "110110101001110" }, "...": "..." },
"numerals": { "roman": { "name": "roman", "description": "27982 in Roman numerals", "value": "...", "display": "..." }, "...": "..." },
"general-facts": { "odd": { "name": "odd", "description": "Is 27982 an odd number?", "value": false, "display": "27982 is not an odd number" }, "...": "..." },
"prime-facts": { "prime": { "name": "prime", "description": "Is 27982 a prime number?", "value": false, "display": "27982 is not a prime number" }, "...": "..." },
"recreational": { "reverse": { "name": "reverse", "description": "Number 27982 reversed", "value": "28972", "display": "28972" }, "...": "..." },
"category": "nod"
}
}
}
}
Spells a number out in words. Also available at /api/numbers/words (identical response).
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to spell. |
| lang | No | A locale code (e.g. en_US, fr_FR, de_DE). Default en_US. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 2342,
"language": "en_US",
"result": "two thousand three hundred forty-two",
"cardinal": "two thousand three hundred forty-two"
}
}
The English ordinal form of a number (1st, 2nd, 3rd, ...), with the same thousands-separator formatting as every other spelled-out number on this page. English only — there is no lang parameter.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 2342,
"result": "2,342nd",
"ordinal": "2,342nd"
}
}
Spells a number out as a currency amount.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to spell. |
| lang | No | A locale code. Default en_US. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 1345456654,
"language": "en_US",
"result": "one billion three hundred forty-five million four hundred fifty-six thousand six hundred fifty-four dollars",
"currency": "one billion three hundred forty-five million four hundred fifty-six thousand six hundred fifty-four dollars"
}
}
Converts a base-10 number to a Roman numeral.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 4568367,
"system": "roman",
"result": "DLXVMMMCCCLXVII"
}
}
Converts a base-10 number to a Chinese numeral.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 4568367,
"system": "chinese",
"result": "伍拾萬陸萬捌仟叄佰陸拾柒"
}
}
Converts a base-10 number to an Egyptian numeral.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 4568367,
"system": "egyptian",
"result": "𓁨𓁨𓁨𓁨𓆐𓆐𓆐𓆐𓆐𓂲𓇃𓍤𓎋𓐀"
}
}
Converts a base-10 number to a Babylonian (sexagesimal) numeral — returned as plain comma-separated base-60 digits (e.g. "1,1,1"), not a cuneiform-glyph rendering.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 3661,
"system": "babylonian",
"result": "1,1,1"
}
}
Converts a base-10 number to a Mayan (vigesimal) numeral, using the real Unicode Mayan Numerals block (U+1D2E0-U+1D2F3).
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
The greatest common factor (GCF/GCD) of two or more numbers.
| Parameter | Required | Description |
|---|---|---|
| numbers | Yes | A comma-separated list of integers, e.g. "12,18,24" (up to 10). |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"numbers": [12, 18, 24],
"answer": 6
}
}
The least common multiple (LCM) of two or more numbers.
| Parameter | Required | Description |
|---|---|---|
| numbers | Yes | A comma-separated list of integers, e.g. "4,6" (up to 10). |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"numbers": [4, 6],
"answer": 12
}
}
The first N prime numbers.
| Parameter | Required | Description |
|---|---|---|
| count | No | How many to return, clamped to a configured maximum rather than rejected. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"count": 5,
"numbers": [2, 3, 5, 7, 11]
}
}
The first N composite numbers.
| Parameter | Required | Description |
|---|---|---|
| count | No | How many to return, clamped to a configured maximum rather than rejected. |
The first N palindromic numbers.
| Parameter | Required | Description |
|---|---|---|
| count | No | How many to return, clamped to a configured maximum rather than rejected. |
A slice of the digits of pi.
| Parameter | Required | Description |
|---|---|---|
| from | No | Start offset into the digit string. Default 0. |
| to | No | Length of the slice returned, counted from "from" (not an end position — from=50&to=100 returns 100 digits starting at offset 50, not the digits between 50 and 100). Default 100. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"from": 0,
"to": 100,
"result": "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679",
"number": "pi"
}
}
Converts a number from any base to any other base (2-64).
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert, written in base "from". |
| to | Yes | The target base. |
| from | No | The source base. Default 10. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 88,
"base": { "from": 10, "to": 12 },
"answer": "74"
}
}
Converts a number to binary (base 2). Shorthand for /api/numbers/base?to=2.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
| from | No | The source base. Default 10. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 32,
"base": { "from": 10, "to": 2 },
"answer": "100000"
}
}
Converts a number to octal (base 8). Shorthand for /api/numbers/base?to=8.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
| from | No | The source base. Default 10. |
Converts a number to hexadecimal (base 16). Shorthand for /api/numbers/base?to=16.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to convert. |
| from | No | The source base. Default 10. |
Is this number prime?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": { "number": 17, "answer": true }
}
Is this a composite number (a positive integer with a factor other than 1 and itself)?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this number odd?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this number even?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
The prime factorization of a number, as a list of {factor, times} pairs.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to factorize. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": {
"number": 60,
"answer": [
{ "factor": 2, "times": 2 },
{ "factor": 3, "times": 1 },
{ "factor": 5, "times": 1 }
],
"prime-factors": [
{ "factor": 2, "times": 2 },
{ "factor": 3, "times": 1 },
{ "factor": 5, "times": 1 }
]
}
}
Is this number a palindrome (reads the same forwards and backwards)?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": { "number": 456654, "answer": true }
}
Is this a triangle number?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this a perfect square?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this a perfect cube?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this a perfect number (equal to the sum of its proper divisors)?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this a known Mersenne prime?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this a known Fermat prime?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this a known Fibonacci prime?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this a known Pell prime?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this a known partition prime?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this an abundant number (its proper divisors sum to more than the number itself)?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": { "number": 12, "answer": true }
}
Is this a deficient number (its proper divisors sum to less than the number itself)?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Is this number squarefree (not divisible by any perfect square other than 1 — equivalently, no repeated prime factors)?
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Euler's totient function φ(n): how many integers from 1 to n are coprime with n. Requires n ≥ 1.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to compute φ(n) for. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": { "number": 36, "answer": 12 }
}
How many positive divisors n has, including 1 and n itself. Requires n ≥ 1.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
The sum of all positive divisors of n, including n itself. Requires n ≥ 1.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
The sum of n's proper divisors (every divisor except n itself) — equal to n for a perfect number, greater for an abundant number, less for a deficient one. Requires n ≥ 1.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | The number to check. |
Are a and b coprime (their only common positive divisor is 1)? The only endpoint on this page that takes two numbers instead of one.
| Parameter | Required | Description |
|---|---|---|
| a | Yes | The first number. |
| b | Yes | The second number. |
Example response
{
"success": { "total": 1 },
"copyright": { "copyright": "2019-26 https://math.tools" },
"contents": { "a": 8, "b": 15, "answer": true }
}
Every plan includes full access to every endpoint above; tiers differ only in daily rate limit.
Every call above, live — expand an endpoint, click "Try it out", paste in your token via "Authorize", and send a real request straight from this page. JavaScript is required to see this section. The spec behind it is also available on its own at https://math.tools/api/numbers/openapi.yaml.
Advertisement