# Blocket Bil Search API Documentation

Search current vehicle listings with make, model, price, year, mileage, fuel, gearbox, body type, location and sales form filters, plus sorting and pagination. Prices are numbers plus currency, mileage is in Scandinavian miles. A valid empty result is a successful response.

- **Documentation:** [https://scrappa.co/docs/blocket-bil-api/blocket_bil_search](https://scrappa.co/docs/blocket-bil-api/blocket_bil_search)
- **API group:** Blocket Bil API
- **Endpoint:** `GET https://scrappa.co/api/blocket-bil/v1/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 |
| --- | --- | --- | --- |
| `page` | integer | No | Zero-based page number. Defaults to 0. |
| `lim` | integer | No | Listings per page, 1 to 50. Defaults to 50. |
| `sort` | string | No | PRICE_ASC or PRICE_DESC. Defaults to PRICE_ASC. |
| `variant` | string | No | Make id from the search filters. Example: 0.818 is Volvo. |
| `location` | string | No | County id from the search filters. Example: 0.300001 is Stockholm. |
| `sales_form` | array | No | Repeatable: 1 used, 2 new, 3 lease, 4 demo. Defaults to 1 and 2. Never 5. |
| `fuel` | integer | No | Fuel id from the search filters. Example: 2 is diesel. |
| `price_from` | integer | No | Optional non-negative minimum price in SEK. |
| `price_to` | integer | No | Optional non-negative maximum price in SEK. |
| `year_from` | integer | No | Optional minimum first registration year. |
| `year_to` | integer | No | Optional maximum first registration year. |
| `mileage_from` | integer | No | Optional minimum mileage in Scandinavian miles (1 mil = 10 km). |
| `mileage_to` | integer | No | Optional maximum mileage in Scandinavian miles. |
| `body_type` | integer | No | Body type id from the search filters. |
| `transmission` | integer | No | Transmission id from the search filters. |
| `org_id` | string | No | Optional dealer organisation id to list one dealer's vehicles. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/blocket-bil/v1/search?page=0&lim=50&sort=PRICE_ASC&variant=0.818&location=0.300001&sales_form%5B0%5D=1&sales_form%5B1%5D=2&fuel=2"
```

## Example response

```json
{
    "success": true,
    "data": {
        "search_metadata": {
            "page": 0,
            "lim": 50,
            "sort": "PRICE_ASC",
            "total_returned": 50,
            "total_matches": 1456,
            "has_more": true,
            "paging": {
                "param": "page",
                "current": 1,
                "last": 30
            }
        },
        "listings": {
            "0": {
                "id": "26235204",
                "heading": "Volvo V50",
                "location": "V\u00e4llingby",
                "price": {
                    "amount": 7500,
                    "currency_code": "SEK",
                    "price_unit": "kr"
                },
                "year": 2010,
                "mileage": 32194,
                "mileage_unit": "SCANDINAVIAN_MILE",
                "fuel": "Diesel",
                "transmission": "Manuell"
            },
            "filters": {
                "variant": {
                    "display_name": "M\u00e4rke",
                    "type": "STANDARD_FILTER",
                    "items": [
                        {
                            "label": "Volvo",
                            "value": "0.818",
                            "hits": 1456
                        }
                    ]
                }
            }
        }
    },
    "meta": {
        "endpoint_family": "search"
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A public parameter or range is invalid. This response is not billable. |
| 404 | Listing Not Found | The requested Blocket listing was not found. This response is not billable. |
| 502 | Invalid Source Response | Blocket returned an unexpected response shape. This response is not billable. |
| 503 | Service Unavailable | The upstream service is temporarily unavailable. Please retry shortly. |

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