Generator · Generic data

Draw a member from a weighted enumeration

Endpoint GET /v1/enum

What it covers

Returns a random member drawn from a user-supplied weighted enumeration — a JSON map of `member → relative weight` in the `choices` param. Weights need not sum to 1; they are normalized by their total, so `{"a":1,"b":4}` and `{"a":0.2,"b":0.8}` are the same distribution. `choices` must be sent as URL-encoded JSON. An empty map, or weights that are all zero, negative, or non-finite, is a 400. `edge=true` inverts the distribution (Pro), `extreme=true` returns a hostile-encoded value (Pro), and `invalid=true` returns a value not in `choices` with probability 0.

Draws one member from a set **you** supply, with a distribution **you** control — for categorical columns no registry issues: status, tier, plan, payment method, a country skewed to your user base. The response echoes the chosen member’s normalized `probability`.

The `choices` parameter is URL-encoded JSON and accepts two shapes. Pass a **bare array** of members for an equal split, or a **weighted map** of `member → relative weight` to skew it. Weights are *relative* — they need not sum to 1, so `{"a":1,"b":4}` and `{"a":0.2,"b":0.8}` describe the same distribution, and you can think in plain counts (1-in-20) instead of fractions.

Gotchas

  • Percent-encode the JSON in a real request — a browser address bar tolerates the raw brackets shown above, but a strict HTTP client needs `%7B…%7D` / `%5B…%5D`.
  • A bare array means equal weights; you do NOT need to write `{"a":1,"b":1,"c":1}`. Reach for the map only when the split is uneven.
  • An empty set, or a map whose weights are all zero / negative / non-finite, is a 400 — there is no well-defined draw.

Parameters

ParameterTypeDescription
choicesstringURL-encoded JSON — either a map of member → relative weight, e.g. {"gold":1,"silver":4,"bronze":15}, or a bare array of members for an equal distribution, e.g. ["gold","silver","bronze"]. Weighted values are normalized by their sum.
countinteger1–1000Number of records to return, 1–1000 (your plan may lower this). Omitted returns a single record; set it for a batch.
edgebooleanInvert the distribution: the least-probable member becomes the most likely (a zero-weight member rises to the top). Requires the Pro plan or above.
extremebooleanReturn the drawn member wrapped in a hostile encoding (untrimmed whitespace, invisible/zero-width characters, BOM, bidi/combining marks, or homoglyphs). Requires the Pro plan or above.
invalidbooleanReturn a value that is NOT in `choices` — a random token, with probability 0 — for exercising unexpected-value handling.
seedintegerInteger seed for reproducible output: the same seed always yields the same record.

Response fields

FieldTypeDescription
valuestringThe drawn enum member.
probabilitynumberThe member's weight normalized by the sum of all weights.

Examples

Equal split — bare array (weights optional)
GET /v1/enum?choices=["gold","silver","bronze"]
Weighted map — integer counts (drawn 1/20, 4/20, 15/20)
GET /v1/enum?choices={"gold":1,"silver":4,"bronze":15}
Weighted map — fractional probabilities
GET /v1/enum?choices={"active":0.9,"churned":0.1}
Disable a branch — a zero weight is kept but never drawn
GET /v1/enum?choices={"a":0,"b":1}

Other generic generators

Try it

Generate a live example below — every response is valid by format and entirely synthetic.