Random - Numbers

Free Random Number API Endpoint

The free random number API endpoint draws one integer inside the bounds you asked for and repeats those bounds in the same reply. There is no key to carry, no body to send and no account to open. Ask with no arguments at all and you get a single die: a value from 1 through 6.

  • No API key
  • Plain GET
  • Inclusive bounds
  • Range echoed back

Draw a number

GET/random_number/{from}/{to}

https://aisenseapi.com/services/v1/random_number/1/100

Call the free random number API endpoint

curl https://aisenseapi.com/services/v1/random_number/1/100

{"random_number":59,"range":{"from":1,"to":100}}

That is the whole interface. One path, one JSON object, two fields inside it.

Nothing has to be configured before the first call works. There is no query string, no header and no key, so pasting the URL into a browser address bar counts as a complete test of the integration. The same request runs unchanged from a shell script, a spreadsheet formula or a language model tool call.

Both bounds are inclusive. A call to /random_number/1/100 can return 1 and it can return 100. A hundred-item list therefore maps onto exactly a hundred reachable values, with no off-by-one correction on your side.

Putting the range in the path

The range is optional. It travels as path segments rather than query parameters, and the number of segments you supply decides how it is read.

RequestRange usedNotes
/random_number1 through 6The default is a single die.
/random_number/101 through 10A single segment is the upper bound. The lower bound stays at 1.
/random_number/1/1001 through 100Two segments are from and to.
/random_number/-5/5-5 through 5Negative bounds are accepted on either side of zero.
/random_number/50/5050 through 50A range of one value always returns that value.
curl https://aisenseapi.com/services/v1/random_number

{"random_number":4,"range":{"from":1,"to":6}}
curl https://aisenseapi.com/services/v1/random_number/10

{"random_number":1,"range":{"from":1,"to":10}}
curl https://aisenseapi.com/services/v1/random_number/-5/5

{"random_number":3,"range":{"from":-5,"to":5}}

Keeping the range in the path is what lets the free random number API endpoint stay callable from places that cannot build a query string comfortably, such as a documentation link, a chat message or a hard-coded webhook target.

Response fields

FieldTypeDescription
random_numberintegerThe drawn value, always between range.from and range.to inclusive.
rangeobjectThe bounds the draw was made from, after defaults were filled in and the two bounds were ordered.
range.fromintegerLower bound, inclusive.
range.tointegerUpper bound, inclusive.

Every successful reply from the free random number API endpoint has the same shape. Two top-level keys arrive each time, and range always carries both of its own keys, so a parser can read the object without defensive checks for missing fields.

Nothing is stored on our side. The drawn value is not logged against your request and cannot be fetched again later. Treat the response as the only copy you will ever see.

How the path is read

  1. Count the segments

    Zero segments means 1 through 6. One segment is the upper bound with a lower bound of 1. Two segments are the lower and the upper bound, in that order.

  2. Order the bounds

    Reversed bounds are sorted rather than refused, so a swapped pair still produces a usable draw. Sending /random_number/100/1 answers with {"random_number":7,"range":{"from":1,"to":100}}, and the echoed range is what tells you the swap happened.

  3. Reject what is not a number

    A segment that is not an integer does not quietly fall back to a default. /random_number/abc/10 returns HTTP 404 with {"error":"Unknown endpoint. See https:\/\/www.aisense.no\/free-public-apis for the reference."}, so a broken URL cannot be mistaken for a successful draw.

Width makes no difference to any of this. A request for /random_number/1/1000000 returned {"random_number":626730,"range":{"from":1,"to":1000000}}, read from the same rules as a single die.

Why the range comes back with the number

Echoing the bounds is a deliberate design detail rather than padding. URLs built by string concatenation are easy to get wrong. A variable comes through empty. A template drops a segment. A value arrives as a float and loses its tail on the way into the path.

Because the reply states the bounds it used, a caller can assert on range in the same step where it reads random_number. A wrong range then fails loudly, instead of producing plausible numbers from a range nobody asked for. That is a real failure mode: nothing about the integer 4 looks wrong until you notice it came from a die when you wanted a percentage.

The pattern is worth copying in tests. Assert the range first, use the number second. It costs one line and it turns a silent misconfiguration into a caught one.

Common uses

Sampling for review

Pull a random row index out of a known record count when a person needs to spot check output rather than read all of it.

Retry and load-test jitter

Ask for a delay in milliseconds so retrying clients spread out instead of firing again in lockstep after an outage.

Test fixtures

Vary quantities, ages and prices in smoke tests, so a suite is not silently passing on one hard-coded value.

Decisions an agent cannot bias

A language model asked to pick a number leans on its own priors. An external draw settles tie-breaks, bucket assignment and turn order without that pull.

Demo prize draws

Pick a winner live from a numbered list in a workshop or a stream, with the echoed range visible as proof of the bounds.

Pair it with the neighbours when a fixture needs more than a number. The UUID API endpoint names the record, the random color API endpoint fills the placeholder swatch, and the password API endpoint supplies a throwaway string for a seeded account.

Limits and suitability

This is a number that crossed the network. It is not suitable for anything security sensitive: not tokens, not keys, not passwords, not lottery draws, not anything an adversary benefits from predicting. Use a local cryptographic random source for those, such as the secure random facility built into your language or your operating system.

What the free random number API endpoint is good for is everything where the requirement is variety rather than secrecy. Sampling, test fixtures, jitter, retry backoff, demo draws and giving an autonomous agent a decision it cannot influence all qualify.

The service-wide limit is 5000 requests per IP per 24 hours, shared across the whole catalogue of free public REST APIs. That budget is generous for interactive work and for wiring up a prototype. A tight loop needing thousands of values a second should draw locally and use this call for a seed or a one-off choice instead.

Every endpoint that mints a value out of randomness is collected on the random generator APIs hub, which is the quickest way to see whether a number, an identifier, a color or a password fits the job you have.