# Woocommerce Public Products (`eichan/woocommerce-public-products`) Actor

- **URL**: https://apify.com/eichan/woocommerce-public-products.md
- **Developed by:** [Eichan Jolly](https://apify.com/eichan) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 87.5% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.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

## WooCommerce Public Products

**One small job:** Get at most 5 (default) published product records from a WooCommerce store's *public*, unauthenticated Store API. One store, one HTTP request, one page, up to 50 items. No checkout, authentication, private WooCommerce REST API, or multi-store crawling.

**For:** Store owners, catalog integrators, or developers who need a tiny product feed sample, not a bulk crawler.

### First-run example (real public store)

The Console **prefill** is:

```json
{"store_url":"https://www.cancork.com","limit":5}
```

On **2026-11-01**, the public product collection at `https://www.cancork.com/wp-json/wc/store/v1/products?per_page=1` returned a non-empty product JSON response, including a product called *Warm Wall Textures*. The Actor requests `page=1&per_page=5` with the same documented WooCommerce API. The demo is a third-party live store: its owner can change products, block API clients, or take it offline. The exact 5-item response was not tested on the Apify platform; this is not a guaranteed fixture. If it stops working, replace the store URL with one you own or are authorized to query.

Sample normalized dataset item (illustrative snapshot, not a guaranteed live response):

```json
{"product_id":185296,"name":"Warm Wall Textures","slug":"warm-wall-textures","permalink":"https://www.cancork.com/sample-sets/warm-wall-textures/","price":"9.95","currency":"CAD"}
```

**Output fields:** `product_id` (integer), `name` (string), `slug` (string or null), `permalink` (string or null), `price` (decimal **string** or null), `currency` (ISO currency string or null). One dataset item per product; missing optional fields are `null`. `price` is computed as raw Store API `prices.price / (10 ** currency_minor_unit)` using decimal arithmetic; for example `995` with 2 minor units becomes `"9.95"`, not `"995"`.

### Run locally (no SDK)

```bash
ACTOR_INPUT_JSON='{"store_url":"https://www.cancork.com","limit":1}' python src/main.py
```

Or place the JSON in `storage/key_value_stores/default/INPUT.json` and run `python src/main.py`. Local results go to `storage/datasets/default/000000001.json`, `000000002.json`, etc. When Apify supplies `APIFY_TOKEN` and the run's `ACTOR_DEFAULT_DATASET_ID`, records are posted to the default dataset through Apify's REST API. When Apify supplies a default key-value store ID, input is read from the `INPUT` record. No SDK is needed.

### Limitations and care

- Requires a public HTTPS WooCommerce root that exposes `GET /wp-json/wc/store/v1/products`; not all installations expose it. Subdirectory WordPress installations may use their installation root. No login or access-control bypass.
- **One page / one store / maximum 50 products.** No pagination, cart requests, discovery crawling, or variant enrichment. The first page's order is store-defined.
- Does not request other hosts: custom redirects are rejected. Public DNS addresses only; private, localhost, Amazon and eBay are excluded. Bounded response: 2 MB and 15 seconds.
- If a live store returns 403/404 or HTML, the Actor reports a plain-language error and writes no invented results. The publisher's demo domain is not controlled by this project.
- Respect site terms and request limits. One request per run is intentional. No retries, proxies, or browser automation.
- Local unit tests and **script-mode offline smoke tests** are shipped in `tests/`. The smoke uses a declared simulated HTTP response so the CLI path can be exercised without internet access; it is **not evidence of a live Apify run**.

### Store categories and pricing (proposal only)

- **Apify Store categories (declare on Store listing):** `ECOMMERCE`, `SCRAPING`.
- **Suggested pricing:** **$3 per 1,000 emitted dataset items** (equivalent $0.003/item), subject to Apify's current pricing-model availability and minimums. No billing or publishing is configured.

### Verification

Run `python -m unittest discover -s tests -v` from the Actor directory; run `python tests/smoke.py` to execute **`python src/main.py`** with a valid actual-domain input and mocked HTTP fixture. This is a repeatable offline execution check. See Batch 2's root `VERIFICATION.md` for the captured terminal output and item.

**API documentation:** https://developer.woocommerce.com/docs/apis/store-api/resources-endpoints/products/

# Actor input Schema

## `store_url` (type: `string`):

Public HTTPS WooCommerce store home URL (or WordPress installation root).

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

One page only. No pagination.

## Actor input object example

```json
{
  "store_url": "https://woocommerce.com",
  "limit": 5
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing the Actor's result items

# 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 = {
    "store_url": "https://woocommerce.com"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eichan/woocommerce-public-products").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 = { "store_url": "https://woocommerce.com" }

# Run the Actor and wait for it to finish
run = client.actor("eichan/woocommerce-public-products").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 '{
  "store_url": "https://woocommerce.com"
}' |
apify call eichan/woocommerce-public-products --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eichan/woocommerce-public-products"
        }
    }
}
```

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/JjfDgrssgF8yrIKso/builds/srFIuwovF0iNiJ4Iw/openapi.json
