Algobook
- The developer's handbook
mode-switch
back-button
Buy Me A Coffee

Credit card validation API

API for validating a credit card number. The API supports both partial and full numbers, which means that the API can be used for checking the card number in real time while being typed in an input field.

The API has support for the major card types:

  • AMERICAN_EXPRESS
  • DINERS_CLUB
  • DISCOVER
  • ELO
  • HIPERCARD
  • HIPER
  • JCB
  • MAESTRO
  • MASTERCARD
  • MIR
  • UNIONPAY
  • VISA

Example

The API has one endpoint today, and it is accepting a number as a query param in the GET request. The number can be both partial or full.

GET https://api.algobook.info/v1/card/verify?number={number}

Full number

Example in JavaScript for checking a full number:

const response = await fetch( "https://api.algobook.info/v1/card/verify?number=378734493671000" ); const creditCard = await response.json(); console.log(creditCard);

Response

{ "cardType": "American Express", "valid": true, "prefixValid": true }

Partial number

Example of partial card number validation:

const response = await fetch( "https://api.algobook.info/v1/card/verify?number=4114" ); const creditCard = await response.json(); console.log(creditCard);

Response

{ "cardType": "Visa", "valid": false, "prefixValid": true }

Error

If the number is invalid or not passed, an error is returned from the API:

const response = await fetch( "https://api.algobook.info/v1/card/verify?number=null" ); const creditCard = await response.json(); console.log(creditCard);

Response

{ "error": "Invalid card number: null" }

Make the API better together

Are you missing something from the API? Don't hesitate to contact us with any feedback. We love when we get great feedback to enhance our offerings to our consumers.

Thanks for using this API.

signature
See all our articlesSee all our open source projects