Build a TCG Collection Manager
Every serious collector wants to know what their cards are worth. With TCG API, you can build a collection manager that values every card in a user's binder, tracks portfolio performance over time, and surfaces insights like which cards are appreciating and which are losing value — across Pokemon, Magic: The Gathering, Yu-Gi-Oh!, and dozens more games.
The Problem
Collectors accumulate hundreds or thousands of cards across multiple games. Knowing what that collection is actually worth requires looking up every card individually, keeping track of condition and printing variants, and somehow aggregating it all into a meaningful total. Most collectors give up and guess.
- Tedious manual lookups. Pricing a 500-card collection by hand means hundreds of individual searches. By the time you finish, the first prices are already stale.
- No portfolio-level view. Collectors can look up individual cards on marketplace sites, but there's no built-in way to see total portfolio value, daily gains and losses, or which cards are driving changes.
- Multi-game complexity. Many collectors play more than one game. A collection spanning Pokemon, Magic, and Lorcana needs data from multiple sources with different structures and conventions.
- Foil and variant tracking. The same card can exist in Normal and Foil printings at wildly different prices. A proper collection manager needs to distinguish between them.
How TCG API Solves This
TCG API gives you everything you need to build a full-featured collection tracker. Search and identify cards, fetch prices for both Normal and Foil printings, pull historical data for trend charts, and use bulk endpoints to value entire sets at once.
Card Search & Identification
The /search endpoint finds cards by name across all 89+ games. Results include set name, rarity, and card ID for precise matching — no ambiguity.
Normal & Foil Prices
Price responses include separate market prices for Normal and Foil printings, so your collection manager can accurately value each variant in a user's collection.
Bulk Set Pricing
Use /sets/{id}/prices to fetch prices for every card in a set with a single request. Perfect for valuing collections organized by set.
Historical Trend Data
Chart portfolio value over time using /cards/{id}/history. Show users how their collection has performed this week, month, or year.
Code Example
This example demonstrates the core workflow of a collection manager: searching for cards to add to a collection, then calculating the total portfolio value with a breakdown by card.
const API_BASE = "https://api.tcgapi.dev/v1";
const API_KEY = "tcg_live_your_key_here";
const headers = { "X-API-Key": API_KEY };
// A user's collection: card IDs with quantities and printing type
const collection = [
{ cardId: 512842, quantity: 1, printing: "Foil" }, // Charizard ex
{ cardId: 510033, quantity: 3, printing: "Normal" }, // Pikachu ex
{ cardId: 489712, quantity: 2, printing: "Normal" }, // Mewtwo VSTAR
{ cardId: 301455, quantity: 1, printing: "Foil" }, // Black Lotus (MTG)
];
// Value the entire collection
async function valueCollection(collection) {
let totalValue = 0;
const breakdown = [];
for (const item of collection) {
const res = await fetch(
`${API_BASE}/cards/${item.cardId}/prices`,
{ headers }
);
const price = await res.json();
// Pick the right printing price
const unitPrice = item.printing === "Foil"
? price.foil_market_price
: price.market_price;
const lineTotal = (unitPrice || 0) * item.quantity;
totalValue += lineTotal;
breakdown.push({
name: price.card_name,
set: price.set_name,
printing: item.printing,
quantity: item.quantity,
unit_price: unitPrice,
total: lineTotal,
change_7d: price.change_7d || 0,
});
}
return { totalValue, breakdown };
}
// Search for a card to add to the collection
async function searchCard(query, game = "pokemon") {
const res = await fetch(
`${API_BASE}/search?q=${encodeURIComponent(query)}&game=${game}&limit=5`,
{ headers }
);
const { results } = await res.json();
return results.map(card => ({
id: card.id,
name: card.name,
set: card.set_name,
rarity: card.rarity,
game: card.game_name,
}));
}
// Example: value the collection and show breakdown
const { totalValue, breakdown } = await valueCollection(collection);
console.log(`Collection Value: $${totalValue.toFixed(2)}\n`);
breakdown.forEach(card => {
const trend = card.change_7d >= 0 ? "+" : "";
console.log(
` ${card.name} (${card.set}, ${card.printing}) x${card.quantity}` +
` — $${card.total.toFixed(2)} [${trend}${card.change_7d.toFixed(1)}% 7d]`
);
}); Efficient Batch Pricing by Set
For large collections, fetch all prices for a set at once instead of making individual card requests. This is especially useful when a user has many cards from the same set.
// Fetch all prices for a set in one request
async function getSetPrices(setId) {
const res = await fetch(
`${API_BASE}/sets/${setId}/prices`,
{ headers }
);
const { prices } = await res.json();
// Build a lookup map: cardId -> price data
const priceMap = new Map();
for (const p of prices) {
priceMap.set(p.card_id, p);
}
return priceMap;
}
// Value all cards from a specific set in the collection
const surgingSparksId = 24680;
const setPrices = await getSetPrices(surgingSparksId);
const myCards = collection.filter(c => c.setId === surgingSparksId);
let setTotal = 0;
for (const card of myCards) {
const price = setPrices.get(card.cardId);
if (price) {
const unitPrice = card.printing === "Foil"
? price.foil_market_price
: price.market_price;
setTotal += (unitPrice || 0) * card.quantity;
}
} Key API Endpoints
Search for cards by name to help users find and add cards to their collection.
Get market price, low price, and foil prices for individual cards in a collection.
Bulk-fetch prices for every card in a set. Efficient for valuing large collections.
Chart historical value trends for individual cards or aggregate collection performance.
List all cards in a set with metadata. Useful for building set completion trackers.
Ready to build your collection manager?
Free tier includes 100 requests per day. No credit card required.