# PcComponentes Product Search API Documentation

`GET /api/pccomponentes/search` returns public storefront products as JSON. Send `query` or a live `category` id, never both. Category ids come from the `filters` object of any search response.

## What you get

The response keeps the storefront envelope: `articles`, `total`, `totalPages`, `page`, `pageSize`, `sort`, `sortingKeys`, `filters`, `category` and `queryId`. Each article carries `id`, `slug`, `name`, `brandName`, `originalPrice`, `promotionalPrice`, `discount`, `stock`, `ratingCount`, `ratingAvg` and full-size `images`. Pass `id` and `slug` unchanged to the product and reviews routes.

## Prices and filters

Prices are numbers in EUR. `originalPrice` is the struck price and `promotionalPrice` the sale price. `discount` is a percentage. `min_price` and `max_price` (or its alias `price`) are applied to the returned page, so an item outside the requested range is never returned. `total` and `totalPages` are the storefront counts for the request before these price bounds are applied; use `articles` and `pageSize` to count what the page actually returns. `sort` accepts relevance, price_asc, price_desc, discount, best_selling, top_rated, activation_date. `page` runs from 1 to 50. A later page is never relabelled as page one; an empty page stays empty.

## Credits

A successful request costs **2 credits**. Errors, challenges and `404` answers cost nothing. The response shows the charge in `meta.credits_charged`.

- **Documentation:** [https://scrappa.co/docs/pccomponentes-api/pccomponentes_search](https://scrappa.co/docs/pccomponentes-api/pccomponentes_search)
- **API group:** PcComponentes API
- **Endpoint:** `GET https://scrappa.co/api/pccomponentes/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 | No | Search words. Use this or category. |
| `category` | string | No | Live category id from a search filters object. Use this or query. |
| `min_price` | number | No | Lowest promotional price in euros. Applied to the returned page. |
| `max_price` | number | No | Highest promotional price in euros. Applied to the returned page. |
| `price` | number | No | Alias for max_price. |
| `sort` | string | No | One of relevance, price_asc, price_desc, discount, best_selling, top_rated, activation_date. |
| `page` | integer | No | Result page, 1-50. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/pccomponentes/search?query=portatil"
```

## Example response

```json
{
    "success": true,
    "articles": [
        {
            "id": "10810270",
            "slug": "portatil-asus-vivobook-15-oled",
            "name": "Portatil Asus Vivobook 15 OLED",
            "brandName": "Asus",
            "originalPrice": 699,
            "promotionalPrice": 579.99,
            "discount": 17,
            "currency": "EUR",
            "stock": true,
            "ratingCount": 189,
            "ratingAvg": 4.455,
            "images": [
                "https://img.pccomponentes.com/articles/108/10810270/1.jpg"
            ]
        }
    ],
    "total": 2943,
    "totalPages": 50,
    "page": 1,
    "pageSize": 20,
    "sort": "relevance",
    "sortingKeys": [],
    "filters": [],
    "category": null,
    "queryId": "example-query",
    "applied_filters": {
        "query": "portatil"
    },
    "meta": {
        "endpoint_family": "pccomponentes-search",
        "billable": true,
        "attempts": 1,
        "credits_charged": 2
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A query parameter is missing, unknown, conflicting or unusable. Unknown parameters are rejected, never ignored. Non-billable. |
| 503 | Upstream Unavailable | The storefront could not be reached, answered with a challenge, or changed its page shape (`upstream_blocked`, `upstream_unavailable`, `parser_drift`). Retryable and never billed. Clients are never rate limited. |

## 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)
