Skip to content
alltcgapi.com

Blog ·

Card numbers across card games, and why they are strings

OP01-001, MAMS-EN001a, DZ-BT17/001EN, 1/194, 1-018L: how each game numbers its cards, and five rules for storing, sorting and searching them.

The collector number is the field users type into a search box, and the field with the least in common between games. Below is what the catalogue holds, game by game, and what it means for your code.

What a number looks like

GameExampleWhat it contains
One PieceOP01-001Set and position, as printed on the card.
Yu-Gi-Oh!MAMS-EN001 · MAMS-EN001aSet code, language and position. Each further rarity of the same card adds a letter.
DigimonBT27-002Set and position, as printed.
Fusion WorldFB11-001 · FB11-001aSet and position. The alternate art adds a letter.
Flesh and BloodMPB001 · MPB002aCollector number. A Marvel or alternate printing adds a letter.
Star Wars: Unlimited1/194Position and the printed size of the set.
Weiss SchwarzUMA/W119-E001 · UMA/W119-E001SPTitle, set and position, with the SP or SR suffix kept.
Cardfight!! VanguardDZ-BT17/001ENSet, position and a language suffix. The slash is part of it.
GundamGD05-123The set the card was first printed in. Reprints keep it.
Final Fantasy1-018LOpus, position and a rarity letter.
Force of WillCPB-001Set and position.
Battle Spirits SagaBSS06-001 · BSS06-001aSet and position. SAGA and special rare printings add a letter.
DragoborneDB-BT05/001Set and position, with a slash.
Cyberpunk TCG001Position within its own product only.

The table lists the games whose number format is described on their page of this site. The rules below hold for every game in the API.

1. A number is a string

Leading zeros (001), letters (a, SP, L, EN) and slashes (1/194) are all part of the number. Parsed as an integer, OP01-001 fails and 001 becomes 1, which no user has ever typed. Store numbers as text and compare them as text.

2. number= matches exactly

GET /v1/cards?game=onepiece&number=OP01-001 returns the cards whose number is exactly OP01-001. Exact means exact: in Yu-Gi-Oh! number=MAMS-EN001 returns the first rarity and not MAMS-EN001a. To show every rarity of a card, list the set or search by the start of the name, and group the results yourself.

Request
curl "https://api.alltcgapi.com/v1/cards?game=yugioh&number=MAMS-EN001" \
  -H "X-Api-Key: $ALLTCG_KEY"

3. Encode the slash

Send the number URL-encoded. In Vanguard DZ-BT17/001EN becomes DZ-BT17%2F001EN; the same applies to 1/194, UMA/W119-E001 and DB-BT05/001, and to anything else your users type. Use the encoder of your language rather than replacing characters by hand.

TypeScript
const number = 'DZ-BT17/001EN';
const url = `https://api.alltcgapi.com/v1/cards?game=vanguard&number=${encodeURIComponent(number)}`;
// …/v1/cards?game=vanguard&number=DZ-BT17%2F001EN

4. Sort in the order the API returns

The cards of a set come back in collector-number order. Sorting the strings yourself puts 10 before 2. A natural sort fixes that and still has to know that 001a follows 001, that SP follows the base card and that L is a rarity, not a position. Store the position in which /v1/sets/{code}/cards returned each card and sort on that.

5. The number does not identify the card

  • Gundam reprints keep their first number, so a GD06 card can be numbered GD02-….
  • Cyberpunk TCG numbers restart in every product.
  • Final Fantasy puts the rarity inside the number.

So the number alone tells you neither the set nor the card. Use it to search and to display; store the id.

Showing numbers to users

Show the number as the API returns it. It is what the user reads on the card in their hand, and any reformatting (dropping the zeros, splitting the slash, moving the suffix) is one more step between your screen and the card. When a search by number returns more than one card, show them all with set and image, and let the user pick.

Published · Atom feed