# Halfords UK Product Scraper (`dromb/halfords-uk-scraper`) Actor

Search Halfords UK products, scrape public category listings, fetch exact product IDs, and collect normalized prices, URLs, images, and available product metadata.

- **URL**: https://apify.com/dromb/halfords-uk-scraper.md
- **Developed by:** [Dmitriy Gyrbu](https://apify.com/dromb) (community)
- **Categories:** Automation, Developer tools, E-commerce
- **Stats:** 2 total users, 1 monthly users, 78.6% 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.
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

## Halfords UK Product Scraper

Scrape Halfords UK product listings and exact product IDs into clean, normalized records for price monitoring, catalog research, ecommerce analysis, and product discovery.

The Actor has a **credential-free public mode** for normal buyer workflows. Search, public category URLs/paths, and exact product IDs can currently run without a Halfords SLAS secret. An optional SLAS credential enables the authenticated API path for advanced controls such as numeric category IDs and API pagination/filtering.

### What you can collect

- Product IDs and names
- Current and regular/list prices when exposed by the source
- Discount price when a lower current price is visible
- Currency
- Product page URLs
- Product images
- Brand, stock status, rating, review count, category ID, and barcode when the selected source path exposes them

Missing retailer data is returned as `null` or omitted; the Actor does not invent unavailable values.

### Supported workflows

#### 1. Search products

Use `query` for keyword search.

```json
{
  "query": "engine oil",
  "limit": 10
}
```

The credential-free public route currently uses Halfords' public HTML and is intended for the first native listing page. `limit` caps how many matching rows are returned.

#### 2. Scrape a public category

`category_url` is the clearest option:

```json
{
  "category_url": "https://www.halfords.com/motoring/engine-oils-and-fluids/engine-oil/",
  "limit": 10
}
```

You can also provide a public path with `category_slug`:

```json
{
  "category_slug": "/motoring/engine-oils-and-fluids/engine-oil/",
  "limit": 10
}
```

#### 3. Fetch exact products by ID

Use `product_ids` for one or more Halfords product/SKU IDs:

```json
{
  "product_ids": ["224411"]
}
```

In credential-free mode the Actor resolves only exact matching IDs and does not substitute a fuzzy product.

#### 4. Authenticated API mode (advanced)

If you already have a valid Halfords SLAS client credential, provide `slas_secret` or the `HALFORDS_SLAS_SECRET` environment variable. This enables the internal API route used for numeric `category_id`, API pagination, sort options, filters, and richer fields where Halfords exposes them.

A SLAS secret is **not required for the normal public search, public category URL/path, or exact product-ID workflows above**.

### Input reference

| Field | Use |
|---|---|
| `query` | Keyword product search |
| `category_url` | Full public Halfords category URL |
| `category_slug` | Public Halfords category path |
| `product_ids` | Exact product/SKU IDs |
| `category_id` | Numeric/internal category ID; advanced authenticated route |
| `limit` | Maximum rows to return from the selected listing/request |
| `page` | API page number; public credential-free listing currently supports page 1 |
| `sort` | API sort option; applies to authenticated API mode |
| `filters` | Raw Halfords refinement filters; applies to authenticated API mode |
| `slas_secret` | Optional advanced Halfords SLAS credential |
| `proxyConfiguration` | Optional Apify proxy configuration |

Use one primary workflow at a time. If several selectors are supplied, the current execution priority is `query` → category (`category_url` / `category_slug` / `category_id`) → `product_ids`.

### Output

Public credential-free rows use a compact normalized shape similar to:

```json
{
  "id": "224411",
  "name": "TotalEnergies Quartz INEO MC3 5W/30 5L",
  "brand": null,
  "current_price": 33.5,
  "price": 33.5,
  "discount_price": null,
  "currency": "GBP",
  "availability": null,
  "in_stock": null,
  "source_url": "https://www.halfords.com/...",
  "url": "https://www.halfords.com/...",
  "images": ["https://.../"],
  "source": "halfords_public_html"
}
```

Depending on the route and source data, authenticated results can also expose fields such as `image`, `rating`, `review_count`, `category_id`, and `barcode`.

### Notes and limitations

- Halfords can change page markup or internal APIs without notice.
- Public HTML can expose less metadata than the authenticated API, so fields such as brand or stock state may legitimately be `null`.
- Credential-free search/category scraping currently targets the first native listing page; use the authenticated route when you need API pagination, sorting, or refinements.
- Numeric `category_id` is an authenticated API feature. For credential-free category scraping, use `category_url` or `category_slug`.
- Direct access currently works for the public fallback. Configure `proxyConfiguration` only when your network or a future Halfords change requires it.
- A genuine no-match request can finish successfully with an empty Dataset.

### Disclaimer

This Actor is unofficial and is not affiliated with or endorsed by Halfords. Users are responsible for complying with applicable terms, policies, and laws.

### AI, MCP and automation contract

Every successful product row is self-describing and includes `record_type=product`, the resolved `operation` (`search`, `category`, or `item`), `retailer=Halfords`, `country=GB`, and an ISO-8601 `retrieved_at` timestamp. Existing product fields remain backward compatible. The `source` field identifies the route that produced the row (for example `halfords_public_html`).

For autonomous agents, use `query` for discovery, then reuse an exact returned `id` in `product_ids` for deterministic item resolution. A legitimate no-match returns an empty Dataset. Access/runtime failures are not converted into fake product rows. Public HTML search can legitimately omit brand or stock fields; the Actor keeps those values null rather than guessing. Exact product pages additionally extract brand and availability when Halfords exposes them in structured product markup.

The default Dataset is the canonical machine-readable output and can be consumed directly through the Apify API, MCP integrations, or downstream automation.

# Actor input Schema

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

Keyword product search (for example, 'engine oil'). In credential-free public mode the first native listing page is used.

## `category_url` (type: `string`):

Full public Halfords category URL. Recommended for credential-free category scraping.

## `category_slug` (type: `string`):

Public Halfords category path, for example /motoring/engine-oils-and-fluids/engine-oil/.

## `product_ids` (type: `array`):

One or more exact Halfords product/SKU IDs. Credential-free mode resolves only exact IDs.

## `category_id` (type: `string`):

Numeric/internal Halfords category ID. This route requires a valid optional SLAS credential; use Category URL or Category Path for credential-free scraping.

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

Maximum number of rows to return from the selected listing/request.

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

Page number for the authenticated API route. Credential-free public search/category mode currently supports the first native listing page.

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

Sort option for the authenticated API route. Credential-free public HTML keeps the retailer's native order.

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

Raw Halfords refinement filters passed to the authenticated API route. They are not applied by the credential-free public HTML fallback.

## `slas_secret` (type: `string`):

Optional Halfords SLAS client credential. Not required for public search, public category URL/path, or exact product-ID workflows. If omitted, HALFORDS\_SLAS\_SECRET may be used from the Actor environment.

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

Optional Apify proxy configuration. Direct access currently works for the public fallback; configure a proxy only when needed.

## Actor input object example

```json
{
  "query": "bike",
  "limit": 10,
  "page": 1,
  "sort": "relevance"
}
```

# Actor output Schema

## `results` (type: `string`):

Normalized Halfords product rows with stable semantic fields such as record\_type, operation, country, retrieved\_at, id, name, prices, and source URL.

# 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/halfords-uk-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/halfords-uk-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 '{}' |
apify call dromb/halfords-uk-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dromb/halfords-uk-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/hpVLk3oMTMJtaxkMK/builds/9YYncwVnpXfaiSiYg/openapi.json
