npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tcgpricelookup/sdk

v0.1.0

Published

Official JavaScript / TypeScript SDK for the TCG Price Lookup API — live trading card prices for Pokemon, MTG, Yu-Gi-Oh!, One Piece, Lorcana, Star Wars: Unlimited, Flesh and Blood, and Pokemon Japan.

Readme

@tcgpricelookup/sdk

npm version license

Official JavaScript / TypeScript SDK for the TCG Price Lookup API — live trading card prices for Pokemon, Magic: The Gathering, Yu-Gi-Oh!, One Piece, Disney Lorcana, Star Wars: Unlimited, Flesh and Blood, and Pokemon Japan, with TCGPlayer market data, real eBay sold-listing averages, and PSA / BGS / CGC graded values.

  • Fully typed against the production API response shapes
  • Zero runtime dependencies, native fetch, ESM + CJS
  • Works in Node 18+, browsers, Cloudflare Workers, Bun, Deno
  • Auto-chunks batch ID lookups beyond the backend's 20-per-request cap
  • Typed errors (AuthenticationError, PlanAccessError, RateLimitError, …)
  • Optional retry-with-backoff for 429 and 5xx responses

Get a free API key: https://tcgpricelookup.com/tcg-api


Installation

npm install @tcgpricelookup/sdk
# or
pnpm add @tcgpricelookup/sdk
# or
yarn add @tcgpricelookup/sdk

Quickstart

import { TcgLookupClient } from "@tcgpricelookup/sdk";

const tcg = new TcgLookupClient({ apiKey: process.env.TCG_API_KEY! });

const { data } = await tcg.cards.search({ q: "charizard", game: "pokemon" });
for (const card of data) {
  console.log(card.name, card.set.name, card.prices.raw.near_mint?.tcgplayer?.market);
}

The first time you call the API you'll need a key — sign up at https://tcgpricelookup.com/tcg-api (no credit card on the Free tier).

Examples

Search cards

const res = await tcg.cards.search({
  q: "charizard",
  game: "pokemon",
  set: "obsidian-flames",
  limit: 20,
});
console.log(res.total, "matches");

Get a single card

const card = await tcg.cards.get("019535a1-d5d0-7c12-a3e8-b7f4c6d8e9a2");
console.log(card.prices.raw.near_mint?.tcgplayer?.market);
console.log(card.prices.graded?.psa?.["10"]?.ebay?.avg_7d); // Trader plan and above

Batch lookup (auto-chunks at 20)

// Pass as many IDs as you want — the SDK transparently splits into 20-per-call
// requests and merges the results.
const portfolio = ["id-1", "id-2", /* … 50 ids … */];
const { data } = await tcg.cards.search({ ids: portfolio });
const total = data.reduce(
  (sum, c) => sum + (c.prices.raw.near_mint?.tcgplayer?.market ?? 0),
  0
);
console.log(`Portfolio value: $${total.toFixed(2)}`);

Price history (Trader plan and above)

import { PlanAccessError } from "@tcgpricelookup/sdk";

try {
  const history = await tcg.cards.history(card.id, { period: "30d" });
  for (const day of history.data) {
    const tcgRow = day.prices.find((p) => p.source === "tcgplayer" && p.condition === "near_mint");
    console.log(day.date, tcgRow?.price_market);
  }
} catch (err) {
  if (err instanceof PlanAccessError) {
    console.log("Upgrade to Trader to access price history");
  } else {
    throw err;
  }
}

List sets / games

const sets = await tcg.sets.list({ game: "pokemon", limit: 10 });
const games = await tcg.games.list();

Read rate-limit info

await tcg.cards.search({ q: "pikachu" });
console.log(tcg.rateLimit); // { limit: 100000, remaining: 99987 }

Retry on 429 / 5xx

Off by default — opt in explicitly:

const tcg = new TcgLookupClient({
  apiKey: process.env.TCG_API_KEY!,
  retry: { attempts: 3, baseDelayMs: 500 },
});

Error handling

Every non-2xx response is mapped to a typed error you can instanceof-check:

| Status | Class | Meaning | |------- |------------------------|--------------------------------------------------------------| | 401 | AuthenticationError | Missing or invalid API key | | 403 | PlanAccessError | Your plan does not include this resource (e.g. history on Free) | | 404 | NotFoundError | Card / set / game does not exist | | 429 | RateLimitError | Daily quota or burst limit exceeded | | 5xx | TcgLookupError | Upstream error |

All of them extend TcgLookupError and expose .status, .url, .body, and .message.

import { TcgLookupClient, RateLimitError } from "@tcgpricelookup/sdk";

try {
  await tcg.cards.search({ q: "pikachu" });
} catch (err) {
  if (err instanceof RateLimitError) {
    console.log("Slow down. Backend says:", err.message);
  } else {
    throw err;
  }
}

Supported games

| Slug | Game | |--------------|-------------------------| | pokemon | Pokémon (English) | | pokemon-jp | Pokémon Japan | | mtg | Magic: The Gathering | | yugioh | Yu-Gi-Oh! | | onepiece | One Piece Card Game | | lorcana | Disney Lorcana | | swu | Star Wars: Unlimited | | fab | Flesh and Blood |

Plan tiers

The Free tier returns raw TCGPlayer prices only. The ebay price block, graded price block, and the cards.history() endpoint require the Trader plan or above. The SDK surfaces this as a PlanAccessError (HTTP 403) so you can branch in code.

See https://tcgpricelookup.com/pricing for current quotas.

API reference

The full HTTP API reference, parameters, and response shapes live at https://tcgpricelookup.com/docs/api-reference.

License

MIT © TCG Price Lookup