{"id":16489,"library":"pokemon-tcg-pocket-database","title":"Pokemon TCG Pocket Database","description":"This npm package, currently at version 2.5.1, provides a comprehensive JSON database for the Pokémon Trading Card Game Pocket. It offers various data files including `cards.json` (basic card info), `cards.extra.json` (detailed card info), `sets.json` (grouped by series), `rarities.json`, and `pullRates.json`. The package frequently updates to incorporate new sets, cards, and game data as they are released in Pokémon TCG Pocket. Key differentiators include its specific focus on the TCG Pocket game (distinct from the main Pokémon TCG) and providing multiple data formats like minified (`.min.json`) and image-stripped (`.no-image.min.json`) versions to optimize bandwidth. Additionally, card images are organized into a predictable `cards-by-set` directory structure for easier programmatic access.","status":"active","version":"2.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/flibustier/pokemon-tcg-pocket-database","tags":["javascript","pokemon","pokemon tcg","pokemon pocket","Pokemon TCG Pocket","pokemon tcgp","pokemon cards","PTCGP"],"install":[{"cmd":"npm install pokemon-tcg-pocket-database","lang":"bash","label":"npm"},{"cmd":"yarn add pokemon-tcg-pocket-database","lang":"bash","label":"yarn"},{"cmd":"pnpm add pokemon-tcg-pocket-database","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"JSON files are direct module imports; named imports from the root package are incorrect. Prefer `cards.min.json` for reduced size.","wrong":"import { cards } from 'pokemon-tcg-pocket-database';","symbol":"cards","correct":"import cards from 'pokemon-tcg-pocket-database/dist/cards.json';"},{"note":"While Node.js 16+ supports 'require' for JSON, ESM `import` is the recommended and future-proof approach for direct JSON file access in modern JavaScript/TypeScript projects.","wrong":"const sets = require('pokemon-tcg-pocket-database/dist/sets.json');","symbol":"sets","correct":"import sets from 'pokemon-tcg-pocket-database/dist/sets.json';"},{"note":"Always specify the full path including `/dist/` as the package entry points for data files are not at the root. Direct JSON imports require proper bundler/TypeScript configuration.","wrong":"import rarities from 'pokemon-tcg-pocket-database/rarities.json';","symbol":"rarities","correct":"import rarities from 'pokemon-tcg-pocket-database/dist/rarities.json';"}],"quickstart":{"code":"import sets from 'pokemon-tcg-pocket-database/dist/sets.json';\nimport cards from 'pokemon-tcg-pocket-database/dist/cards.min.json';\nimport rarities from 'pokemon-tcg-pocket-database/dist/rarities.json';\n\n// Log basic database information\nconsole.log(`Total sets available: ${Object.keys(sets).length}`);\nconsole.log(`Total cards available: ${cards.length}`);\nconsole.log(`Total rarities defined: ${Object.keys(rarities).length}`);\n\n// Example: Find the first set and some of its cards\nconst firstSeriesKey = Object.keys(sets)[0]; // e.g., 'A'\nconst firstSetInSeries = sets[firstSeriesKey] ? sets[firstSeriesKey][0] : null;\n\nif (firstSetInSeries) {\n  console.log(`\\nFirst set in database: ${firstSetInSeries.name} (${firstSetInSeries.id})`);\n  const cardsInFirstSet = cards.filter(card => card.set === firstSetInSeries.id);\n  console.log(`Cards in ${firstSetInSeries.name}: ${cardsInFirstSet.slice(0, 3).map(c => c.name).join(', ')}...`);\n\n  // Example of calculating an image path (v2.1.0+ structure)\n  if (cardsInFirstSet.length > 0) {\n    const exampleCard = cardsInFirstSet[0];\n    const imagePath = `cards-by-set/${exampleCard.set}/${exampleCard.number}.webp`;\n    console.log(`Example image path for '${exampleCard.name}': ${imagePath}`);\n  }\n}\n\n// Example: Accessing a specific rarity\nconst commonRarity = rarities['C'];\nif (commonRarity) {\n  console.log(`\\nRarity 'C' details: Name = ${commonRarity.name}, Cost = ${commonRarity.cost}`);\n}","lang":"typescript","description":"Demonstrates how to import the various JSON data files and access basic information about sets, cards, and rarities, including generating card image paths."},"warnings":[{"fix":"Refer to the `CHANGELOG.md` file in the repository for the migration guide from v1 to v2, specifically the '2.0.0 - Scizor: Reduce and Split' entry.","message":"Version 2.0.0 introduced significant breaking changes, requiring a migration guide. This includes changes to data structures and file organization from v1.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"For smaller bundles without card images, use `cards.no-image.min.json`. To programmatically access images, construct paths using `cards-by-set/${card.set}/${card.number}.webp`.","message":"The `image` field in `cards.min.json` was removed in v2.1.0. The package also introduced `cards.no-image.min.json` and standardized image paths into a new directory structure.","severity":"breaking","affected_versions":">=2.1.0"},{"fix":"Update any code relying on the `packs` field on card objects. Review card data structures if migrating from versions prior to 2.2.0.","message":"The `packs` field was removed from card objects in `cards.json` and its variants starting from v2.2.0, as it was often empty or redundant.","severity":"breaking","affected_versions":">=2.2.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you are using an ESM environment with Node.js 16+ or a bundler configured to handle direct JSON imports. For TypeScript, add `\"resolveJsonModule\": true` and `\"esModuleInterop\": true` to your `tsconfig.json`.","cause":"Incorrect import path or missing JSON module resolution configuration for CommonJS environments or TypeScript projects.","error":"Cannot find module 'pokemon-tcg-pocket-database/dist/cards.json'"},{"fix":"Update image path generation logic to `cards-by-set/${card.set}/${card.number}.webp`. Verify the base path where the `cards-by-set` directory is located relative to your assets.","cause":"The image asset path structure changed significantly in v2.1.0, moving to a `cards-by-set` directory with predictable `set/number.webp` naming.","error":"Image not found when attempting to load a card asset (e.g., '.../assets/A1/card-1.webp')"}],"ecosystem":"npm"}