# Costco Product Scraper (`dromb/costco-product-scraper`) Actor

Scrape products, categories and item details from Costco Australia.

- **URL**: https://apify.com/dromb/costco-product-scraper.md
- **Developed by:** [Dmitriy Gyrbu](https://apify.com/dromb) (community)
- **Categories:** Automation, Developer tools, E-commerce
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 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.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## Costco Australia Product Scraper

This Apify Actor allows you to scrape product data, categories, and detailed item information from Costco Australia for price monitoring, product research, market research, availability tracking, and competitive analysis.

### Features

- **Product Search**: Search for products using keywords, sort options, and facet filters.
- **Category Scraping**: List products within a specific category.
- **Detailed Item Info**: Get full specifications, pricing, and availability for a single product.
- **Category Tree**: Explore the Costco category hierarchy.
- **Multi-Method HTTP Fallback**: Automatically tries multiple HTTP clients (httpx, cloudscraper, tls_client, curl_cffi) for maximum success rate.
- **Proxy Support**: Integrated Apify proxy support with country filtering (AU recommended).
- **Browser Cookies Support**: Integration with camoufox for enhanced bypass capabilities.
- **User-Agent Randomization**: Random User-Agent selection for reduced detection risk.
- **Retry Logic**: Automatic retry with exponential backoff for blocked requests.
- **Standardized Infrastructure**: Built on shared apify-wave1 runtime for consistency across actors.

### Operation Guide

#### 1. Product Search
Provide a `Search Query` (e.g., "coffee") to get a list of matching products. You can refine results using `Sort` and `Filters`.

#### 2. Category Scraping
Provide a `Category Code` (e.g., `cos_21.1.2`) to fetch all products in that category. You can also combine this with a search query to search *within* a category.

#### 3. Item Details
Provide a `Product Code` (e.g., `100087` or a product URL) to get exhaustive details for a single item.

#### 4. Category List
Provide a `Parent Category ID` or `Category Level` to get a list of categories. Use `Refresh Categories` to force reload from sitemap and `Include Non-COS Categories` to include brand/promo buckets.

### Examples

You can copy and paste these JSON inputs into the Apify Actor's "JSON" editor for quick testing.

#### Search for "Olive Oil"
Returns a list of olive oil products sorted by relevance.
```json
{
  "operation": "search",
  "query": "olive oil",
  "limit": 10,
  "sort": "relevance",
  "proxyCountry": "AU"
}
````

#### Search for Samsung TVs in Electronics

Returns Samsung TVs filtered by a specific category code.

```json
{
  "operation": "search",
  "query": "tv",
  "categoryCode": "cos_21",
  "filters": ["Brand:Samsung"],
  "sort": "price_asc",
  "limit": 5,
  "proxyCountry": "AU"
}
```

#### Fetch Specific Product Details

Gets full specifications for a product using its code.

```json
{
  "operation": "item",
  "productCode": "100087",
  "proxyCountry": "AU"
}
```

#### List Top-Level Categories

Returns the main category structure of the site.

```json
{
  "operation": "categories",
  "level": 1,
  "limit": 20,
  "proxyCountry": "AU"
}
```

#### List Sub-categories of a Parent

Returns direct children of a specific category.

```json
{
  "operation": "categories",
  "parentId": "cos_2",
  "limit": 50,
  "proxyCountry": "AU"
}
```

### Input Fields

| Field | Required | Description | Example |
|---|---|---|---|
| `operation` | **Required** | Operation to perform: `search`, `category`, `item`, or `categories` | `search` |
| `query` | Optional | Text search query | `tv` |
| `categoryCode` | Optional | Costco category code or URL | `cos_21.1.2` |
| `productCode` | Optional | Product code, slug or URL | `100087` |
| `parentId` | Optional | Parent category ID for listing categories | `cos_2` |
| `level` | Optional | Category depth level | `1` |
| `limit` | Optional | Max items to return | `20` |
| `page` | Optional | Page number | `1` |
| `sort` | Optional | Sort order (`relevance`, `price_asc`, etc.) | `price_asc` |
| `filters` | Optional | Facet filters (`FacetName:FacetValue`) | `Brand:Samsung` |
| `details` | Optional | Include richer normalized fields | `false` |
| `refresh` | Optional | Refresh category cache from sitemap | `false` |
| `includeNonCos` | Optional | Include non-standard category codes | `false` |
| `rawQuery` | Optional | Raw Costco query expression | `tv:relevance` |

### Output Fields

Each product item includes:

- `id`: Product code.
- `name`: Product name.
- `brand`: Brand name.
- `price`: Current price.
- `discount_price`: Discounted price.
- `currency`: Currency (AUD).
- `source_url`: URL to product page.
- `image`: Main product image.
- `images`: List of all product images.
- `in_stock`: Stock availability boolean.
- `description`: Full product description.
- `attributes`: Detailed specifications (materials, dimensions, weight, etc.).
- `breadcrumbs`: Category hierarchy.

### Proxy & Bot Protection

Costco AU uses bot protection. We recommend using **Apify Proxy** with **AU** country.

- **Auto**: Automatically handles proxy selection (currently defaults to Apify proxy).
- **Direct**: Bypasses proxy.
- **Custom**: Uses a provided custom proxy URL.

The actor includes automatic retry logic with exponential backoff for blocked requests (403, 429, 502, 503) and invalid JSON responses.

### Pricing

- **Actor Start**: $0.005 per run
- **Dataset Item**: $0.0004 per item

Free/trial users are limited to 10 result requests per day.

### Limitations

- This scraper is unofficial and not affiliated with Costco.
- Costco may change their API structure without notice.
- Some products may have incomplete data depending on source availability.
- Category codes may change over time; use the categories endpoint to discover current codes.
- High-volume scraping may trigger rate limiting or blocking.

### Disclaimer

This scraper is unofficial and not affiliated with Costco. Users are responsible for complying with Costco's terms of service and applicable laws.

# Actor input Schema

## `operation` (type: `string`):

Operation to perform: search, category, item, or categories.

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

Free-text query (e.g., 'tv' or 'olive oil') for searching products.

## `categoryCode` (type: `string`):

Category code or URL (e.g., cos\_21.1.2) to filter results or list category products.

## `productCode` (type: `string`):

Product code, slug, or full URL for fetching a single item's details.

## `parentId` (type: `string`):

Return only direct children of this category code when listing categories.

## `level` (type: `integer`):

Filter categories by breadcrumb depth.

## `limit` (type: `integer`):

Maximum number of items/categories to return.

## `page` (type: `integer`):

Page number for pagination.

## `sort` (type: `string`):

Sort order: relevance, name\_asc, name\_desc, price\_asc, price\_desc, top\_sellers, top\_rated.

## `filters` (type: `array`):

Facet filters in format 'FacetName:FacetValue'.

## `details` (type: `boolean`):

When true, return richer normalized fields where available.

## `refresh` (type: `boolean`):

Refresh category cache from sitemap when listing categories.

## `includeNonCos` (type: `boolean`):

Include non-standard category codes (brand/promo buckets) when listing categories.

## `rawQuery` (type: `string`):

Raw Costco query expression. Overrides query/sort/category/filter.

## `proxy` (type: `string`):

Proxy configuration: 'direct', 'apify', 'custom', or 'auto'.

## `customProxyUrl` (type: `string`):

URL for custom proxy if 'custom' is selected.

## `proxyCountry` (type: `string`):

Country for the proxy (e.g., 'AU').

## Actor input object example

```json
{
  "operation": "search",
  "limit": 20,
  "page": 1,
  "sort": "relevance",
  "details": false,
  "refresh": false,
  "includeNonCos": false,
  "proxy": "auto",
  "proxyCountry": "AU"
}
```

# Actor output Schema

## `id` (type: `string`):

Product code

## `slug` (type: `string`):

Product slug

## `name` (type: `string`):

Product name

## `brand` (type: `string`):

Brand name

## `source_url` (type: `string`):

URL to product page

## `breadcrumbs` (type: `string`):

Category hierarchy

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

Product category

## `product_category` (type: `string`):

Product category (alias)

## `price` (type: `string`):

Current price

## `discount_price` (type: `string`):

Discounted price

## `currency` (type: `string`):

Currency

## `unit_price` (type: `string`):

Price per unit

## `unit_quantity` (type: `string`):

Unit quantity

## `unit` (type: `string`):

Unit type

## `price_per_unit_price` (type: `string`):

Price per unit (alias)

## `price_per_unit_unit` (type: `string`):

Price per unit type (alias)

## `price_per_unit_quantity` (type: `string`):

Price per unit quantity (alias)

## `size` (type: `string`):

Product size

## `in_stock` (type: `string`):

Availability status

## `stock` (type: `string`):

Stock count

## `stock_status` (type: `string`):

Stock status text

## `description` (type: `string`):

Full product description

## `short_description` (type: `string`):

Short product description

## `ingredients` (type: `string`):

Product ingredients

## `image` (type: `string`):

Main product image

## `images` (type: `string`):

List of product images

## `rating` (type: `string`):

Product rating

## `review_count` (type: `string`):

Number of reviews

## `attributes` (type: `string`):

Detailed specifications

## `price_info` (type: `string`):

Price information array

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("dromb/costco-product-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("dromb/costco-product-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call dromb/costco-product-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=dromb/costco-product-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Costco Product Scraper",
        "description": "Scrape products, categories and item details from Costco Australia.",
        "version": "0.2",
        "x-build-id": "FPV2uo4XKWDXY19rL"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/dromb~costco-product-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-dromb-costco-product-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/dromb~costco-product-scraper/runs": {
            "post": {
                "operationId": "runs-sync-dromb-costco-product-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/dromb~costco-product-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-dromb-costco-product-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "operation": {
                        "title": "Operation",
                        "enum": [
                            "search",
                            "category",
                            "item",
                            "categories"
                        ],
                        "type": "string",
                        "description": "Operation to perform: search, category, item, or categories.",
                        "default": "search"
                    },
                    "query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "Free-text query (e.g., 'tv' or 'olive oil') for searching products."
                    },
                    "categoryCode": {
                        "title": "Category Code",
                        "type": "string",
                        "description": "Category code or URL (e.g., cos_21.1.2) to filter results or list category products."
                    },
                    "productCode": {
                        "title": "Product Code",
                        "type": "string",
                        "description": "Product code, slug, or full URL for fetching a single item's details."
                    },
                    "parentId": {
                        "title": "Parent Category ID",
                        "type": "string",
                        "description": "Return only direct children of this category code when listing categories."
                    },
                    "level": {
                        "title": "Category Level",
                        "type": "integer",
                        "description": "Filter categories by breadcrumb depth."
                    },
                    "limit": {
                        "title": "Limit",
                        "type": "integer",
                        "description": "Maximum number of items/categories to return.",
                        "default": 20
                    },
                    "page": {
                        "title": "Page",
                        "type": "integer",
                        "description": "Page number for pagination.",
                        "default": 1
                    },
                    "sort": {
                        "title": "Sort",
                        "enum": [
                            "relevance",
                            "name_asc",
                            "name_desc",
                            "price_asc",
                            "price_desc",
                            "top_sellers",
                            "top_rated"
                        ],
                        "type": "string",
                        "description": "Sort order: relevance, name_asc, name_desc, price_asc, price_desc, top_sellers, top_rated.",
                        "default": "relevance"
                    },
                    "filters": {
                        "title": "Filters",
                        "type": "array",
                        "description": "Facet filters in format 'FacetName:FacetValue'.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "details": {
                        "title": "Include Details",
                        "type": "boolean",
                        "description": "When true, return richer normalized fields where available.",
                        "default": false
                    },
                    "refresh": {
                        "title": "Refresh Categories",
                        "type": "boolean",
                        "description": "Refresh category cache from sitemap when listing categories.",
                        "default": false
                    },
                    "includeNonCos": {
                        "title": "Include Non-COS Categories",
                        "type": "boolean",
                        "description": "Include non-standard category codes (brand/promo buckets) when listing categories.",
                        "default": false
                    },
                    "rawQuery": {
                        "title": "Raw Query Expression",
                        "type": "string",
                        "description": "Raw Costco query expression. Overrides query/sort/category/filter."
                    },
                    "proxy": {
                        "title": "Proxy Configuration",
                        "enum": [
                            "direct",
                            "apify",
                            "custom",
                            "auto"
                        ],
                        "type": "string",
                        "description": "Proxy configuration: 'direct', 'apify', 'custom', or 'auto'.",
                        "default": "auto"
                    },
                    "customProxyUrl": {
                        "title": "Custom Proxy URL",
                        "type": "string",
                        "description": "URL for custom proxy if 'custom' is selected."
                    },
                    "proxyCountry": {
                        "title": "Proxy Country",
                        "type": "string",
                        "description": "Country for the proxy (e.g., 'AU').",
                        "default": "AU"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
