# TCGplayer Marketplace Scraper (`rl1987/tcgplayer-api-scraper`) Actor

Search, browse and price TCGplayer anonymously: keyword search, category or set browse, product detail with seller listings and bucketed price history. Every product row carries market, low, low-with-shipping and median price, set, rarity and release date.

- **URL**: https://apify.com/rl1987/tcgplayer-api-scraper.md
- **Developed by:** [R.L.](https://apify.com/rl1987) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.81 / 1,000 product rows

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## TCGplayer Marketplace Scraper

Scrapes the TCGplayer marketplace through the same JSON API the Android app
uses: keyword search, category/set browse, and per-product detail with optional
seller listings and bucketed price history.

Anonymous — there is no API key, account or login. Prices are USD.

### Three row kinds in one dataset

Every row carries `recordType`, so filter on it before reading anything else.

| `recordType` | What it is | When it appears |
| --- | --- | --- |
| `product` | One product: name, set, rarity, collector number, market/lowest/median price, listing count | Every mode |
| `listing` | One live seller listing: seller, condition, printing, language, quantity, price, shipping | Product-detail mode, when "Also collect seller listings" is on |
| `priceHistory` | One price bucket per SKU: market price, low/high sale price, quantity sold, transactions | Product-detail mode, when "Also collect price history" is on |

The dataset declares a view per row kind (`products`, `listings`,
`priceHistory`), so the console's Output tab can be switched by kind instead of
showing one wide table of mostly-empty columns.

### Modes

#### Search — keyword

One product search per entry in **Search keywords**, relevance-ranked by
TCGplayer's own `sales_dismax` algorithm.

There is deliberately no sort option. A non-empty `sort` on this endpoint does
not reorder the keyword's matches, it *ranks the catalogue instead of filtering
it*: measured 2026-11-22, `q=Charizard` sorted by product name returned
"151 Booster Bundle" first with only 5 of 24 rows mentioning Charizard, against
24 of 24 unsorted. Sorting is therefore not exposed.

A keyword that matches nothing returns zero rows, no error, and a status message
saying so — it does not fall back to a nearby page.

#### Browse — product line and/or set

Give a product line (`pokemon`, `magic`, `yugioh`, `onepiece`, `lorcana`,
`digimon` — the app's own list from `/v1/search/productLines`), a set display
name (`Base Set`), or both. Both together are an intersection, not two sweeps:
`pokemon` + `Base Set` returns Base Set cards.

Both filters are terms TCGplayer applies server-side, and the failure mode is
asymmetric: an unrecognised *set name is ignored*, not matched to nothing. Measured
2026-11-22, `pokemon` + a made-up set name returned the whole Pokemon line
(33,131 products, a full page of rows, HTTP 200) where `pokemon` + `Base Set`
returned 109. A keyword typo returns nothing; a set-name typo returns everything
in the game. Check the row count and the first rows before trusting a browse.

#### Product detail — by product id

One row per TCGplayer product id (the number in a
`tcgplayer.com/product/<id>` URL). Ids are validated before the first request, so
a typo is a message rather than a failure halfway through a billed run.

Two optional enrichments, each billed as its own row kind:

- **Also collect seller listings** — one row per live listing, cheapest first
  including shipping, filtered to the languages you list (English by default).
  `maxListingPages` bounds how deep it goes per product.
- **Also collect price history** — one row per price bucket per SKU. `day` gives
  daily buckets, `quarter` (the default) gives about 30 buckets over roughly the
  last quarter. A SKU with no sales returns no buckets and produces no rows.

`shippingCountry` applies to every mode and decides whose shipping cost is
priced. It changes `lowestPriceWithShipping` and the order of listings; it does
not change which products are returned.

### What the data is, and what it is not

- **`marketPrice` is TCGplayer's own computed figure**, not the cheapest
  listing. It is null for products with too few recent sales to compute one.
- **`lowestPrice` is the cheapest copy of the product**, and ignores `custom`
  listings. The listings endpoint does return custom listings — "deck box only",
  "set of 60 dice" — attached to the same product, so the cheapest thing on a
  product's page and `lowestPrice` can differ by two orders of magnitude. Use
  `priceWithShipping` on the listing rows for what a buyer actually pays.
- **The `sealed` flag and `productTypeId` only mean something on product-detail
  rows.** The same sealed product reports `sealed: true` on `/v2/product/{id}/details`
  and `sealed: false` on the search endpoint, where `productTypeId` is also 0 on
  every row. On search rows, a populated `cardNumber`/`cardType` is what
  identifies a single card.
- **`sellerListable` is TCGplayer's own flag, not a sellability verdict.** The
  search and browse endpoints report `false` for every product — including ones
  with thousands of live listings — while `/v2/product/{id}/details` can report
  `true` for the same product. A `false` reflects the endpoint, not that the
  product cannot be sold.
- **`priceHistory` numbers arrive as strings upstream** and are emitted as
  numbers; every numeric column is a number in every row.
- **`sellerSales` stays a string** because TCGplayer sends buckets such as
  `50000+` for it.
- **A browse with a misspelt set name is not empty** — see the Browse section. The
  set filter is dropped and the whole product line comes back, billed.

### Cost

Billing is pay-per-event: one event per delivered `product`, `listing` or
`priceHistory` row. Rows that are de-duplicated, that resolved nothing, or that
are cut by `maxItems` or the run's maximum total charge are not billed. `maxItems`
counts delivered rows across all three kinds. Actual prices are on the Actor's
Pricing tab in Apify Console.

### Output and auditing

- Default dataset — the rows above; see `.actor/dataset_schema.json` for all
  three views and a description of every column.
- `BILLING_AUDIT` in the default key-value store — rows delivered and charged per
  event for this run, plus any divergence between the ledger's count and the
  platform's, written on every run including one that delivered nothing.
- `failed-requests` dataset — written only when a request exhausted every retry.

### Inputs

| Field | Modes | Meaning |
| --- | --- | --- |
| `mode` | all | `search`, `browse` or `detail` |
| `searchQueries` | search | one keyword per entry |
| `productLines`, `setNames` | browse | category and/or set; both narrow |
| `productIds` | detail | one numeric product id per entry |
| `includeListings`, `listingLanguages`, `maxListingPages` | detail | seller listings |
| `includePriceHistory`, `priceHistoryRange` | detail | bucketed price history |
| `shippingCountry` | all | two-letter ISO code, default `US` |
| `maxPages` | search, browse | pages of 24 per query; pagination stops early when the matches run out |
| `maxItems` | all | stop after this many delivered rows (0 = no limit) |
| `maxConcurrency`, `maxRequestsPerCrawl`, `maxRequestRetries`, `maxSessionRotations` | all | throttling and retry bounds |
| `proxyConfiguration` | all | off by default — see below |

### Proxy

Off by default. TCGplayer serves this API anonymously and answered every
endpoint used here from a plain datacenter IP with no proxy during this build
(2026-11-22). The app's own `User-Agent` is required on two of the four hosts —
`/price/history` and `/v1/product/{id}/listings` answer `403` without it — which
the Actor always sends. Turn on Apify residential proxy only if you start seeing
`403`s or challenge pages.

### Development

```bash
pip install -r requirements.txt
python -m pytest tests -q                     # unit + live contract tests
SDB_OFFLINE=1 python -m pytest tests -q       # unit tests only, no network
python -m src                                 # run locally against a local INPUT.json
```

`tests/fixtures/` holds trimmed real responses captured 2026-11-22; the mapping
tests run against them, so an upstream contract change fails a test instead of
silently emptying a column.

# Actor input Schema

## `mode` (type: `string`):

What this run does. 'Search' runs one keyword query per entry and returns relevance-ranked products. 'Browse' returns every product in a category and/or set. 'Product detail' fetches one record per product id, optionally with its seller listings and its price history. Pick the mode first; only the fields in that mode's section are read.

## `searchQueries` (type: `array`):

Search mode. One product search per line, e.g. 'Charizard' or 'Black Lotus'. Results are relevance-ranked by TCGplayer's own 'sales_dismax' algorithm; there is no sort option because the API's sorted path drops the keyword filter (measured 2026-11-22: sorting q=Charizard by product name returned '151 Booster Bundle' first, 5/24 rows matching, against 24/24 unsorted). A keyword with no matches returns 0 rows and the status message says so.

## `productLines` (type: `array`):

Browse mode. Game/category url names: 'pokemon', 'magic', 'yugioh', 'onepiece', 'lorcana', 'digimon'. The list is the app's own, from /v1/search/productLines. Product line and set filters combine, so 'pokemon' plus 'Base Set' returns Base Set cards only.

## `setNames` (type: `array`):

Browse mode. Exact set display names as TCGplayer spells them, e.g. 'Base Set', 'SWSH04: Vivid Voltage'. IMPORTANT: a set name TCGplayer does not recognise is IGNORED, not matched to nothing. Measured 2026-11-22: 'pokemon' + 'Nope Set That Does Not Exist' returned the whole Pokemon line (33,131 products, HTTP 200, a full billed page), where 'pokemon' + 'Base Set' returned 109. So a typo silently widens the run to a whole game instead of returning nothing - check the row count and the first rows of a browse before trusting it, and prefer this mode for enumerating a set you have spelled correctly.

## `productIds` (type: `array`):

Product detail mode. One TCGplayer product id per line, as a number: the id in a tcgplayer.com/product/<id> URL. Ids are checked before the first request, so a non-numeric entry fails the run with a message instead of midway through. An id TCGplayer does not know returns an empty body and produces no row (it is not billed).

## `includeListings` (type: `boolean`):

Product detail mode. Adds one row per live seller listing for each product, cheapest-first including shipping: seller, condition, printing, language, price, shipping, quantity. Billed as its own 'listing-row' event, so this roughly multiplies the run's cost by the number of listings per product. Off, each product row still carries listingCount, lowestPrice and lowestPriceWithShipping (totalListings is null on product-detail rows; the live count is listingCount).

## `listingLanguages` (type: `array`):

Product detail mode, listings only. Languages to keep, defaulting to English. 'Japanese' narrows a card's listings to its Japanese printing. Ignored unless 'Also collect seller listings' is on.

## `maxListingPages` (type: `integer`):

Product detail mode, listings only. Pages of 24 listings per product. 1 (default) is the first page of cheapest-with-shipping listings, which is what the app itself shows; raise it only when you need the long tail. Each page's rows are billed per listing-row.

## `includePriceHistory` (type: `boolean`):

Product detail mode. Adds one row per price bucket per SKU: market price, low and high sale price, quantity sold and transaction count for that bucket, plus the SKU's all-time totals. Billed as its own 'price-history-row' event, so this roughly multiplies the run's cost by the number of buckets (up to 30 per SKU). Off, each product row still carries current price fields. SKUs with no sales yet come back with an empty bucket list and produce no rows.

## `priceHistoryRange` (type: `string`):

Product detail mode, price history only. Bucket width: 'day' gives daily buckets, 'quarter' (default) gives 30 buckets over roughly the last quarter. Each bucket is one row and one charge, so a wider range with narrower buckets costs more.

## `shippingCountry` (type: `string`):

All modes. Two-letter ISO country code, default US. It decides which sellers' shipping cost is priced, so it changes lowestPriceWithShipping and the listing order - a card that is $0.50 to ship in the US may be $12 to ship to NL. It does not filter which products are returned.

## `maxItems` (type: `integer`):

Stop after this many rows have been DELIVERED across all record types (0 = no limit). Counted by the billing ledger after de-duplication, so it is a limit on what you receive and pay for, not on what the target returned.

## `maxPages` (type: `integer`):

Search and browse modes. Pages of 24 products per keyword or per browse filter; 1 (default) is the first page. Pagination stops early when the match count runs out, so a broad browse (all of Pokemon is ~33,000 products) needs this raised well above 1 to go deep - and each page is billed per product-row.

## `maxConcurrency` (type: `integer`):

Max number of requests processed in parallel. TCGplayer answers this API anonymously and did not rate-limit a handful of parallel requests, but 5 is a polite default; raise it only if you see no 429s.

## `maxRequestsPerCrawl` (type: `integer`):

Safety cap on the total number of HTTP requests in the run, before billing is considered. 0 = unlimited. Useful with a wide browse as a backstop against a runaway pagination loop.

## `maxRequestRetries` (type: `integer`):

Retries per request before it is marked failed. Does NOT bound retries caused by a blocked or rate-limited status code (401/403/429) - see maxSessionRotations for that.

## `maxSessionRotations` (type: `integer`):

How many times one request may be retried with a freshly rotated session and proxy after a blocked status code. Only matters when a proxy is configured; without one, a rotation reuses the same egress.

## `proxyConfiguration` (type: `object`):

Off by default: TCGplayer serves this API anonymously and answered every endpoint from a plain datacenter IP during this build. Switch on Apify residential only if you start seeing 403s or challenge pages.

## Actor input object example

```json
{
  "mode": "search",
  "searchQueries": [
    "Charizard"
  ],
  "productLines": [],
  "setNames": [],
  "productIds": [],
  "includeListings": true,
  "listingLanguages": [
    "English"
  ],
  "maxListingPages": 1,
  "includePriceHistory": true,
  "priceHistoryRange": "quarter",
  "shippingCountry": "US",
  "maxItems": 0,
  "maxPages": 1,
  "maxConcurrency": 5,
  "maxRequestsPerCrawl": 0,
  "maxRequestRetries": 5,
  "maxSessionRotations": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `products` (type: `string`):

Default dataset items. Filter on recordType to split the three kinds; listing and priceHistory rows only exist in product-detail mode with their toggle on.

## `billingAudit` (type: `string`):

End-of-run record of rows delivered and charged per event, and any divergence between the ledger's own counts and the platform's. Written on every run, including one that delivered nothing.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchQueries": [
        "Charizard"
    ],
    "productLines": [],
    "setNames": [],
    "productIds": [],
    "listingLanguages": [
        "English"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("rl1987/tcgplayer-api-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchQueries": ["Charizard"],
    "productLines": [],
    "setNames": [],
    "productIds": [],
    "listingLanguages": ["English"],
}

# Run the Actor and wait for it to finish
run = client.actor("rl1987/tcgplayer-api-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchQueries": [
    "Charizard"
  ],
  "productLines": [],
  "setNames": [],
  "productIds": [],
  "listingLanguages": [
    "English"
  ]
}' |
apify call rl1987/tcgplayer-api-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rl1987/tcgplayer-api-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/rRxYlA3iEAzO1zKj8/builds/qBBaPfs7HHA8qgnXd/openapi.json
