# H-E-B Search API Documentation

<p><strong>H-E-B Search API</strong> searches grocery products on heb.com. Each item has the name, brand, size, price, regular and sale price, unit price, full-size image, availability and promotion flags. Prices are in US dollars.</p><p>Send <code>query</code> and optionally a public <code>storeId</code> (default 590), <code>shoppingContext</code>, <code>sortBy</code>, <code>sortDirection</code> and a <code>category</code>. For a later page, send the <code>next_cursor</code> of the previous response as <code>cursor</code>, with <code>page</code> one higher. A page above 1 without a cursor answers 422. Unknown parameters also answer 422. Accepted filter values are listed in the <code>filters</code>, <code>categories</code> and <code>sort_options</code> blocks of the response.</p><p>Product ids pass unchanged to the product route. Use <code>id</code> from a search result. A search without hits returns an empty list. Costs 1 credit per successful request with results. Empty results and failed requests are free.</p>

- **Documentation:** [https://scrappa.co/docs/heb-api/heb_search](https://scrappa.co/docs/heb-api/heb_search)
- **API group:** H-E-B API
- **Endpoint:** `GET https://scrappa.co/api/heb/search`

## Authentication

Send your Scrappa API key in the `X-API-KEY` request header. Paid endpoints also support accountless x402 payments when called without an API key.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | Yes | Search text, 1 to 120 characters, for example milk. |
| `storeId` | integer | No | Public H-E-B store id, default 590. |
| `shoppingContext` | string | No | CURBSIDE_PICKUP or CURBSIDE_DELIVERY. |
| `category` | string | No | Numeric category id from the categories block of a search response. |
| `sortBy` | string | No | SCORE, PRICE or PRODUCT_NAME. |
| `sortDirection` | string | No | ASC or DESC. |
| `cursor` | string | No | The next_cursor of the previous response. |
| `page` | integer | No | Page number, 1 based. Needs a cursor when above 1. |

## Example response

```json
{
    "data": {
        "page": 1,
        "count": 1,
        "items": [
            {
                "id": "314124",
                "name": "H-E-B Whole Milk Gallon",
                "size": "1 gal",
                "unit": "fl oz",
                "brand": "H-E-B",
                "image": "https://images.heb.com/is/image/HEBGrocery/000314124-1",
                "price": 3.29,
                "category": "Dairy & Eggs",
                "currency": "USD",
                "position": 1,
                "unit_price": 0.03,
                "availability": "CURBSIDE_PICKUP",
                "regular_price": 3.29
            }
        ],
        "query": "milk",
        "total": 325,
        "store_id": 590,
        "next_cursor": "eyJvZmZzZXQiOjUwfQ",
        "has_next_page": true,
        "shopping_context": "CURBSIDE_PICKUP"
    },
    "meta": {
        "credits": 1,
        "billable": true,
        "endpoint_family": "search"
    },
    "success": true
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A required parameter, a value or an unknown filter is invalid. This response is not billable. |
| 503 | Upstream Unavailable | H-E-B could not be reached after a fresh-exit retry. This response is not billable. |

## More Scrappa resources

- [API documentation](https://scrappa.co/docs)
- [Full LLM-readable API reference](https://scrappa.co/llms-full.txt)
- [OpenAPI specification](https://scrappa.co/docs/api.json)
- [Pricing](https://scrappa.co/pricing)
