> **For coding agents and LLMs:** This is one page from the Social Fetch docs (markdown export). For curated orientation and workflow guidance, start with [`/llms.txt`](https://www.socialfetch.dev/llms.txt); for agent onboarding and crawl rules, use [`/agents.txt`](https://www.socialfetch.dev/agents.txt); for the full endpoint list with links to pages like this one, use [`/llms-endpoints.txt`](https://www.socialfetch.dev/llms-endpoints.txt); for one platform's parameters and curls, use [`/llms-{platform}.txt`](https://www.socialfetch.dev/llms-tiktok.txt); use [`/llms.json`](https://www.socialfetch.dev/llms.json) when you need structured JSON for tool registration.

## This page

- **On-site (HTML):** <https://www.socialfetch.dev/docs/api/v1/hm/search/get>
- **Markdown (.mdx) URL:** <https://www.socialfetch.dev/docs/api/v1/hm/search/get.mdx>

## API base URL and authentication

- **API origin (from OpenAPI `servers`):** `https://api.socialfetch.dev`
- **Authentication:** send `x-api-key: sfk_...` on `/v1/**` and `/v2/**` routes unless the operation is explicitly anonymous (check OpenAPI `security`, the [API reference hub](https://www.socialfetch.dev/docs/api.mdx), [`/llms.txt`](https://www.socialfetch.dev/llms.txt), or [`/llms.json`](https://www.socialfetch.dev/llms.json) for each route).
- **OpenAPI JSON:** <https://www.socialfetch.dev/openapi.json>

## Recommended docs entrypoints (this site)

- [Documentation overview](https://www.socialfetch.dev/docs.mdx) — top-level orientation (markdown).
- [Quickstart](https://www.socialfetch.dev/docs/quickstart.mdx) — authenticate with `x-api-key`, validate auth with `whoami`, and understand the JSON envelope.
- [SDK](https://www.socialfetch.dev/docs/sdk.mdx) — official TypeScript SDK guide, including `SocialFetchClient`, `Result`, and `unwrap()`.
- [Capability matrix](https://www.socialfetch.dev/docs/capability-matrix.mdx) — every operation with identifiers, pagination, outcomes, media download, credits, and its SDK method. Generated from OpenAPI, so use it for route selection instead of scanning individual pages.
- [Recipes](https://www.socialfetch.dev/docs/recipes.mdx) — copyable workflows (brand monitoring, transcripts, Ad Library, creator scoring, Reddit research) with credit callouts and SDK examples.
- [Integrations](https://www.socialfetch.dev/docs/integrations.mdx) — MCP for AI clients, n8n verified node, Apify Store Actors, Make custom app, SDK, and REST API connection paths.
- [MCP product page](https://www.socialfetch.dev/mcp) — hosted MCP overview, OAuth, Skills install.
- [MCP integration](https://www.socialfetch.dev/docs/integrations/mcp.mdx) — hosted `/mcp` server, OAuth, Cursor/VS Code/Claude install snippets, 1112 endpoint tools, plus docs_search/docs_read for implementation help.
- [n8n integration](https://www.socialfetch.dev/docs/integrations/n8n.mdx) — install `n8n-nodes-socialfetch`, credentials, and workflow examples.
- [Apify integration](https://www.socialfetch.dev/docs/integrations/apify.mdx) — Store Actors under @social-fetch, PPE billing, dataset export, and quick start.
- [Make integration](https://www.socialfetch.dev/docs/integrations/make.mdx) — custom app modules for Make scenarios, API key credentials, and module catalog.
- [`/llms-endpoints.txt`](https://www.socialfetch.dev/llms-endpoints.txt) — every documented operation with a direct link to that route's agent-readable markdown page (prefer this over parsing OpenAPI).
- [`/llms-{platform}.txt`](https://www.socialfetch.dev/llms-tiktok.txt) — per-platform endpoint files generated from OpenAPI (parameters, credits, curls).
- [`/agents.txt`](https://www.socialfetch.dev/agents.txt) — agent crawl/onboarding file with capabilities, auth rules, and allowlist.
- [`/llms.json`](https://www.socialfetch.dev/llms.json) — structured machine-readable operation inventory with parameter names, pagination, outcomes, credits, and SDK mapping.
- [API reference hub](https://www.socialfetch.dev/docs/api.mdx) — human-friendly index of operations with links into generated pages.
- [Errors](https://www.socialfetch.dev/docs/errors.mdx) — shared error envelope and HTTP status guidance.
- [Credits](https://www.socialfetch.dev/docs/credits.mdx) — metering, `402`, and planning batch jobs.
- Outcome semantics such as `found`, `not_found`, and `private` are documented in [Errors](https://www.socialfetch.dev/docs/errors.mdx) and on operation pages when present in the OpenAPI contract.

## Markdown docs convention

- Every docs page has a markdown twin: append **`.mdx`** to the docs pathname (for example `/docs/quickstart` → `/docs/quickstart.mdx`).
- Agents that send `Accept: text/markdown` on `/docs/**` HTML URLs may receive markdown directly (same URL, `Vary: Accept`).
- Published blog posts use the same convention: `/blog/{slug}` → `/blog/{slug}.mdx`, or `Accept: text/markdown` on the HTML URL (`Vary: Accept`).

---
# Search H&M products (https://www.socialfetch.dev/docs/api/v1/hm/search/get)

## Summary

Search H&M products in a country, with prices, sale prices, colours, sizes, filters and cursor paging.

**Tags:** `H&M`

## HTTP

- **Method:** GET
- **Path:** `/v1/hm/search`
- **Base URL:** `https://api.socialfetch.dev`

## Capability summary

- **SDK mapping:** `client.hm.searchProducts({ query: "jeans", country: "US" })`
- **Accepted identifiers:** `query` (query)
- **Pagination:** cursor via `cursor`, next cursor: `data.page.nextCursor`, has more: `data.page.hasMore`
- **Business outcome field:** `data.lookupStatus` with values `found`, `not_found`

## Credits

- **Base:** 1 credit per successful lookup.
- **Maximum on success (200):** 1 credit.
- **Failed requests (`lookup_failed`, `503`):** not charged.
- **Authoritative field:** `meta.creditsCharged`.

## Authentication

- **`x-api-key`**: API key (`sfk_...`)

## Parameters

### `query` (query)

- **Required:** yes
- **Constraints:** type `string`; minLength: 1; maxLength: 200
- **Description:** What to search for, e.g. `jeans` or `linen shirt`.

### `sort` (query)

- **Required:** no
- **Constraints:** type `string`; enum: relevance, newest, price_low, price_high
- **Description:** `relevance` (default), `newest` first, `price_low` (lowest price first) or `price_high`.

### `limit` (query)

- **Required:** no
- **Constraints:** type `integer`; minimum: 1; maximum: 72
- **Description:** Products per page, 1 to 72. Default: 36.

### `cursor` (query)

- **Required:** no
- **Constraints:** type `string`; minLength: 1; maxLength: 512
- **Description:** Pass `page.nextCursor` from the previous response to get the next page.

### `country` (query)

- **Required:** no
- **Constraints:** type `string`
- **Description:** Two-letter country code of the H&M market, e.g. `GB` or `DE`. Default: `US`.

### `language` (query)

- **Required:** no
- **Constraints:** type `string`; pattern: `^[a-z]{2}$`
- **Description:** Two-letter language code of the market's site, e.g. `en` or `fr`. Default: the market's main language.

## Pagination

This endpoint uses **cursor-based pagination** via the `cursor` query parameter.

- Read **hasMore** from `data.page.hasMore`.
- When that value is `true`, read **nextCursor** from `data.page.nextCursor` and pass it as the `cursor` query parameter on the **next** request (URL-encode when building a query string).
- Omit `cursor` on the **first** request.
- Stop when **hasMore** is `false` or **nextCursor** is null (end of list).

## Responses (status codes)

- **200**: H&M products matching the search, with filters.
- **400**: Invalid request
- **401**: Missing or invalid API key
- **402**: Insufficient credits
- **500**: Unexpected or billing error
- **502**: Lookup could not be completed.
- **503**: Service temporarily unavailable; safe to retry with backoff.

## Response body (200)

H&M products matching the search, with filters.

### Field outline

- **data** (required) — type `object`. Endpoint-specific response payload.
  - **lookupStatus** (required) — type `string`; enum: found, not_found. Always `found`: no match is an empty list.
  - **query** (required) — type `string`. The query that was searched.
  - **sort** (required) — type `string`; enum: relevance, newest, price_low, price_high. The order of the results.
  - **market** (required) — type `object`. The H&M market the answer is for.
    - **country** (required) — type `string`. Two-letter country code, e.g. `US`.
    - **language** (required) — type `string`. Two-letter language code, e.g. `en`.
    - **locale** (required) — type `string`. H&M's own name for the market's site, e.g. `en_us`.
    - **currency** (required) — type `string`; nullable. ISO 4217 currency of the market, e.g. `USD`.
  - **totalCount** (required) — type `integer`; nullable. Matching products.
  - **pageNumber** (required) — type `integer`. This page's number, from 1.
  - **totalPages** (required) — type `integer`; nullable. Pages at this page size.
  - **products** (required) — type `array`. Products on this page.
    - _items:_
      - **id** (required) — type `string`. Article id, the product in one colour, e.g. `1337544001`.
      - **productCode** (required) — type `string`; nullable. Product code shared by every colour, e.g. `1337544`.
      - **title** (required) — type `string`. Product name.
      - **url** (required) — type `string`; nullable. Product page URL.
      - **vendor** (required) — type `string`; nullable. Brand, e.g. `H&M`.
      - **productType** (required) — type `string`; nullable. H&M's category code, e.g. `ladies_jeans_wide`.
      - **availableForSale** (required) — type `boolean`; nullable. Whether the product can be bought online now.
      - **stockState** (required) — type `string`; nullable. Stock state as H&M names it, e.g. `Available`.
      - **comingSoon** (required) — type `boolean`; nullable. Whether it is coming soon.
      - **newArrival** (required) — type `boolean`; nullable. Whether it is a new arrival.
      - **isOnline** (required) — type `boolean`; nullable. Whether it is sold online.
      - **price** (required) — type `object`; nullable. Current price; the sale price when the product is on sale.
      - **compareAtPrice** (required) — type `object`; nullable. Regular price when the product is on sale; null otherwise.
      - **memberPrice** (required) — type `object`; nullable. Members' price where H&M offers one; null otherwise.
      - **discountPercent** (required) — type `number`; minimum: 0; nullable. The sale discount H&M shows, e.g. `60` for `-60%`; null when the product is not on sale.
      - **colorName** (required) — type `string`; nullable. Colour of this article.
      - **colorCode** (required) — type `string`; nullable. Hex colour code of this article.
      - **colorShades** (required) — type `array`. Colour shades H&M tags the article with.
        - _items:_
          - type `string`
      - **featuredImage** (required) — type `string`; nullable. Main product image URL.
      - **featuredImageAlt** (required) — type `string`; nullable. The main image's alt text; null where it has none.
      - **modelImage** (required) — type `string`; nullable. Image of the product worn.
      - **images** (required) — type `array`. Every image in the result.
        - _items:_
      - **swatches** (required) — type `array`. Every colour of the product, this one included.
        - _items:_
      - **sizes** (required) — type `array`. Sizes with their stock indicator.
        - _items:_
      - **markers** (required) — type `array`. Labels on the product, e.g. `H&M Studio` or `New arrival`.
        - _items:_
          - type `string`
      - **hasVideo** (required) — type `boolean`; nullable. Whether the product has a video.
      - **isMultipack** (required) — type `boolean`; nullable. Whether it is a multipack.
  - **filters** (required) — type `array`. Filters with counts.
    - _items:_
      - **id** (required) — type `string`. Filter id, e.g. `colorWithNames`.
      - **name** (required) — type `string`; nullable. Filter name, e.g. `Colors`.
      - **type** (required) — type `string`; nullable. `TEXT`, `RANGE` and the like.
      - **values** (required) — type `array`. Values with counts.
        - _items:_
      - **min** (required) — type `number`; nullable. Lowest value of a range filter.
      - **max** (required) — type `number`; nullable. Highest value of a range filter.
  - **departments** (required) — type `array`. Departments with counts.
    - _items:_
      - **id** (required) — type `string`. Department id, e.g. `ladies_all`.
      - **label** (required) — type `string`; nullable. Department name, e.g. `Women`.
      - **count** (required) — type `integer`; nullable. Matching products.
  - **didYouMean** (required) — type `array`. Spelling suggestions.
    - _items:_
      - type `string`
  - **relatedSearches** (required) — type `array`. Related searches.
    - _items:_
      - type `string`
  - **page** (required) — type `object`. Pagination state for the current page.
    - **hasMore** (required) — type `boolean`. Whether another page is available.
    - **nextCursor** (required) — type `string`; nullable. Cursor to pass in the next request when more pages exist; null on the last page.
- **meta** (required) — type `object`. Metadata describing the request and billing outcome.
  - **requestId** (required) — type `string`; minLength: 1. Unique request identifier for tracing this API call.
  - **creditsCharged** (required) — type `integer`; minimum: 0. Credits charged for this request.
  - **version** (required) — type `string`; enum: v1. Public API version that served the response.
  - **stale** (optional) — type `boolean`; enum: true. Present, and `true`, only when the source couldn't be reached and this is the last good answer for the same request instead, up to 24 hours old. Absent on every live answer.
  - **fetchedAt** (optional) — type `string`. When a stale answer (`stale: true`) was originally fetched (ISO 8601, UTC). Absent on every live answer.

### Example JSON (found)

```json
{
  "data": {
    "lookupStatus": "found",
    "query": "jeans",
    "sort": "relevance",
    "market": {
      "country": "US",
      "language": "en",
      "locale": "en_us",
      "currency": "USD"
    },
    "totalCount": 1321,
    "pageNumber": 1,
    "totalPages": 166,
    "products": [
      {
        "id": "1336845001",
        "productCode": "1336845",
        "title": "Straight High-Waist Jeans",
        "url": "https://www2.hm.com/en_us/productpage.1336845001.html",
        "vendor": "H&M",
        "productType": "ladies_jeans_straight",
        "availableForSale": true,
        "stockState": "Available",
        "comingSoon": false,
        "newArrival": true,
        "isOnline": true,
        "price": {
          "amount": 34.99,
          "currency": "USD",
          "formatted": "$34.99"
        },
        "compareAtPrice": null,
        "memberPrice": null,
        "discountPercent": null,
        "colorName": "Dark denim blue",
        "colorCode": "2E3036",
        "colorShades": [
          "Bright blue"
        ],
        "featuredImage": "https://image.hm.com/assets/hm/ed/04/ed04caa65ca621759c777dd58386b0465cde6d4a.jpg",
        "featuredImageAlt": "A pair of dark blue, high-waisted denim jeans is facing front, featuring a classic five-pocket design with a button closure and zip fly. The jeans are displaying a regular fit from the waist to the hips that transitions into a loose, straight-leg cut.",
        "modelImage": "https://image.hm.com/assets/hm/db/d4/dbd41611eb1a95afe993a9c447a8bde7bf255545.jpg",
        "images": [
          {
            "url": "https://image.hm.com/assets/hm/9a/10/9a101cb7de3b982c86a6bc1d24fc1a039cde2783.jpg",
            "type": "Lookbook",
            "alt": null
          }
        ],
        "swatches": [
          {
            "id": "1336845001",
            "colorName": "Dark denim blue",
            "colorCode": "2E3036",
            "url": "https://www2.hm.com/en_us/productpage.1336845001.html",
            "image": "https://image.hm.com/assets/hm/ed/04/ed04caa65ca621759c777dd58386b0465cde6d4a.jpg"
          }
        ],
        "sizes": [
          {
            "id": "001",
            "label": "0",
            "stockLevel": 2
          }
        ],
        "markers": [],
        "hasVideo": false,
        "isMultipack": false
      }
    ],
    "filters": [
      {
        "id": "priceRange",
        "name": "Price",
        "type": "RANGE",
        "values": [],
        "min": 9.99,
        "max": 269
      }
    ],
    "departments": [
      {
        "id": "all",
        "label": "All",
        "count": 1321
      }
    ],
    "didYouMean": [],
    "relatedSearches": [],
    "page": {
      "hasMore": true,
      "nextCursor": "eyJwIjoyLCJ6Ijo4LCJmIjoiY2RlM2U1NTY0NDE5Y2YxOSJ9"
    }
  },
  "meta": {
    "requestId": "req_01example_hm_search",
    "creditsCharged": 1,
    "version": "v1"
  }
}
```

### Machine-readable error codes

When an error JSON body is returned, it may include one of these `error.code` values (derived from the OpenAPI schemas for this operation; additional codes may exist at runtime):

- `bad_request`

## Error handling & retries

Interpret HTTP status codes using the descriptions below. Do not assume a JSON body unless the OpenAPI schema defines one for that status.

- **400**: Invalid request **Retry:** Fix the request; retrying the same invalid payload will not help.
- **401**: Missing or invalid API key **Retry:** Fix the API key first; retrying without changes will not help.
- **402**: Insufficient credits **Retry:** Do not retry without resolving billing/credits (retrying the same request will not help).
- **500**: Unexpected or billing error
- **502**: Lookup could not be completed. **Retry:** May be transient; a few retries with backoff are reasonable.
- **503**: Service temporarily unavailable; safe to retry with backoff. **Retry:** Usually safe to retry with exponential backoff and jitter.

### Suggested client defaults

- Send the API key using the `x-api-key` header on every request.
- On `503` (and sometimes `502`), retry with backoff; cap retries and surface a clear error to the user.
- On `402`, surface an actionable billing message rather than blind retries.

## Examples

### TypeScript SDK

```typescript
import { SocialFetchClient } from "@socialfetch/sdk";

const client = new SocialFetchClient({
  apiKey: process.env.SOCIALFETCH_API_KEY!,
});

const result = await client.hm.searchProducts({
  query: "jeans",
});

if (!result.ok) {
  console.error(result.error);
} else {
  console.log(result.value.data);
}
```

### Node.js

```javascript
const response = await fetch(
  "https://api.socialfetch.dev/v1/hm/search?query=jeans",
  {
    headers: {
      "x-api-key": "YOUR_API_KEY"
    }
  }
);

const data = await response.json();
console.log(data);
```

### cURL

```bash
curl "https://api.socialfetch.dev/v1/hm/search?query=jeans" \
  -H "x-api-key: YOUR_API_KEY"
```

### Python

```python
import requests

response = requests.get(
    "https://api.socialfetch.dev/v1/hm/search?query=jeans",
    headers={"x-api-key": "YOUR_API_KEY"},
)
data = response.json()
print(data)
```

### Example: next page (pagination)

After a successful response, if pagination is not finished, request the next page using `cursor` (URL-encode when composing the query string):

```javascript
const previous = await response.json();
const nextCursor = previous?.data?.page?.nextCursor;
const hasMore = previous?.data?.page?.hasMore;
if (!hasMore || nextCursor == null) {
  // no more pages
} else {
  const nextUrl = new URL("https://api.socialfetch.dev/v1/hm/search");
  nextUrl.searchParams.set("cursor", nextCursor);
  // optionally preserve sort: nextUrl.searchParams.set("sortBy", "latest");
  const nextResponse = await fetch(nextUrl.toString(), {
    headers: { "x-api-key": "YOUR_API_KEY" },
  });
  const nextData = await nextResponse.json();
}
```