numbers.dk

Public JSON API

Numbers API

Everything you wanted to know about a number.

GET https://numbers.dk/api/42
{
    "number": 42,
    "formatted": "42",
    "previous": {
        "number": 41,
        "url": "https://numbers.dk/api/41"
    },
    "next": {
        "number": 43,
        "url": "https://numbers.dk/api/43"
    },
    "absolute": 42,
    "sign": 1,
    "even": true,
    "odd": false,
    "prime": false,
    "positive": true,
    "negative": false,
    "zero": false,
    "square": false,
    "cube": false,
    "fibonacci": false,
    "triangular": false,
    "palindrome": false,
    "digit_count": 2,
    "digit_sum": 6,
    "reversed": 24,
    "divisors": [
        1,
        2,
        3,
        6,
        7,
        14,
        21,
        42
    ],
    "divisor_count": 8,
    "binary": "101010",
    "octal": "52",
    "hex": "2A",
    "roman": "XLII",
    "languages": {
        "english": "forty-two",
        "danish": "toogfyrre"
    },
    "scientific": "4.2 × 10¹",
    "factorial": null
}

A tiny API for integers

Request any integer and get back useful facts and representations — primes, divisors, bases, Roman numerals, English words, and more. Responses are deterministic, cached, and calculated on demand. No API key. No signup.

Try it

Enter an integer and inspect the live JSON response.

Range: -1,000,000,000 … 1,000,000,000

GET /api/42
Response
Loading…

Endpoint documentation

One resource. A few helpers. All responses are JSON.

GET /api/{number}

Return properties and representations for a single integer. Optional query parameter pretty=1 enables indented JSON.

https://numbers.dk/api/42?pretty=1

GET /api/random

Return data for a random integer within the supported range.

https://numbers.dk/api/random

GET /api

Basic API metadata: name, version, and endpoint pointers.

{
  "name": "Numbers API",
  "version": "1.0",
  "endpoint": "/api/{number}"
}

Response fields

Every successful number response includes the following fields.

FieldTypeNotes
numberintegerThe requested integer
formattedstringThousands-separated display form
previous / nextobject|nullAdjacent integer + API url; null at range edges
absoluteintegerAbsolute value
signinteger-1, 0, or 1
even / oddbooleanParity flags
primebooleanTrue for primes greater than 1
positive / negative / zerobooleanSign classification
square / cubebooleanPerfect power checks
fibonacci / triangularbooleanSequence membership (non-negative)
palindromebooleanDigit palindrome using absolute value
digit_count / digit_sumintegerDecimal digit metrics
reversedintegerDigits reversed, sign preserved
divisorsarrayPositive divisors of |n|; empty for 0
divisor_countintegerLength of divisors
binary / octal / hexstringBase representations; negatives prefixed with -
romanstring|nullSupported for 1–3999; otherwise null
languagesobjectWord forms: english, danish
scientificstringScientific notation with Unicode exponents
factorialinteger|nullProvided for 0–20; otherwise null

HTTP status codes

  • 200— Successful response
  • 422— Invalid or out-of-range number
  • 404— Unknown endpoint
  • 429— Rate limit exceeded
{
  "error": {
    "code": "NUMBER_OUT_OF_RANGE",
    "message": "The number must be between -1000000000 and 1000000000."
  }
}

Rate limits

Anonymous clients are limited to 120 requests per minute per IP. Responses include standard headers:

  • X-RateLimit-Limit
  • X-RateLimit-Remaining
  • Retry-After (on 429)

CORS is enabled for public GET requests, so you can call the API from browser apps.

Code examples

Copy a ready-made request in your language of choice.

cURL

curl -s https://numbers.dk/api/42

JavaScript

const res = await fetch('https://numbers.dk/api/42');
const data = await res.json();
console.log(data);

PHP

$json = file_get_contents('https://numbers.dk/api/42');
$data = json_decode($json, true);
print_r($data);

Python

import urllib.request, json

with urllib.request.urlopen('https://numbers.dk/api/42') as r:
    data = json.load(r)
print(data)

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://numbers.dk/api/42")).GET().build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());