Skip to main content

API Resources

Complete reference for all available resources and methods in the Trading Card API PHP SDK.

Overview

The SDK provides access to the following Trading Card API resources:

ResourceDescriptionCRUD Operations
CardsIndividual trading cards✅ Create, Read, Update, Delete
SetsCard sets and collections✅ Create, Read, Update, Delete
PlayersPlayer information✅ Create, Read, Update
TeamsTeam data✅ Create, Read, Update
GenresCard categories/types✅ Create, Read, Update, Delete
BrandsTrading card brands✅ Create, Read, Update, Delete
ManufacturersCard manufacturers✅ Create, Read, Update, Delete
YearsTrading card years✅ Create, Read, Update, Delete
AttributesCard attributes✅ Read
StatsModel statistics✅ Read

Cards

Individual trading cards with detailed information.

Available Methods

// Get single card
$card = TradingCardApiSdk::card()->get($id, $options = []);

// List cards
$cards = TradingCardApiSdk::card()->getList($filters = []);

// Create card
$card = TradingCardApiSdk::card()->create($data);

// Update card
$card = TradingCardApiSdk::card()->update($id, $data);

// Delete card
$success = TradingCardApiSdk::card()->delete($id);

Examples

Get Single Card

// Basic card retrieval
$card = TradingCardApiSdk::card()->get('card-123');

// Get card with relationships
$card = TradingCardApiSdk::card()->get('card-123', [
'include' => 'set,player,team,prices'
]);

// Access card data
echo $card['name']; // Card name
echo $card['description']; // Card description
echo $card['rarity']; // Card rarity
echo $card['set']['name']; // Set name (if included)

List Cards

// Basic listing
$cards = TradingCardApiSdk::card()->getList();

// With pagination
$cards = TradingCardApiSdk::card()->getList([
'page' => 1,
'limit' => 25
]);

// With filters
$cards = TradingCardApiSdk::card()->getList([
'name' => 'Charizard',
'year' => 2023,
'rarity' => 'rare',
'genre' => 'Pokemon'
]);

// With sorting
$cards = TradingCardApiSdk::card()->getList([
'sort' => 'name',
'order' => 'asc'
]);

Create Card

$newCard = TradingCardApiSdk::card()->create([
'name' => 'Custom Pikachu',
'description' => 'A special custom Pikachu card',
'rarity' => 'ultra_rare',
'set_id' => 'set-456',
'player_id' => 'player-789',
'number' => '025',
'condition' => 'mint'
]);

Sets

Card sets and collections that group related cards.

Available Methods

// Standard CRUD operations
$set = TradingCardApiSdk::set()->get($id, $options = []);
$sets = TradingCardApiSdk::set()->getList($filters = []);
$set = TradingCardApiSdk::set()->create($data);
$set = TradingCardApiSdk::set()->update($id, $data);
$success = TradingCardApiSdk::set()->delete($id);

// Set-specific methods
$checklist = TradingCardApiSdk::set()->checklist($id);
$result = TradingCardApiSdk::set()->addMissingCards($id);
$result = TradingCardApiSdk::set()->addChecklist($request, $id);

Examples

Get Set with Cards

// Get set with all cards
$set = TradingCardApiSdk::set()->get('set-123', [
'include' => 'cards,genre,brand'
]);

// Access set data
echo $set['name']; // Set name
echo $set['release_year']; // Release year
echo $set['total_cards']; // Total cards in set

// Access cards in the set
foreach ($set['cards'] as $card) {
echo $card['name'] . " (#" . $card['number'] . ")\n";
}

Set Checklist

// Get checklist for a set
$checklist = TradingCardApiSdk::set()->checklist('set-123');

foreach ($checklist as $item) {
$status = $item['collected'] ? '✅' : '❌';
echo "{$status} {$item['card']['name']} (#{$item['card']['number']})\n";
}

Add Missing Cards

// Automatically add missing cards to a set
$result = TradingCardApiSdk::set()->addMissingCards('set-123');

echo "Added {$result['added_count']} missing cards\n";

Players

Player information and statistics.

Available Methods

$player = TradingCardApiSdk::player()->get($id, $options = []);
$players = TradingCardApiSdk::player()->getList($filters = []);
$player = TradingCardApiSdk::player()->create($data);

Examples

// Get player with cards
$player = TradingCardApiSdk::player()->get('player-123', [
'include' => 'cards,team'
]);

// List players by team
$players = TradingCardApiSdk::player()->getList([
'team_id' => 'team-456',
'position' => 'pitcher'
]);

// Create new player
$player = TradingCardApiSdk::player()->create([
'name' => 'John Smith',
'position' => 'shortstop',
'team_id' => 'team-789',
'jersey_number' => 42
]);

Teams

Team data and information.

Available Methods

$team = TradingCardApiSdk::team()->get($id, $options = []);
$teams = TradingCardApiSdk::team()->getList($filters = []);
$team = TradingCardApiSdk::team()->create($data);

Examples

// Get team with players
$team = TradingCardApiSdk::team()->get('team-123', [
'include' => 'players,cards'
]);

// List teams by location
$teams = TradingCardApiSdk::team()->getList([
'location' => 'New York',
'active' => true
]);

// Create new team
$team = TradingCardApiSdk::team()->create([
'name' => 'Custom Team',
'location' => 'Custom City',
'founded_year' => 2023,
'league' => 'Custom League'
]);

Genres

Card categories and types (Pokemon, Baseball, Football, etc.).

Available Methods

// Standard CRUD operations
$genre = TradingCardApiSdk::genre()->get($id, $options = []);
$genres = TradingCardApiSdk::genre()->getList($filters = []);
$genre = TradingCardApiSdk::genre()->create($data);
$genre = TradingCardApiSdk::genre()->update($id, $data);
$success = TradingCardApiSdk::genre()->delete($id);

