Math Tools Math Tools

Numbers API

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

Endpoint

Every request is made against:

https://math.tools/api/numbers

Authentication

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

Numbers

GET /api/numbers/fact

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"
  }
}

GET /api/numbers/random

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
  }
}

GET /api/numbers/nod

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"
      }
    }
  }
}

Spelling out a number

GET /api/numbers/cardinal

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"
  }
}

GET /api/numbers/ordinal

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"
  }
}

GET /api/numbers/currency

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"
  }
}

Converting to another numeral system

GET /api/numbers/numeral/roman

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"
  }
}

GET /api/numbers/numeral/chinese

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": "伍拾萬陸萬捌仟叄佰陸拾柒"
  }
}

GET /api/numbers/numeral/egyptian

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": "𓁨𓁨𓁨𓁨𓆐𓆐𓆐𓆐𓆐𓂲𓇃𓍤𓎋𓐀"
  }
}

GET /api/numbers/numeral/babylonian

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"
  }
}

GET /api/numbers/numeral/mayan

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.

Greatest common factor / least common multiple

GET /api/numbers/gcf

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
  }
}

GET /api/numbers/lcm

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
  }
}

Lists

GET /api/numbers/list/primes

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]
  }
}

GET /api/numbers/list/composites

The first N composite numbers.

Parameter Required Description
count No How many to return, clamped to a configured maximum rather than rejected.

GET /api/numbers/list/palindromes

The first N palindromic numbers.

Parameter Required Description
count No How many to return, clamped to a configured maximum rather than rejected.

Digits of Pi (π)

GET /api/numbers/pi

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"
  }
}

Converting to another base

GET /api/numbers/base

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"
  }
}

GET /api/numbers/base/binary

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"
  }
}

GET /api/numbers/base/octal

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.

GET /api/numbers/base/hex

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.

Number theory checks

GET /api/numbers/prime/is-prime

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 }
}

GET /api/numbers/is-composite

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.

GET /api/numbers/is-odd

Is this number odd?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-even

Is this number even?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/prime/factors

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 }
    ]
  }
}

GET /api/numbers/is-palindrome

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 }
}

GET /api/numbers/is-triangle

Is this a triangle number?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-square

Is this a perfect square?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-cube

Is this a perfect cube?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-perfect

Is this a perfect number (equal to the sum of its proper divisors)?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-mersenne-prime

Is this a known Mersenne prime?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-fermat-prime

Is this a known Fermat prime?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-fibonacci-prime

Is this a known Fibonacci prime?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-pell-prime

Is this a known Pell prime?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-partition-prime

Is this a known partition prime?

Parameter Required Description
number Yes The number to check.

Number Properties

GET /api/numbers/is-abundant

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 }
}

GET /api/numbers/is-deficient

Is this a deficient number (its proper divisors sum to less than the number itself)?

Parameter Required Description
number Yes The number to check.

GET /api/numbers/is-squarefree

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.

GET /api/numbers/totient

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 }
}

GET /api/numbers/number-of-divisors

How many positive divisors n has, including 1 and n itself. Requires n ≥ 1.

Parameter Required Description
number Yes The number to check.

GET /api/numbers/sum-of-divisors

The sum of all positive divisors of n, including n itself. Requires n ≥ 1.

Parameter Required Description
number Yes The number to check.

GET /api/numbers/aliquot-sum

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.

GET /api/numbers/coprime

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 }
}

Pricing

Every plan includes full access to every endpoint above; tiers differ only in daily rate limit.

Numbers API Starter

$4.99/mo

  • 5,000 requests/day
Subscribe

Numbers API Premium

$14.99/mo

  • 25,000 requests/day
Subscribe

Numbers API Enterprise

$39.99/mo

  • 100,000 requests/day
Subscribe

API Console

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