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
| Game | Example | What it contains |
|---|---|---|
| One Piece | OP01-001 | Set and position, as printed on the card. |
| Yu-Gi-Oh! | MAMS-EN001 · MAMS-EN001a | Set code, language and position. Each further rarity of the same card adds a letter. |
| Digimon | BT27-002 | Set and position, as printed. |
| Fusion World | FB11-001 · FB11-001a | Set and position. The alternate art adds a letter. |
| Flesh and Blood | MPB001 · MPB002a | Collector number. A Marvel or alternate printing adds a letter. |
| Star Wars: Unlimited | 1/194 | Position and the printed size of the set. |
| Weiss Schwarz | UMA/W119-E001 · UMA/W119-E001SP | Title, set and position, with the SP or SR suffix kept. |
| Cardfight!! Vanguard | DZ-BT17/001EN | Set, position and a language suffix. The slash is part of it. |
| Gundam | GD05-123 | The set the card was first printed in. Reprints keep it. |
| Final Fantasy | 1-018L | Opus, position and a rarity letter. |
| Force of Will | CPB-001 | Set and position. |
| Battle Spirits Saga | BSS06-001 · BSS06-001a | Set and position. SAGA and special rare printings add a letter. |
| Dragoborne | DB-BT05/001 | Set and position, with a slash. |
| Cyberpunk TCG | 001 | Position 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.
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.
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%2F001EN4. 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