// Genre-specific methods
$deletedGenres = TradingCardApiSdk::genre()->listDeleted();
$deletedGenre = TradingCardApiSdk::genre()->deleted($id);

Examples

// List all active genres
$genres = TradingCardApiSdk::genre()->getList();

// Get genre with sets and cards
$genre = TradingCardApiSdk::genre()->get('pokemon', [
'include' => 'sets,cards'
]);

// Create new genre
$genre = TradingCardApiSdk::genre()->create([
'name' => 'Custom TCG',
'description' => 'A custom trading card game',
'slug' => 'custom-tcg'
]);

// List deleted genres
$deletedGenres = TradingCardApiSdk::genre()->listDeleted();

Brands

Trading card brands and manufacturers.

Available Methods

$brand = TradingCardApiSdk::brand()->get($id, $options = []);
$brands = TradingCardApiSdk::brand()->getList($filters = []);
$brand = TradingCardApiSdk::brand()->create($data);
$brand = TradingCardApiSdk::brand()->update($id, $data);
$success = TradingCardApiSdk::brand()->delete($id);

Examples

// List all brands
$brands = TradingCardApiSdk::brand()->getList();

// Get brand with sets
$brand = TradingCardApiSdk::brand()->get('topps', [
'include' => 'sets'
]);

// Create new brand
$brand = TradingCardApiSdk::brand()->create([
'name' => 'Custom Brand',
'description' => 'A custom card brand',
'founded_year' => 2023
]);

Manufacturers

Card manufacturing companies.

Available Methods

$manufacturer = TradingCardApiSdk::manufacturer()->get($id, $options = []);
$manufacturers = TradingCardApiSdk::manufacturer()->getList($filters = []);
$manufacturer = TradingCardApiSdk::manufacturer()->create($data);
$manufacturer = TradingCardApiSdk::manufacturer()->update($id, $data);
$success = TradingCardApiSdk::manufacturer()->delete($id);

Examples

// List manufacturers
$manufacturers = TradingCardApiSdk::manufacturer()->getList();

// Get manufacturer with brands
$manufacturer = TradingCardApiSdk::manufacturer()->get('panini', [
'include' => 'brands,sets'
]);

Years

Trading card years and eras.

Available Methods

$year = TradingCardApiSdk::year()->get($id, $options = []);
$years = TradingCardApiSdk::year()->getList($filters = []);
$year = TradingCardApiSdk::year()->create($data);
$year = TradingCardApiSdk::year()->update($id, $data);
$success = TradingCardApiSdk::year()->delete($id);

Examples

// List all years
$years = TradingCardApiSdk::year()->getList([
'sort' => 'year',
'order' => 'desc'
]);

// Get specific year with sets
$year = TradingCardApiSdk::year()->get('1989', [
'include' => 'sets,cards'
]);

Attributes

Card attributes and characteristics.

Available Methods

$attribute = TradingCardApiSdk::attribute()->get($id, $options = []);
$attributes = TradingCardApiSdk::attribute()->getList($filters = []);

Examples

// List all attributes
$attributes = TradingCardApiSdk::attribute()->getList();

// Get specific attribute
$attribute = TradingCardApiSdk::attribute()->get('rarity');

Stats

Model statistics and analytics.

Available Methods

$stats = TradingCardApiSdk::stats()->get($type);

Examples

// Get card statistics
$cardStats = TradingCardApiSdk::stats()->get('cards');
echo "Total cards: " . $cardStats['total'];
echo "By genre: " . json_encode($cardStats['by_genre']);

// Get set statistics
$setStats = TradingCardApiSdk::stats()->get('sets');
echo "Total sets: " . $setStats['total'];

// Get player statistics
$playerStats = TradingCardApiSdk::stats()->get('players');

Common Patterns

Filtering and Searching

Most getList() methods support common filters:

// Common filters
$results = TradingCardApiSdk::card()->getList([
'name' => 'search term', // Name contains
'year' => 2023, // Exact year
'genre' => 'pokemon', // Exact genre
'rarity' => 'rare', // Exact rarity
'active' => true, // Boolean filters
'page' => 1, // Pagination
'limit' => 25, // Results per page
'sort' => 'name', // Sort field
'order' => 'asc' // Sort direction
]);

Including Relationships

Use the include parameter to fetch related data:

// Single relationship
$card = TradingCardApiSdk::card()->get('card-id', [
'include' => 'set'
]);

// Multiple relationships
$card = TradingCardApiSdk::card()->get('card-id', [
'include' => 'set,player,team,prices'
]);

// Nested relationships (if supported)
$set = TradingCardApiSdk::set()->get('set-id', [
'include' => 'cards.player,genre'
]);

Pagination

Handle large datasets with pagination:

function getAllCards(): array
{
$allCards = [];
$page = 1;
$limit = 100;

do {
$response = TradingCardApiSdk::card()->getList([
'page' => $page,
'limit' => $limit
]);

if (isset($response['data'])) {
$allCards = array_merge($allCards, $response['data']);
}

$page++;
$hasMore = count($response['data']) === $limit;
} while ($hasMore);

return $allCards;
}

Error Handling

Always handle potential errors:

use CardTechie\TradingCardApiSdk\Exceptions\{
CardNotFoundException,
ValidationException,
RateLimitException
};

try {
$card = TradingCardApiSdk::card()->get('invalid-id');
} catch (CardNotFoundException $e) {
// Handle not found
} catch (ValidationException $e) {
// Handle validation errors
$errors = $e->getValidationErrors();
} catch (RateLimitException $e) {
// Handle rate limiting
$retryAfter = $e->getRetryAfter();
}

Next Steps