Skip to main content

Test Credit Card Number API

MOCK DATA

Clearly-fake test credit cards — Luhn-valid numbers with correct Visa, Mastercard, Amex and Discover prefixes, future expiry and matching CVV.

Generated test data for fixtures and development

Base URL
/api/credit-cards
Capabilities
1 route Seedable
Last updated
July 29, 2026

GET /api/credit-cards

Live requestRuns against the public API
No key required
GET/api/credit-cards?count=5&seed=42

Request parameters

Only generate cards of this brand. Omit for a mix of all four.

Advanced response options7 options

How many records to generate (1–100).

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

Return all fields except these (comma-separated).

Response format: json envelope, ndjson (one record per line) or csv.

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/credit-cards?count=5&seed=42"
const res = await fetch("https://randomapi.dev/api/credit-cards?count=5&seed=42");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/credit-cards?count=5&seed=42").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/credit-cards?count=5&seed=42"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 1
brand enum

Only generate cards of this brand. Omit for a mix of all four.

allowed: visa | mastercard | amex | discover
example: brand=visa
Universal parameters Shared response and formatting options 7
count int

How many records to generate (1–100).

default: 10
allowed: 1 – 100
example: count=3
seed int

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

example: seed=42
fields list

Return only these fields (comma-separated). Mutually exclusive with 'exclude'.

example: fields=number,brand
exclude list

Return all fields except these (comma-separated).

example: exclude=holderName
format enum

Response format: json envelope, ndjson (one record per line) or csv.

default: json
allowed: json | ndjson | csv
example: format=csv
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 6
number string

Card number, digits only (no spaces). Luhn-valid with the brand's correct prefix and length, but tied to no real account.

example: 4539148803436467

brand string

visa | mastercard | amex | discover — always consistent with the number's prefix.

example: visa

expMonth integer

Expiry month, 1–12.

example: 9

expYear integer

Expiry year — always strictly in the future (request year +1 to +5).

example: 2029

cvv string

Card verification code: 4 digits for amex, 3 for every other brand. String because it may start with 0.

example: 417

holderName string

Cardholder's full name in UPPERCASE, as embossed on a physical card.

example: EMILY CARTER

Documented examples

Build-generated requests and complete responses
3
Five reproducible test cards
GET /api/credit-cards?count=5&seed=42
{
  "data": [
    {
      "number": "2520350047973637",
      "brand": "mastercard",
      "expMonth": 10,
      "expYear": 2029,
      "cvv": "319",
      "holderName": "KAYLIE GORCZANY-CONSIDINE"
    },
    {
      "number": "4045912567887760",
      "brand": "visa",
      "expMonth": 5,
      "expYear": 2031,
      "cvv": "819",
      "holderName": "WAINO MARVIN"
    },
    {
      "number": "6011345050180366",
      "brand": "discover",
      "expMonth": 10,
      "expYear": 2029,
      "cvv": "201",
      "holderName": "HAILEE STREICH"
    },
    {
      "number": "4501986319099194",
      "brand": "visa",
      "expMonth": 12,
      "expYear": 2030,
      "cvv": "459",
      "holderName": "OTIS HODKIEWICZ"
    },
    {
      "number": "6542069882857086",
      "brand": "discover",
      "expMonth": 8,
      "expYear": 2028,
      "cvv": "550",
    …
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Visa cards only
GET /api/credit-cards?brand=visa&count=3
{
  "data": [
    {
      "number": "4465350047973630",
      "brand": "visa",
      "expMonth": 10,
      "expYear": 2029,
      "cvv": "319",
      "holderName": "KAYLIE GORCZANY-CONSIDINE"
    },
    {
      "number": "4004591256788775",
      "brand": "visa",
      "expMonth": 8,
      "expYear": 2028,
      "cvv": "942",
      "holderName": "WAINO MARVIN"
    },
    {
      "number": "4813450501803676",
      "brand": "visa",
      "expMonth": 7,
      "expYear": 2028,
      "cvv": "554",
      "holderName": "HAILEE STREICH"
    }
  ],
  "meta": {
    "endpoint": "credit-cards",
    "count": 3,
    "seed": 42,
    "params": {
      "brand": "visa"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Amex — 15 digits, 4-digit CVV
GET /api/credit-cards?brand=amex&count=3&seed=7
{
  "data": [
    {
      "number": "378517491214943",
      "brand": "amex",
      "expMonth": 2,
      "expYear": 2030,
      "cvv": "7829",
      "holderName": "BELL TREUTEL"
    },
    {
      "number": "375370983767561",
      "brand": "amex",
      "expMonth": 7,
      "expYear": 2031,
      "cvv": "8451",
      "holderName": "JERMAINE SCHUMM"
    },
    {
      "number": "347670178792737",
      "brand": "amex",
      "expMonth": 8,
      "expYear": 2028,
      "cvv": "9128",
      "holderName": "JULIANA BINS"
    }
  ],
  "meta": {
    "endpoint": "credit-cards",
    "count": 3,
    "seed": 7,
    "params": {
      "brand": "amex"
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

About this API

Coverage & behavior

Generates clearly-fake test credit cards for checkout forms, payment sandboxes and fixtures. Every number is generated at random and belongs to no real account, person or bank — these cards can never be charged. They are however Luhn-valid (correct ISO/IEC 7812 mod-10 check digit) with the genuine issuer prefix and length for each brand, so client-side validators, brand detectors and form libraries accept them exactly like real cards:

  • visa — starts with 4 · 16 digits · 3-digit CVV
  • mastercard — starts with 51–55 or 2221–2720 · 16 digits · 3-digit CVV
  • amex — starts with 34 or 37 · 15 digits · 4-digit CVV
  • discover — starts with 6011 or 65 · 16 digits · 3-digit CVV

brand restricts output to one brand (omit it for a mix of all four), and the brand field always matches the number's actual prefix. expMonth/expYear are always strictly in the future — 1 to 5 years ahead of the request time — so generated cards never trip "card expired" validation. With a seed, the same request returns byte-identical cards forever, ideal for reproducible payment tests.

Use it for

  • Test checkout validation — Luhn checks, brand detection, CVV length — without touching real card data
  • Seed demo shops and payment sandboxes with realistic-looking cards
  • Reproducible payment-flow fixtures in CI via seed (same cards every run)

Frequently asked questions

Do the numbers pass Luhn validation?

Yes — every number has a correct Luhn check digit and a real brand prefix and length, so checkout-form validators accept it.

Can these cards be charged?

No — they're not connected to any account. They exist to test validation and UI flows; real payment gateways will decline them.

Can I pick a specific brand?

Yes — brand=visa|mastercard|amex|discover, with expiry dates and CVVs generated coherently (amex gets 4-digit CVVs).