BYTETOOLS

Deck of Cards API

Free playing card API with no key: shuffle decks, draw cards, manage piles and get card images. Stateful deck ids. Tested curl example and live JSON.

No API key requiredCORS enabledHTTPSFree tier

Endpoint tested and returned HTTP 200 on 2026-08-19

What is the Deck of Cards API?

The Deck of Cards API is a free, key-free API that simulates physical decks of playing cards. It shuffles decks, deals cards, manages named piles and provides an image for every card, tracking state server-side via a deck id.

What makes this API unusual among free APIs is that it is stateful. You create a deck, get back a `deck_id`, and every subsequent draw remembers what has already been dealt — the API tracks `remaining` for you rather than making you manage the deck yourself.

That statefulness makes it genuinely useful for building real card games rather than just demos. It also supports named piles, so you can model each player's hand and a discard pile server-side, which removes most of the bookkeeping from your client code.

Quick facts

Base URL
https://deckofcardsapi.com/api/deck
Authentication
No key required.
Rate limit
No published limit.
Pricing
Free.
CORS
Enabled — callable directly from browser JavaScript
Official docs
Read the docs

How to use the Deck of Cards API

Every request below was executed against the live API on 2026-08-19, and the response shown is the real body it returned — not an illustration.

1. Shuffle a new deck of cards

GET https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1

curl
curl 'https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1'
JavaScript (fetch)
const res = await fetch("https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);
Python (requests)
import requests

res = requests.get("https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1", timeout=20)
res.raise_for_status()
print(res.json())
Response — HTTP 200
{
  "success": true,
  "deck_id": "xiyuflcig0a4",
  "remaining": 52,
  "shuffled": true
}

Parameters

ParameterTypeRequiredDescription
deck_countintegerOptionalNumber of 52-card decks to combine. 1
<deck_id>pathOptionalDeck identifier returned when you created the deck. 3p40paa87x90
countintegerOptionalHow many cards to draw. 5
jokers_enabledbooleanOptionalInclude two jokers per deck. true

Response fields

deck_idstring
Identifier used for all subsequent operations on this deck.
remaininginteger
Cards left undealt — the API tracks this for you.
shuffledboolean
Whether the deck has been shuffled.
cards[].codestring
Short card code such as AS for ace of spades.
cards[].imagestring
PNG image URL for the card face.
cards[].value / suitstring
Card value and suit as readable strings.

What you can build with the Deck of Cards API

  • Build blackjack, poker or solitaire with server-tracked deck state
  • Create card-based teaching demos without implementing shuffling
  • Manage player hands and discard piles using named piles
  • Render real card images without sourcing your own artwork

Common errors and how to fix them

Deck not found

The deck_id expired or was mistyped.

Fix: Deck ids are not permanent — create a new deck and store the id for the session.

Not enough cards remaining

You drew more than the deck holds.

Fix: Check `remaining` before drawing, or reshuffle with the /shuffle endpoint.

Deck of Cards API — frequently asked questions

Is the Deck of Cards API free?

Yes, completely free with no API key or registration required.

Does the API remember which cards have been dealt?

Yes. It is stateful — create a deck, keep the returned `deck_id`, and each draw is tracked server-side with a `remaining` count.

Can I use multiple decks at once?

Yes, pass `deck_count` when creating a deck to combine several 52-card decks, which is how casino blackjack shoes work.

Does it provide card images?

Yes, every card includes a PNG image URL for its face, so you do not need to source or draw your own card artwork.

Tools that pair with this API

Deck of Cards is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-19; always check the official documentation before relying on this API in production, as terms and limits can change.