# Card Validator API

> Card Validator is a credit card number validator API: it checks whether a card number is valid, identifies the card brand, and flags risk. It runs the Luhn checksum, detects the scheme (Visa, Mastercard, Amex and more), returns the PCI-safe BIN and last 4 digits, flags known processor test cards, and returns a composite risk score.

**Endpoint:** `GET https://api.apiverve.com/v1/cardvalidator`  
**Category:** Data Validation  
**Cost:** 2 credits per call  
**Canonical page:** https://apiverve.com/marketplace/cardvalidator

## Overview

Card Validator is a card number validator and card verifier API. It works by validating the card number against the Luhn algorithm and the brand's prefix and length rules. It identifies the card scheme, extracts the BIN and last four digits, checks the number against a list of known published test cards, and returns a risk score summarizing how safe the number is to trust. It does not say whether a card is debit or credit or who issued it; send the first six digits to BIN Lookup for that.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/cardvalidator?number=4900264223817524" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `number` | string | Yes | The card number to validate, up to 19 digits; spaces or dashes between digit groups are accepted. length 13-23 |

## Response fields

- `card` — object · Card identification and validation details
  - `card.niceType` — string · Human-readable card type name like Visa
  - `card.type` — string · Machine-readable card type identifier · (premium)
  - `card.patterns` — array · Starting digit patterns for card type · (premium)
  - `card.gaps` — array · Character positions for spacing formatting · (premium)
  - `card.lengths` — array · Valid card length values in digits · (premium)
  - `card.code` — object · Security code specifications for card · (premium)
    - `card.code.name` — string · Name of security code like CVV · (premium)
    - `card.code.size` — number · Number of digits in security code · (premium)
  - `card.matchStrength` — number · Confidence level of card type match · (premium)
- `brand` — string · Human-readable card brand (e.g. Visa, Mastercard, RuPay), or null if the scheme could not be identified
- `cardNumber` — string · The card number, masked to its last four digits (e.g. ************4242). The full number is never returned
- `bin` — string · The card's BIN/IIN (first 6 digits), or null if fewer than 6 digits were supplied
- `last4` — string · The last 4 digits of the card, or null if fewer than 4 digits were supplied
- `isValid` — boolean · Whether the card number is complete and passes the Luhn checksum
- `isPotentiallyValid` — boolean · Whether the number could still become valid (correct brand prefix but possibly incomplete) — useful while a user is still typing
- `isTestCard` — boolean · Whether the number is a known published processor test card (Stripe, Adyen, etc.) rather than a live card · (premium)
- `riskScore` — number · Composite 0-100 risk score combining Luhn validity, test-card and scheme-recognition signals (higher is riskier) · (premium)
- `riskLevel` — string · Risk band derived from the score: low, medium or high · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "card": {
      "niceType": "Visa",
      "type": "visa",
      "patterns": [
        4
      ],
      "gaps": [
        4,
        8,
        12
      ],
      "lengths": [
        16,
        18,
        19
      ],
      "code": {
        "name": "CVV",
        "size": 3
      },
      "matchStrength": 1
    },
    "brand": "Visa",
    "cardNumber": "************7524",
    "bin": "490026",
    "last4": "7524",
    "isValid": true,
    "isPotentiallyValid": true,
    "isTestCard": false,
    "riskScore": 0,
    "riskLevel": "low"
  }
}
```

## Use cases

- **Dynamic Checkout Formatting** — When shoppers type card numbers during checkout, frontend forms inspect partial validity to display matching brand icons and security code hints immediately.
- **Test Card Interception** — Flag published processor test numbers in production checkouts before sending them to gateways, preventing failed authorization attempts or merchant penalty fees.
- **Payment Method Tokenization** — Subscription billing services verify Luhn checksums and separate the bank identification number and last four digits before storing masked records in customer vaults.
- **Account Signup Screening** — To block automated trial abuse, fraud prevention systems score incoming payment details and reject generated numbers that fail mathematical card validity checks.

## SDKs

- **npm** — `npm install @apiverve/cardvalidator` (https://www.npmjs.com/package/@apiverve/cardvalidator)
- **PyPI** — `pip install apiverve-cardvalidator` (https://pypi.org/project/apiverve-cardvalidator/)
- **NuGet** — `dotnet add package APIVerve.API.CardValidator` (https://www.nuget.org/packages/APIVerve.API.CardValidator)
- **Source** — https://github.com/apiverve/cardvalidator-api

## More

- Full reference: https://docs.apiverve.com/ref/cardvalidator
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
