# Pottery Barn Product Scraper (`crawlerbros/potterybarn-scraper`) Actor

Scrape PotteryBarn.com (Williams-Sonoma) - US furniture & home decor. Browse by category or keyword via the product sitemap, or fetch products by direct URL; parses prices, images, availability, SKUs and category paths from server-rendered state.

- **URL**: https://apify.com/crawlerbros/potterybarn-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** E-commerce, Automation, Integrations
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Pottery Barn Product Scraper

Scrape [PotteryBarn.com](https://www.potterybarn.com/) — Williams-Sonoma's US furniture & home-decor e-commerce. Product discovery is **sitemap-driven**: live product URLs come from the public product sitemap (16k+ URLs), so the actor never relies on JS-rendered category grids or site search. Product details (prices, images, availability, SKUs, category breadcrumbs) are parsed from the server-rendered `window.__INITIAL_STATE__` payload of each product page. Direct **product URLs** are also accepted.

### Why sitemap-driven?

The category/search result grids are JS-rendered (absent from the plain HTML). The product sitemap — `netstorage/sitemaps/product-sitemap-1.xml.gz` — is publicly served and lists ~16,706 live product URLs, sidestepping that problem entirely. Stale/dead deep links that redirect to the homepage are never used.

### What this actor does

- **Three modes:** `byCategory` (default), `byKeyword`, `byProductUrls`
- **13 shop categories** as a dropdown (furniture, bedding, rugs, lighting, outdoor, …)
- **curl\_cffi (chrome131 impersonation)** as the primary fetcher — fast and cheap when it gets through
- **Automatic anti-bot escalation:** lazy-engages Apify AUTO datacenter proxy on block, rotates to a fresh exit IP after repeated blocks, and escalates to Apify RESIDENTIAL proxy if AUTO stays blocked. If curl\_cffi (even with residential) can't get real data through in a fair trial, the actor automatically falls back to a real anti-detect browser (Camoufox + residential proxy) for the rest of the run — no user configuration needed either way
- **Filters:** price range (selling price), title/category keyword, in-stock-only
- **Bounded discovery:** `byCategory` / `byKeyword` walk the sitemap in order (fetch budget = `max(1500, maxItems×50)` pages, walked 8 URLs concurrently) and keep records matching the category path / keyword, stopping at `maxItems`
- **Empty fields are omitted**; every record carries `sourceUrl`, `scrapedAt`, `recordType`

### Output per product

- `productId` (group id), `title`, `sku` (leader SKU)
- `description` (SEO materials copy from `<meta name="description">`)
- `price` (low selling), `priceMax` (high selling), `regularPrice`, `retailPrice`, `wasPrice` (when retail > selling)
- `brand` (Pottery Barn), `categoryPath[]`, `categoryUrl`, `superCategoryId` (canonical shop-category slug)
- `availability`, `skuCount`
- `images[]` (pbimgs CDN URLs), `imageUrl`
- `productUrl`, `recordType`, `scrapedAt`

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `mode` | select | `byCategory` | `byCategory` / `byKeyword` / `byProductUrls` |
| `category` | select | `furniture` | Shop category (13 options) |
| `searchQuery` | string | `vanity` | Keyword (mode=byKeyword) |
| `productUrls` | array | – | Product URLs (mode=byProductUrls) |
| `priceMin` / `priceMax` | int | – | Selling-price range (USD) |
| `containsKeyword` | string | – | Title/category substring filter |
| `inStockOnly` | bool | `false` | Only available products |
| `maxItems` | int | `20` | Hard cap (1–500) |

#### Example: furniture under $500, in stock

```json
{
  "mode": "byCategory",
  "category": "furniture",
  "priceMax": 500,
  "inStockOnly": true,
  "maxItems": 10
}
```

#### Example: keyword match

```json
{
  "mode": "byKeyword",
  "searchQuery": "vanity",
  "maxItems": 10
}
```

#### Example: direct URLs

```json
{
  "mode": "byProductUrls",
  "productUrls": ["https://www.potterybarn.com/products/sausalito-dressing-vanity/"]
}
```

### Image URLs

Product images are served from `assets.pbimgs.com` — verified `HTTP 200 image/jpeg` from a clean shell (no Referer/cookies), so they are shipped as-is.

### Anti-bot notes

- Pottery Barn sits behind Akamai bot management, which can escalate from simple IP-reputation blocking (fixed by proxy rotation) up to a JS-sensor challenge (`_abck`) that no static HTTP client can satisfy regardless of IP quality or TLS fingerprint — only a real browser executing Akamai's JS clears that. The actor handles both: curl\_cffi + proxy rotation for the common case, Camoufox (anti-detect Firefox) + residential proxy as an automatic fallback for the JS-sensor case.
- The fallback triggers on a success-rate probe (first 3 batches of the sitemap walk, or the first few `byProductUrls` requests) rather than a strict "zero successes" check, so an occasional lucky curl\_cffi request doesn't mask a mostly-blocked run and disable the fallback.
- Ratings require the JS review widget (Bazaarvoice), which is not rendered server-side and is disabled for Pottery Barn desktop in some regions — `rating`/`reviewCount` are not shipped in v1 (documented, not sentinel).

### Data source

potterybarn.com product pages (`window.__INITIAL_STATE__.product.productDetails`) + public product sitemap. No login required.

### Limitations

- `byCategory` / `byKeyword` walk the sitemap with a bounded fetch budget (budget = `max(1500, maxItems×50)`); all 13 dropdown categories are reachable at the default `maxItems=20` — for keywords that match extremely deep in the sitemap (past ~1500 URLs), raise `maxItems` to widen the budget. Category membership is matched on the canonical `superCategoryId` slug (with breadcrumb-label aliases as fallback).
- The `category` enum contains only the 13 categories that actually appear as `superCategoryId` on product pages. Pottery Barn's "New", "Sale", "Registry", "PB Apartment" and "Small-Space Furniture" sections are curated landing pages, not product categories — products there carry their real category ID (e.g. `furniture`), so they are not offered as `byCategory` options; use `byKeyword` (e.g. `sale`, `outlet`) or direct product URLs to reach those products.
- If every candidate page within the budget is filtered out, the actor soft-fails with a status message instead of silently dropping. Invalid product URLs in `byProductUrls` produce typed `recordType: "error"` records; duplicate URLs in the input are deduplicated to single records.

# Actor input Schema

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

What to fetch.

## `category` (type: `string`):

Pottery Barn top-level shop category.

## `searchQuery` (type: `string`):

Free-text keyword for site search.

## `productUrls` (type: `array`):

Full Pottery Barn product URLs, e.g. https://www.potterybarn.com/products/sausalito-dressing-vanity/

## `priceMin` (type: `integer`):

Drop products selling below this price (USD).

## `priceMax` (type: `integer`):

Drop products selling above this price (USD).

## `containsKeyword` (type: `string`):

Only keep products whose title, brand or category path contains this substring (case-insensitive).

## `inStockOnly` (type: `boolean`):

Only emit products currently available to order.

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

Hard cap on emitted records.

## Actor input object example

```json
{
  "mode": "byCategory",
  "category": "furniture",
  "searchQuery": "vanity",
  "productUrls": [],
  "inStockOnly": false,
  "maxItems": 20
}
```

# Actor output Schema

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

Dataset containing all scraped Pottery Barn products.

# 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 = {
    "mode": "byCategory",
    "category": "furniture",
    "searchQuery": "vanity",
    "productUrls": [],
    "inStockOnly": false,
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/potterybarn-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 = {
    "mode": "byCategory",
    "category": "furniture",
    "searchQuery": "vanity",
    "productUrls": [],
    "inStockOnly": False,
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/potterybarn-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 '{
  "mode": "byCategory",
  "category": "furniture",
  "searchQuery": "vanity",
  "productUrls": [],
  "inStockOnly": false,
  "maxItems": 20
}' |
apify call crawlerbros/potterybarn-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,crawlerbros/potterybarn-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/ycyHKKhJcDb5BSAKa/builds/COM6tEMSOP2xykSf1/openapi.json
