# BrickLink Scraper - LEGO Catalog & Price Guide (`jongoose/bricklink-scraper`) Actor

Scrape the BrickLink LEGO catalog + price guide: item no, name, type, category, image, and current-market New/Used min, average, qty-average & max prices with quantities and seller counts. Search by keyword and item type (Set/Part/Minifig/Book). No account or API key.

- **URL**: https://apify.com/jongoose/bricklink-scraper.md
- **Developed by:** [James Scott](https://apify.com/jongoose) (community)
- **Categories:** E-commerce, Lead generation
- **Features:** Limited permissions
- **Stats:** 12 total users, 2 monthly users, 99.4% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## BrickLink Scraper - LEGO Catalog & Price Guide

Scrape the **BrickLink** LEGO catalog and its **price guide** into clean, structured data - no BrickLink account or API key required. For every catalog item you get its identity (number, name, type, category, image) plus the **current-market price guide**: New and Used **min / average / qty-average / max** prices, quantities and seller counts, computed from every live listing.

### What you get (per item)

- **Item number** (`75300-1`, `3001`, `sw0599`), **name**, **type** (Set / Part / Minifig / Book / Gear / ...), **BrickLink category id**
- Canonical **catalog URL** and **image URL**
- **Currency** (`USD` - all prices are BrickLink's US$-normalized figures)
- **New** price guide: `newMinPrice`, `newAvgPrice`, `newQtyAvgPrice`, `newMaxPrice`, `newTotalQty`, `newLots`, `newSellerCount`
- **Used** price guide: `usedMinPrice`, `usedAvgPrice`, `usedQtyAvgPrice`, `usedMaxPrice`, `usedTotalQty`, `usedLots`, `usedSellerCount`
- `priceGuideSource` - `current_market` when the detailed per-item price guide was fetched, else `search_summary` (min/max/qty only)

The New/Used min-average-qty-average-max figures mirror BrickLink's **"Current Items for Sale"** price-guide tables - the numbers resellers price against day to day.

### Input

- **Search keyword** - e.g. `star wars`, `millennium falcon`, `75300`, or a part number like `3001`.
- **Item type** - Set, Part, Minifig, Book, Gear, Catalog, Instruction, or **Any** (scans Set/Part/Minifig/Book).
- **BrickLink search URLs** - or paste catalog/search URLs; the keyword is read from each URL's `?q=` parameter.
- **Fetch detailed price guide per item** - ON (default) computes exact averages from every live listing (one extra bounded request per item); OFF keeps only the search min/max/qty summary (faster/cheaper).
- **Max items** caps the run.

#### Example input

```json
{
  "query": "star wars",
  "itemType": "S",
  "priceGuideDetail": true,
  "maxItems": 200,
  "proxyConfiguration": { "useApifyProxy": true }
}
```

#### Example output record (real, live)

```json
{
  "itemNo": "75407-1",
  "itemName": "Brick-Built Star Wars Logo",
  "itemType": "Set",
  "itemTypeCode": "S",
  "categoryId": "65.169",
  "yearReleased": null,
  "url": "https://www.bricklink.com/v2/catalog/catalogitem.page?S=75407-1",
  "imageUrl": "https://img.bricklink.com/ItemImage/SN/0/75407-1.png",
  "currency": "USD",
  "newMinPrice": 38.34,
  "newAvgPrice": 67.1586,
  "newQtyAvgPrice": 65.4792,
  "newMaxPrice": 120.55,
  "newTotalQty": 272,
  "newLots": 104,
  "newSellerCount": 101,
  "usedMinPrice": 29.99,
  "usedAvgPrice": 41.268,
  "usedQtyAvgPrice": 41.268,
  "usedMaxPrice": 57.16,
  "usedTotalQty": 5,
  "usedLots": 5,
  "usedSellerCount": 4,
  "priceGuideSource": "current_market",
  "priceGuideSampled": false,
  "soldPriceGuide": null,
  "scrapedFrom": "bricklink.com"
}
```

### How it works

- **Search** - `GET /ajax/clone/search/searchproduct.ajax` paginates the catalog for your keyword + item type. Each row already carries a current New/Used min-max-qty-seller summary.
- **Price guide** - for each item, one bounded `GET /ajax/clone/catalogifs.ajax` pulls the whole current for-sale book (up to 500 listings, price-sorted), and the actor computes the New/Used min/avg/qty-avg/max/total-qty/lots.

Both are BrickLink's own internal JSON handlers, so the actor parses **structured JSON, not brittle CSS**, and runs on Apify's default **datacenter** proxy (no pricey residential proxy).

### Known limitation - historical "sold" data

BrickLink's **"Last 6 Months Sold"** price-guide quadrants live only on the classic `catalogPG.asp` page, which is protected by an **AWS WAF JavaScript challenge** and cannot be reached by a plain HTTP client. This actor therefore captures the **current-market** price guide (live listings) and emits `soldPriceGuide` as `null`. Adding sold data would require a headless browser to solve the WAF challenge and mint an `aws-waf-token` cookie before calling `catalogPG.asp`; it is intentionally out of scope for this JSON-only, proxy-light actor.

`yearReleased` is likewise only on the WAF-gated detail page and is emitted as `null`; `categoryId` is BrickLink's stable catalog category identifier (name resolution also requires the gated catalog).

### Why this actor

- **Real price intelligence:** New/Used averages, ranges, quantities and seller depth for any LEGO set, part or minifig.
- **Fast + cheap:** BrickLink's own JSON, one bounded request per item, default datacenter proxy.
- **Durable:** structured JSON handlers, not CSS selectors.
- Export as JSON, CSV, or Excel, or pull via the Apify API.

Great for **LEGO resellers, collectors and analysts** doing pricing, sell-through and inventory-valuation research.

This is public catalog data provided for research; it is **not** affiliated with or endorsed by BrickLink or the LEGO Group.

# Actor input Schema

## `query` (type: `string`):

Keyword to search the BrickLink catalog for, e.g. "star wars", "75300", "millennium falcon", or a part number like "3001". Leave empty (and provide no Start URLs) to browse the whole catalog for the chosen item type.

## `itemType` (type: `string`):

Which BrickLink catalog type to search. Choose "Any" to scan Sets, Parts, Minifigs and Books.

## `startUrls` (type: `array`):

Optional. Paste one or more BrickLink search/catalog URLs; a keyword is derived from each URL's ?q= parameter or its last path segment. Leave empty to search by the Keyword above.

## `priceGuideDetail` (type: `boolean`):

ON (recommended): make one extra bounded request per item to compute exact current-market New/Used min, average, qty-average and max prices from every live listing. OFF: faster/cheaper - keep only the min/max/qty summary that comes with search results (no averages).

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

Stop after collecting this many catalog items.

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

BrickLink's catalog JSON works fine through Apify's default (datacenter) proxy - no residential proxy needed.

## Actor input object example

```json
{
  "query": "star wars",
  "itemType": "S",
  "startUrls": [],
  "priceGuideDetail": true,
  "maxItems": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# 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 = {
    "query": "star wars",
    "startUrls": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("jongoose/bricklink-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 = {
    "query": "star wars",
    "startUrls": [],
}

# Run the Actor and wait for it to finish
run = client.actor("jongoose/bricklink-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 '{
  "query": "star wars",
  "startUrls": []
}' |
apify call jongoose/bricklink-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jongoose/bricklink-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/5dgU0KlC4h6eDnQUY/builds/wCeOh7p0gia8dOfiU/openapi.json
