### Usage Examples for Pokemon TCG SDK TypeScript Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Demonstrates how to use the Pokemon TCG SDK in TypeScript to fetch card data. Includes examples for finding a card by ID, searching cards with parameters, and retrieving all cards. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript' PokemonTCG.Card.find('xy1') .then(card => { // do stuff with the card }) .catch(error => { // do something with the error }); let params: PokemonTCG.IQuery[] = [{ name: 'name', value: 'Charizard' }]; PokemonTCG.Card.where(params) .then(cards => { // do stuff with the cards }) .catch(error => { // do something with the error }); PokemonTCG.Card.all() .then(cards => { // do stuff with the cards }) .catch(error => { // do something with the error }); ``` -------------------------------- ### Install Pokemon TCG SDK TypeScript Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Instructions for installing the Pokemon TCG SDK using npm or yarn package managers. This SDK allows interaction with the Pokemon TCG API. ```bash npm install --save pokemon-tcg-sdk-typescript ``` ```bash yarn add pokemon-tcg-sdk-typescript ``` -------------------------------- ### Get All Subtypes: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Illustrates the change in fetching all subtypes. The v1 function `PokemonTCG.Meta.allSubtypes()` is replaced by `PokemonTCG.getSubtypes()` in v2. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 PokemonTCG.Meta.allSubtypes(); // V2 PokemonTCG.getSubtypes(); ``` -------------------------------- ### Get All Pokemon Cards using TypeScript Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Shows how to retrieve all Pokemon cards available through the API using the Pokemon TCG SDK TypeScript. It demonstrates automatic pagination (defaulting to 250 cards per request) and provides an example of grouping the retrieved cards by their set. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Get all cards (returns first page of 250) PokemonTCG.Card.all() .then((cards: PokemonTCG.Card[]) => { console.log(`Retrieved ${cards.length} cards`); // Group cards by set const cardsBySet = cards.reduce((acc, card) => { const setName = card.set.name; if (!acc[setName]) acc[setName] = []; acc[setName].push(card); return acc; }, {} as Record); Object.entries(cardsBySet).forEach(([setName, setCards]) => { console.log(`${setName}: ${setCards.length} cards`); }); }) .catch(error => { console.error('Failed to fetch cards:', error.message); }); ``` -------------------------------- ### Get All Cards: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Demonstrates the change in how to fetch all cards from the Pokemon TCG API. This involves updating the function call from `PokemonTCG.Card.all()` in v1 to `PokemonTCG.getAllCards()` in v2. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 PokemonTCG.Card.all(); // V2 PokemonTCG.getAllCards(); ``` -------------------------------- ### Get All Types: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Shows the change in fetching all available types from the Pokemon TCG API. The v1 function `PokemonTCG.Meta.getAllTypes()` is replaced by `PokemonTCG.getTypes()` in v2. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 PokemonTCG.Meta.getAllTypes(); // V2 PokemonTCG.getTypes(); ``` -------------------------------- ### Get All Supertypes: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Details the migration for fetching all supertypes. The v1 function `PokemonTCG.Meta.allSupertypes()` is updated to `PokemonTCG.getSupertypes()` in v2. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 PokemonTCG.Meta.allSupertypes(); // V2 PokemonTCG.getSupertypes(); ``` -------------------------------- ### Get All Sets: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Details the change in fetching all available sets from the Pokemon TCG API. The v1 function `PokemonTCG.Set.all()` is updated to `PokemonTCG.getAllSets()` in v2. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 PokemonTCG.Set.all(); // V2 PokemonTCG.getAllSets(); ``` -------------------------------- ### Search Pokemon Cards with Query Parameters using TypeScript Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Illustrates how to search for Pokemon cards based on specific criteria using query parameters with the Pokemon TCG SDK TypeScript. It covers searching by name and set ID, by type and HP, and includes examples of paginated searches. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Search for Charizard cards in the Base set const params: PokemonTCG.IQuery[] = [ { name: 'q', value: 'name:Charizard set.id:base1' } ]; PokemonTCG.Card.where(params) .then((cards: PokemonTCG.Card[]) => { console.log(`Found ${cards.length} cards`); cards.forEach(card => { console.log(`${card.name} - ${card.set.name} (#${card.number})`); }); }) .catch(error => { console.error('Search failed:', error.message); }); // Search by Pokemon type const fireTypeParams: PokemonTCG.IQuery[] = [ { name: 'q', value: 'types:Fire hp:[100 TO *]' } ]; PokemonTCG.Card.where(fireTypeParams) .then(cards => { console.log(`Found ${cards.length} Fire type cards with 100+ HP`); }); // Search with pagination const paginatedParams: PokemonTCG.IQuery[] = [ { name: 'q', value: 'supertype:Pokemon' }, { name: 'page', value: 1 }, { name: 'pageSize', value: 50 } ]; PokemonTCG.Card.where(paginatedParams) .then(cards => { console.log(`Page 1: ${cards.length} Pokemon cards`); }); ``` -------------------------------- ### Get All Pokemon TCG Sets (TypeScript) Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Retrieves all available Pokemon card sets from the API. This function requires the 'pokemon-tcg-sdk-typescript' package and returns a Promise that resolves with an array of all Set objects. It also demonstrates grouping sets by series. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Get all sets PokemonTCG.Set.all() .then((sets: PokemonTCG.Set[]) => { console.log(`Total sets: ${sets.length}`); // Group sets by series const setBySeries = sets.reduce((acc, set) => { if (!acc[set.series]) acc[set.series] = []; acc[set.series].push(set); return acc; }, {} as Record); Object.entries(setBySeries).forEach(([series, seriesSets]) => { const totalCards = seriesSets.reduce((sum, s) => sum + s.total, 0); console.log(`${series}: ${seriesSets.length} sets, ${totalCards} total cards`); }); }) .catch(error => { console.error('Failed to fetch sets:', error.message); }); ``` -------------------------------- ### Get All Pokemon TCG Card Subtypes (TypeScript) Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Retrieves a list of all available card subtypes, including Basic, Stage 1, Stage 2, EX, GX, and VMAX. This function requires the 'pokemon-tcg-sdk-typescript' package and returns a Promise that resolves with an array of subtype strings. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Get all card subtypes PokemonTCG.Meta.allSubtypes() .then((subtypes: string[]) => { console.log('Available Card Subtypes:'); subtypes.forEach(subtype => console.log(`- ${subtype}`)); // Example output: Basic, Stage 1, Stage 2, BREAK, EX, GX, V, VMAX, etc. }) .catch(error => { console.error('Failed to fetch subtypes:', error.message); }); ``` -------------------------------- ### Get All Pokemon TCG Types (TypeScript) Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Retrieves a list of all available Pokemon types, such as Fire, Water, and Grass. This function requires the 'pokemon-tcg-sdk-typescript' package and returns a Promise that resolves with an array of type strings. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Get all Pokemon types PokemonTCG.Meta.allTypes() .then((types: string[]) => { console.log('Available Pokemon Types:'); types.forEach(type => console.log(`- ${type}`)); // Example output: Colorless, Darkness, Dragon, Fairy, Fighting, Fire, Grass, Lightning, Metal, Psychic, Water }) .catch(error => { console.error('Failed to fetch types:', error.message); }); ``` -------------------------------- ### Get All Pokemon TCG Card Supertypes (TypeScript) Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Retrieves a list of all available card supertypes, such as Pokemon, Trainer, and Energy. This function requires the 'pokemon-tcg-sdk-typescript' package and returns a Promise that resolves with an array of supertype strings. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Get all card supertypes PokemonTCG.Meta.allSupertypes() .then((supertypes: string[]) => { console.log('Available Card Supertypes:'); supertypes.forEach(supertype => console.log(`- ${supertype}`)); // Output: Energy, Pokémon, Trainer }) .catch(error => { console.error('Failed to fetch supertypes:', error.message); }); ``` -------------------------------- ### Get All Pokemon TCG Card Rarities (TypeScript) Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Retrieves a list of all available card rarities, including Common, Uncommon, Rare, and Rare Holo. This function requires the 'pokemon-tcg-sdk-typescript' package and returns a Promise that resolves with an array of rarity strings. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Get all card rarities PokemonTCG.Meta.allRarities() .then((rarities: string[]) => { console.log('Available Card Rarities:'); rarities.forEach(rarity => console.log(`- ${rarity}`)); // Example output: Common, Uncommon, Rare, Rare Holo, Rare Holo EX, etc. }) .catch(error => { console.error('Failed to fetch rarities:', error.message); }); ``` -------------------------------- ### Find Sets by Queries: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Illustrates the update for querying sets. V1 used `PokemonTCG.Set.where()` with `IQuery` objects, while v2 uses `PokemonTCG.findSetsByQueries()` with a `Parameter` object containing a `q` property for query filtering. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 const paramsV1: PokemonTCG.IQuery[] = [{ name: 'name', value:'Base' }]; PokemonTCG.Set.where(paramsV1).then((sets: PokemonTCG.Set[]) => { console.log(sets[0].name) // Base }); // V2 const paramsV2: PokemonTCG.Parameter[] = { q: 'name:Base' }; PokemonTCG.findSetsByQueries(paramsV2).then((sets: PokemonTCG.Set[]) => { console.log(sets[0].name) // Base }); ``` -------------------------------- ### Process Pokemon Cards using TypeScript SDK Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Demonstrates how to use the Pokemon TCG SDK in TypeScript to fetch and process card data. It shows how to construct query parameters, retrieve cards using `PokemonTCG.Card.where`, and iterate through the results, leveraging TypeScript's type safety for autocompletion and error checking. ```typescript async function processCards(): Promise { const params: PokemonTCG.IQuery[] = [ { name: 'q', value: 'name:Pikachu' } ]; const cards: PokemonTCG.Card[] = await PokemonTCG.Card.where(params); cards.forEach((card: PokemonTCG.Card) => { // TypeScript provides autocomplete and type checking const { name, hp, types, attacks, set } = card; console.log(`${name} (${hp} HP) - ${set.name}`); attacks?.forEach(attack => { console.log(` ${attack.name}: ${attack.damage} damage`); }); }); } ``` -------------------------------- ### Find Cards by Queries: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Shows the refactoring of the function to find cards based on query parameters. V1 used an array of `IQuery` objects, while v2 utilizes a `Parameter` object with a `q` property for queries, changing the function name to `PokemonTCG.findCardsByQueries()`. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 const paramsV1: PokemonTCG.IQuery[] = [{ name: 'name', value: 'Gardevoir' }]; PokemonTCG.Card.where(paramsV1).then((cards: PokemonTCG.Card[]) => { console.log(cards[0].name) // Gardevoir }); // V2 const paramsV2: PokemonTCG.Parameter[] = { q: 'id:xy7-54' }; PokemonTCG.findCardsByQueries(paramsV2).then((cards: PokemonTCG.Card[]) => { console.log(cards[0].name) // Gardevoir }); ``` -------------------------------- ### Search Pokemon TCG Sets with Query Parameters (TypeScript) Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Searches for Pokemon card sets based on provided query parameters, such as name or series. This function requires the 'pokemon-tcg-sdk-typescript' package and accepts an array of IQuery objects. It returns a Promise that resolves with an array of matching Set objects or rejects with an error. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Search for sets by name const params: PokemonTCG.IQuery[] = [ { name: 'q', value: 'name:Base' } ]; PokemonTCG.Set.where(params) .then((sets: PokemonTCG.Set[]) => { console.log(`Found ${sets.length} sets matching 'Base'`); sets.forEach(set => { console.log(`${set.name} (${set.series}) - ${set.total} cards`); }); }) .catch(error => { console.error('Search failed:', error.message); }); // Search for sets by series const seriesParams: PokemonTCG.IQuery[] = [ { name: 'q', value: 'series:XY' } ]; PokemonTCG.Set.where(seriesParams) .then(sets => { console.log(`XY Series has ${sets.length} sets`); }); ``` -------------------------------- ### Find Set by ID: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Explains the migration for finding a specific set using its ID. The v1 method `PokemonTCG.Set.find()` is replaced by `PokemonTCG.findSetByID()` in v2, with identical promise-based return types. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 PokemonTCG.Set.find('base1').then((set: PokemonTCG.Set) => { console.log(set.name) // Base }); // V2 PokemonTCG.findSetByID('base1').then((set: PokemonTCG.Set) => { console.log(set.name) // Base }); ``` -------------------------------- ### Pokemon TCG SDK TypeScript Method Definitions Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Outlines the static methods available on the Card, Set, and Meta classes for interacting with the Pokemon TCG API. These methods include finding by ID, filtering with parameters, and retrieving all available data. ```typescript Card.find(id: string): Promise Card.where(params: IQuery[]): Promise Card.all(): Promise Set.find(id: string): Promise Set.where(params: IQuery[]): Promise Set.all(): Promise Meta.allTypes(): Promise Meta.allSubtypes(): Promise Meta.allSupertypes(): Promise ``` -------------------------------- ### Meta API Endpoints Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Provides methods to retrieve lists of available types, subtypes, and supertypes for filtering. ```APIDOC ## GET /types ### Description Retrieves a list of all available card types. ### Method GET ### Endpoint `/types` ### Response #### Success Response (200) - **string[]** (array) - An array of card type strings. #### Response Example ```json [ "Colorless", "Darkness", "Dragon", "Fighting", "Fire", "Grass", "Lightning", "Metal", "Psychic", "Water" ] ``` ## GET /subtypes ### Description Retrieves a list of all available card subtypes. ### Method GET ### Endpoint `/subtypes` ### Response #### Success Response (200) - **string[]** (array) - An array of card subtype strings. #### Response Example ```json [ "BREAK", "Baby", "EX", "Fusion Strike", "G-Booster", "G-Max", "GX", "ika", "Item", "Legend", "Level-Up", "Lost Zone", "Mega", "Partner", "Phaser", "Rapid Strike", "Restored", "SP", "Special", "Stage 1", "Stage 2", "Stellar", "Subtotal", "Supporter", "Tag Team", "TDX", "Trainer", "V", "VMAX", "VSTAR", "ாதாரண" ] ``` ## GET /supertypes ### Description Retrieves a list of all available card supertypes. ### Method GET ### Endpoint `/supertypes` ### Response #### Success Response (200) - **string[]** (array) - An array of card supertype strings. #### Response Example ```json [ "Energy", "Item", "Legendary", "Pokémon", "Trainer" ] ``` ``` -------------------------------- ### Find Pokemon Card by ID using TypeScript Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Demonstrates how to retrieve a single Pokemon card by its unique identifier using the Pokemon TCG SDK TypeScript. It shows how to access card details like name, HP, types, set, rarity, artist, image URL, attacks, abilities, and TCGPlayer pricing. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Find a specific card by ID PokemonTCG.Card.find('xy7-54') .then((card: PokemonTCG.Card) => { console.log('Card Name:', card.name); // Gardevoir console.log('HP:', card.hp); // 130 console.log('Types:', card.types); // ['Psychic'] console.log('Set:', card.set.name); // Ancient Origins console.log('Rarity:', card.rarity); // Rare Holo console.log('Artist:', card.artist); console.log('Image URL:', card.images.large); // Access attacks if (card.attacks) { card.attacks.forEach(attack => { console.log(`Attack: ${attack.name}, Damage: ${attack.damage}, Cost: ${attack.cost.join(', ')}`); }); } // Access abilities if (card.abilities) { card.abilities.forEach(ability => { console.log(`Ability: ${ability.name} - ${ability.text}`); }); } // Access pricing data if available if (card.tcgplayer) { console.log('TCGPlayer URL:', card.tcgplayer.url); } }) .catch(error => { console.error('Error fetching card:', error.message); }); ``` -------------------------------- ### TypeScript IQuery Interface Definition Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Defines the structure for a query parameter object used in API requests. It consists of a name and a value, where the value can be a string or a number. ```typescript { name: string, value: string | number } ``` -------------------------------- ### Set API Endpoints Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Provides methods to find a specific set by ID, search for sets using query parameters, or retrieve all available sets. ```APIDOC ## GET /sets/:id ### Description Retrieves a single set by its unique identifier. ### Method GET ### Endpoint `/sets/:id` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the set. ### Response #### Success Response (200) - **Set** (object) - Detailed information about the set. #### Response Example ```json { "id": "base1", "name": "Base", "series": "Base", "printedTotal": 102, "total": 102, "releaseDate": "1999/01/09", "updatedAt": "2020/08/14 09:39:00", "images": { "symbol": "https://images.pokemontcg.io/base1/symbol.png", "logo": "https://images.pokemontcg.io/base1/logo.png" }, "legalities": { "unlimited": "Legal", "standard": "Not Legal", "expanded": "Not Legal" } } ``` ## GET /sets ### Description Retrieves a list of sets, optionally filtered by query parameters. ### Method GET ### Endpoint `/sets` ### Parameters #### Query Parameters - **name** (string) - Optional - Filter sets by name. - **series** (string) - Optional - Filter sets by series (e.g., XY, Sun & Moon). - **ptcgoCode** (string) - Optional - Filter sets by PTCGO code. - **total** (number) - Optional - Filter sets by the total number of cards. - **page** (number) - Optional - The page number for pagination. - **pageSize** (number) - Optional - The number of results per page. ### Response #### Success Response (200) - **Set[]** (array) - An array of set objects matching the query. #### Response Example ```json [ { "id": "base1", "name": "Base", "series": "Base", "printedTotal": 102, "total": 102, "releaseDate": "1999/01/09", "updatedAt": "2020/08/14 09:39:00", "images": { "symbol": "https://images.pokemontcg.io/base1/symbol.png", "logo": "https://images.pokemontcg.io/base1/logo.png" }, "legalities": { "unlimited": "Legal", "standard": "Not Legal", "expanded": "Not Legal" } } ] ``` ``` -------------------------------- ### Find Card by ID: v1 vs v2 Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/MIGRATING.md Illustrates the migration of the function to find a specific card by its ID. The v1 method `PokemonTCG.Card.find()` is replaced by `PokemonTCG.findCardByID()` in v2, maintaining the same promise-based return type. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // V1 PokemonTCG.Card.find('xy7-54').then((card: PokemonTCG.Card) => { console.log(card.name) // Gardevoir }); // V2 PokemonTCG.findCardByID('xy7-54').then((card: PokemonTCG.Card) => { console.log(card.name) // Gardevoir }); ``` -------------------------------- ### TypeScript IAbility Interface Definition Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Defines the structure for an 'Ability' object, commonly found within a Pokemon Card. It includes the ability's name, description text, and type. ```typescript name: string; text: string; type: string; ``` -------------------------------- ### Card API Endpoints Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Provides methods to find a specific card by ID, search for cards using query parameters, or retrieve all available cards. ```APIDOC ## GET /cards/:id ### Description Retrieves a single card by its unique identifier. ### Method GET ### Endpoint `/cards/:id` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the card. ### Response #### Success Response (200) - **Card** (object) - Detailed information about the card. #### Response Example ```json { "id": "xy1", "name": "Charizard", "supertype": "Pokémon", "subtypes": [ "Stage 2" ], "hp": "120", "types": [ "Fire" ], "evolvesFrom": "Charmeleon", "attacks": [ { "cost": [ "Fire", "Fire", "Colorless" ], "name": "Fire Spin", "text": "Discard 2 Energy cards attached to this Pokémon in order to use this attack.", "damage": "100", "convertedEnergyCost": 3 } ], "weaknesses": [ { "type": "Water", "value": "×2" } ], "retreatCost": [ "Colorless", "Colorless", "Colorless" ], "convertedRetreatCost": 3, "set": { "id": "xy1", "name": "XY", "series": "XY", "printedTotal": 146, "total": 146, "releaseDate": "2014/03/12", "updatedAt": "2020/08/14 09:39:00" }, "number": "7", "artist": "Hajime Kusajima", "rarity": "Rare Holo", "legalities": { "unlimited": "Legal", "expanded": "Legal" }, "images": { "small": "https://images.pokemontcg.io/xy1/7.png", "large": "https://images.pokemontcg.io/xy1/7_hires.png" } } ``` ## GET /cards ### Description Retrieves a list of cards, optionally filtered by query parameters. ### Method GET ### Endpoint `/cards` ### Parameters #### Query Parameters - **name** (string) - Optional - Filter cards by name. - **supertype** (string) - Optional - Filter cards by supertype (e.g., Pokémon, Trainer, Energy). - **subtypes** (string) - Optional - Filter cards by subtype (e.g., Stage 1, GX, Full Art). - **types** (string) - Optional - Filter cards by type (e.g., Fire, Water, Grass). - **rarity** (string) - Optional - Filter cards by rarity (e.g., Common, Uncommon, Rare). - **set** (string) - Optional - Filter cards by set ID or code. - **artist** (string) - Optional - Filter cards by artist name. - **page** (number) - Optional - The page number for pagination. - **pageSize** (number) - Optional - The number of results per page. ### Response #### Success Response (200) - **Card[]** (array) - An array of card objects matching the query. #### Response Example ```json [ { "id": "xy1-7", "name": "Charizard", "supertype": "Pokémon", "subtypes": [ "Stage 2" ], "hp": "120", "types": [ "Fire" ], "evolvesFrom": "Charmeleon", "attacks": [ { "cost": [ "Fire", "Fire", "Colorless" ], "name": "Fire Spin", "text": "Discard 2 Energy cards attached to this Pokémon in order to use this attack.", "damage": "100", "convertedEnergyCost": 3 } ], "weaknesses": [ { "type": "Water", "value": "×2" } ], "retreatCost": [ "Colorless", "Colorless", "Colorless" ], "convertedRetreatCost": 3, "set": { "id": "xy1", "name": "XY", "series": "XY", "printedTotal": 146, "total": 146, "releaseDate": "2014/03/12", "updatedAt": "2020/08/14 09:39:00" }, "number": "7", "artist": "Hajime Kusajima", "rarity": "Rare Holo", "legalities": { "unlimited": "Legal", "expanded": "Legal" }, "images": { "small": "https://images.pokemontcg.io/xy1/7.png", "large": "https://images.pokemontcg.io/xy1/7_hires.png" } } ] ``` ``` -------------------------------- ### TypeScript Set Class Definition Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Defines the structure of a 'Set' object, representing a Pokemon TCG expansion set. It includes properties like id, name, release date, and total cards. ```typescript id: string; images: ISetImage; legalities: ILegality; name: string; printedTotal: number; ptcgoCode: string; releaseDate: string; series: string; total: number; updatedAt: string; ``` -------------------------------- ### TypeScript IResistance and IWeakness Interface Definition Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Defines the structure for 'Resistance' and 'Weakness' objects, specifying the type and value of resistance or weakness. ```typescript type: string; value: string; ``` -------------------------------- ### Find Pokemon TCG Set by ID (TypeScript) Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Retrieves a single Pokemon card set using its unique identifier. Requires the 'pokemon-tcg-sdk-typescript' package. It takes a set ID as input and returns a Promise that resolves with the Set object or rejects with an error. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Find a specific set by ID PokemonTCG.Set.find('base1') .then((set: PokemonTCG.Set) => { console.log('Set Name:', set.name); // Base console.log('Series:', set.series); // Base console.log('Total Cards:', set.total); // 102 console.log('Printed Total:', set.printedTotal); console.log('Release Date:', set.releaseDate); console.log('PTCGO Code:', set.ptcgoCode); console.log('Symbol:', set.images.symbol); console.log('Logo:', set.images.logo); console.log('Legalities:', set.legalities); }) .catch(error => { console.error('Error fetching set:', error.message); }); ``` -------------------------------- ### TypeScript IAttack Interface Definition Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Defines the structure for an 'Attack' object, detailing a Pokemon's attack. It includes energy cost, name, description, damage, and converted energy cost. ```typescript cost: string[]; name: string; text: string; damage: string; convertedEnergyCost: string; ``` -------------------------------- ### TypeScript Card Class Definition Source: https://github.com/pokemontcg/pokemon-tcg-sdk-typescript/blob/master/README.md Defines the structure of a 'Card' object within the Pokemon TCG SDK. It includes properties like id, name, types, abilities, attacks, and image details. Some properties are optional. ```typescript id: string; name: string; supertype: string; subtypes: string[]; hp?: string; types?: string[]; evolesFrom?: string; evolvesTo?: string[]; rules?: string[]; ancientTrait?: IAncientTrait; abilities?: IAbility[]; attacks?: IAttack[]; weaknesses?: IWeakness[]; resistances?: IResistance[]; retreatCost?: string[]; convertedRetreatCost?: number; set: ISet; number: string; artist?: string; rarity: string; flavorText?: string; nationalPokedexNumbers?: number[]; legalities: ILegality; images: ICardImage; tcgplayer?: ITCGPlayer; cardmarket?: ICardmarket; ``` -------------------------------- ### Define TypeScript Interfaces for Pokemon TCG SDK Source: https://context7.com/pokemontcg/pokemon-tcg-sdk-typescript/llms.txt Defines core TypeScript interfaces for representing Pokemon TCG cards, sets, attacks, abilities, and query parameters. These interfaces ensure type safety when interacting with the Pokemon TCG API. ```typescript import { PokemonTCG } from 'pokemon-tcg-sdk-typescript'; // Card interface interface Card { id: string; name: string; supertype: string; subtypes: string[]; hp?: string; types?: string[]; evolvesFrom?: string; evolvesTo?: string[]; rules?: string[]; abilities?: IAbility[]; attacks?: IAttack[]; weaknesses?: IWeakness[]; resistances?: IResistance[]; retreatCost?: string[]; convertedRetreatCost?: number; set: ISet; number: string; artist?: string; rarity: string; flavorText?: string; nationalPokedexNumbers?: number[]; legalities: ILegality; regulationMark?: string; images: ICardImage; tcgplayer?: ITCGPlayer; cardmarket?: ICardmarket; } // Set interface interface Set { id: string; images: ISetImage; legalities: ILegality; name: string; printedTotal: number; ptcgoCode: string; releaseDate: string; series: string; total: number; updatedAt: string; } // Attack interface interface IAttack { convertedEnergyCost: number; cost: string[]; damage: string; name: string; text: string; } // Ability interface interface IAbility { name: string; text: string; type: string; } // Query interface for searches interface IQuery { name: string; value: string | number; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.