# H\&M (`datasaurus/hm-products`) Actor

Scrape products from H\&M websites. All countries and languages. Fast and efficient.

- **URL**: https://apify.com/datasaurus/hm-products.md
- **Developed by:** [datasaurus](https://apify.com/datasaurus) (community)
- **Categories:** E-commerce
- **Stats:** 46 total users, 5 monthly users, 100.0% runs succeeded, 3 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.
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

## H\&M Products Scraper

This tool scrapes product data from H\&M. It works with all website countries and languages.

Checkout our other scrapers: [Zara](https://apify.com/datasaurus/zara) | [Stradivarius](https://apify.com/datasaurus/stradivarius) | [Pull\&Bear](https://apify.com/datasaurus/pullandbear) | [MassimoDutti](https://apify.com/datasaurus/massimodutti) | [Bershka](https://apify.com/datasaurus/bershka) | [Oysho](https://apify.com/datasaurus/oysho) | [ZaraHome](https://apify.com/datasaurus/zarahome)

### Features

- **Detailed Scrape**:
  - Scrapes individual product pages for detailed information
  - <span style="color:">**Fields include**: name, description, price, colors, sizes, SKUs, category, images, stock availability, discount, product page url, plus more. </span>
  - <span style="color:MediumSeaGreen">**Approx Run time**: 1000 products in 30 seconds</span>

- **Granularity**: Scrape:
  - The entire website, e.g. <https://www2.hm.com/en_gb/>
  - Product category pages, e.g. <https://www2.hm.com/en_gb/home/seasonal-trending/bestsellers.html>

- **Multiple URLs**: Scrape data from multiple start urls within a single scrape, including from different country websites.

- **Set Limits**: Define the maximum products pages to scrape per url.

- **Deduplication**: Unique products are returned, even across multiple start URLs. This is useful in instances where the same product appears in multiple subcategories. The scrapper will do it's best to deduplicate results - as pages are scrapped concurrently, the scrapper may occassionally not identify every duplicate product.

### Notes

- This tool is configured to use datacentre proxies which are low cost and necessay to avoid IP address blocking. It is effecient with data download sizes which optimises run time and cost.
- The output is in JSON format due to the nested data structure.

### Known Scraping Challenges

- Occasionally the scrape might not start or the scrape might stop due to requests being blocked by the website. A '403 error' will appear in the logs. This is common in webscrapping and difficult to avoid, but it can be solved by re-running the scrape.

### Resources

- **Getting Started with Apify**:
  - [Getting Started with Apify 1/4 - Introduction](https://www.youtube.com/watch?v=b_nep8vMnkc\&list=PLObrtcm1Kw6MUrlLNDbK9QRg8VDJg0gOW\&index=1)
  - [Getting Started with Apify 4/4 - Integrations](https://www.youtube.com/watch?v=bNACk1_S_6w\&list=PLObrtcm1Kw6MUrlLNDbK9QRg8VDJg0gOW\&index=4)
  - [Try Apify for Free - 2,000+ Pre-built Web Scraping and Automation Tools](https://www.youtube.com/watch?v=WQNgQVRG9_U)
  - [Integration with Make, GitHub, Zapier, Google Drive, and other apps](https://apify.com/integrations)
  - [How to Train ChatGPT on Your Own Data - Build a Custom AI Chatbot](https://www.youtube.com/watch?v=LcG919C4UeU)
  - [Apify Platform Documentation](https://docs.apify.com/platform)

### Example Input

```json
{
  "start_urls": [
    {"url": "https://www2.hm.com/en_gb/index.html"},
    {"url": "https://www2.hm.com/en_gb/home/seasonal-trending/bestsellers.html"},
  ],
  "deduplicate_across_all_start_urls": true,
  "max_categories": 1,
  "max_pages": 1
}
```

### Example Output

```json
{
  "id": "0974175002",
  "trackingId": "OzU7IzswOTc0MTc1MDAyOyM7IzsvZmFzaGlvbi9NT0JJTEUvTEFORElOR19QQUdFL05BVklHQVRJT05fUkVTVUxUOyM7IztPQkpFQ1RJVkUkOzExOzQ3OyM7IzsvaG9tZTs_e4",
  "productName": "Cotton storage basket",
  "external": false,
  "brandName": "H&M",
  "url": "https://www2.hm.com/en_gb/productpage.0974175002.html",
  "showPriceMarker": false,
  "prices": [
    {
      "priceType": "whitePrice",
      "price": 19.99,
      "minPrice": 19.99,
      "maxPrice": 19.99,
      "formattedPrice": "£19.99"
    }
  ],
  "availability": {
    "stockState": "Available",
    "comingSoon": false
  },
  "swatches": [
    {
      "articleId": "0974175002",
      "url": "https://www2.hm.com/en_gb/productpage.0974175002.html",
      "colorName": "Light beige",
      "colorCode": "B5AFA0",
      "trackingId": "OzU7IzswOTc0MTc1MDAyOyM7IzsvZmFzaGlvbi9NT0JJTEUvTEFORElOR19QQUdFL05BVklHQVRJT05fUkVTVUxUOyM7IztPQkpFQ1RJVkUkOzExOzQ3OyM7IzsvaG9tZTs_e4",
      "productImage": "https://image.hm.com/assets/hm/9d/b2/9db248e3025308a910b4d3cd543ec33803f09cd2.jpg"
    }
  ],
  "productMarkers": [],
  "images": [
    {
      "url": "https://image.hm.com/assets/hm/d2/c3/d2c3427b67121103bce070735bebc6a76b6f824d.jpg"
    },
    {
      "url": "https://image.hm.com/assets/hm/cd/b3/cdb3cc592089d526a1563e8d4f4ca3c0ea53346d.jpg"
    }
  ],
  "hasVideo": false,
  "removed": false,
  "colorName": "Light beige",
  "isPreShopping": false,
  "isOnline": true,
  "modelImage": "https://image.hm.com/assets/hm/ec/7c/ec7c5c8be146f7c79343fa550b3eb8e082b0259e.jpg",
  "colors": "B5AFA0",
  "productImage": "https://image.hm.com/assets/hm/9d/b2/9db248e3025308a910b4d3cd543ec33803f09cd2.jpg",
  "sizes": [
    {
      "id": "001",
      "label": "NOSIZE",
      "stock": 2
    }
  ],
  "newArrival": false,
  "isLiquidPixelUrl": false,
  "colorWithNames": "beige_f5f5dc",
  "mainCatCode": "home_storageorganizing_baskets"
}
```

# Actor input Schema

## `start_urls` (type: `array`):

Website: e.g.
https://www2.hm.com/en\_gb/index.html
-see Information tab for a list of country websites-
Category page: e.g.
https://www2.hm.com/en\_gb/home/seasonal-trending/bestsellers.html

## `max_categories` (type: `integer`):

Select the number of category product pages to scrape per url. This works with main page urls only.

## `max_pages` (type: `integer`):

Select the maximum number of pages to scrape per start url.

## Actor input object example

```json
{
  "start_urls": [
    {
      "url": "https://www2.hm.com/en_gb/index.html"
    },
    {
      "url": "https://www2.hm.com/en_gb/home/seasonal-trending/bestsellers.html"
    }
  ],
  "max_categories": 2,
  "max_pages": 1
}
```

# Actor output Schema

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

No description

# 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 = {
    "start_urls": [
        {
            "url": "https://www2.hm.com/en_gb/index.html"
        },
        {
            "url": "https://www2.hm.com/en_gb/home/seasonal-trending/bestsellers.html"
        }
    ],
    "max_pages": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("datasaurus/hm-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 = {
    "start_urls": [
        { "url": "https://www2.hm.com/en_gb/index.html" },
        { "url": "https://www2.hm.com/en_gb/home/seasonal-trending/bestsellers.html" },
    ],
    "max_pages": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("datasaurus/hm-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 '{
  "start_urls": [
    {
      "url": "https://www2.hm.com/en_gb/index.html"
    },
    {
      "url": "https://www2.hm.com/en_gb/home/seasonal-trending/bestsellers.html"
    }
  ],
  "max_pages": 1
}' |
apify call datasaurus/hm-products --silent --output-dataset

```

## MCP server setup

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