# POST /v1/live/youpin/search

Search Youpin (youpin898) for CS2 items by weapon, collection, rarity, wear, color, price, or stickers, with each item's lowest price and listing count in CNY.

Returns the Youpin items that match a search, each with its lowest price and its number of listings.

Available on all plans, at [6 requests per minute on Developer and 36 on Scale](/docs/pricing#live-limits). Each request is for one search, with up to 20 items per page.

Prices are in CNY and aren't converted. Data is real-time.

## Inputs

Every field is optional. Send `search`, `filters`, or both.

| Field | Type | Meaning |
| --- | --- | --- |
| `search` | `string` | Text that Youpin matches against its [Chinese item names](/docs/live-youpin#text-search). |
| `listing_type` | `string` | `buy_now`, `rental`, or `auction`. Without it, the search covers buy now listings. |
| `filters` | `object` | See [Filters](#filters). |
| `sort` | `object` | See [Sorting](#sorting). |
| `raw_response` | `boolean` | `false` returns [structured rows](/docs/live-overview#raw-and-structured-responses). Without it, `data` is Youpin's own JSON. |

An auction search can also take a `market_hash_name` or an `item_id`, to return one item's auctions.

```json
{
  "filters": {
    "weapon": "AK-47",
    "collection": "The Gallery Collection",
    "max_price": 500
  },
  "sort": { "field": "price" }
}
```

## Filters

Filters search Youpin in English. Each takes a single value or a list of up to 50.

| Filter | Type | Meaning |
| --- | --- | --- |
| `weapon` | `string` or `string[]` | The weapon, such as `AK-47`. You can't send it with `item_type`. |
| `item_type` | `string` or `string[]` | The kind of item, for items that aren't weapons. |
| `quality` | `string` or `string[]` | The quality, such as `normal` or `stattrak`. Both include ★ items. |
| `rarity` | `string` or `string[]` | The item's rarity. |
| `wear` | `string` or `string[]` | The wear, such as `Field-Tested`. |
| `collection` | `string` or `string[]` | The collection's English name, such as `The Gallery Collection`. |
| `color` | `string` or `string[]` | Youpin's own color grouping for the item. |
| `knife_finish` | `string` or `string[]` | The finish of a knife. |
| `sticker_slab` | `string` or `string[]` | Sticker slab items. It doesn't filter the stickers on weapons. |
| `min_price`, `max_price` | `number` | The item's lowest listing price in CNY, inclusive. |
| `stickers` | `object` | Items with listings that carry these stickers, in the same forms as on [listings](/docs/live-youpin-listings#stickers-patches-and-charms). |
| `min_short_daily_rent`, `max_short_daily_rent` | `number` | Rentals only. The short-term rent in CNY per day. |
| `min_long_daily_rent`, `max_long_daily_rent` | `number` | Rentals only. The long-term rent in CNY per day. A maximum needs a minimum above 0. |
| `min_deposit`, `max_deposit` | `number` | Rentals only. The deposit in CNY. |

Buy now search takes all of these except the rent and deposit filters. The other listing types take fewer:

| `listing_type` | Filters |
| --- | --- |
| `rental` | Everything buy now takes except `min_price`, `max_price`, and `stickers`, plus the rent and deposit filters. |
| `auction` | `weapon`, `min_price`, `max_price`, and `stickers` with one sticker by `name`. |

The [options path](#post-v1liveyoupinsearchoptions) lists each filter's accepted values. Youpin's own request parameters go in [`market_parameters`](/docs/live-overview#filters-and-sorting).

## Sorting

| `listing_type` | `sort.field` |
| --- | --- |
| `buy_now` | `price`, `listing_count` (ascending by default), `ranking` (descending only) |
| `rental` | `short_daily_rent`, `long_daily_rent`, `deposit` (ascending by default), `ranking` (descending only) |
| `auction` | `price`, `watcher_count` (ascending by default), `bid_count` (descending by default) |

`ranking` is Youpin's own order, and the default without `sort`.

## Request

`POST https://api.cs2.sh/v1/live/youpin/search`

**curl**

```bash
curl -X POST https://api.cs2.sh/v1/live/youpin/search \
  -H "Authorization: Bearer <<YOUR_API_KEY>>" \
  -H "Accept-Encoding: gzip" --compressed \
  -H "Content-Type: application/json" \
  -d '{
  "filters": {
    "weapon": "AK-47",
    "collection": "The Gallery Collection",
    "max_price": 500
  },
  "sort": {
    "field": "price"
  },
  "raw_response": false
}'
```

**Python**

```python
import requests

headers = {
    "Authorization": "Bearer <<YOUR_API_KEY>>",
    "Accept-Encoding": "gzip",
    "Content-Type": "application/json",
}

payload = {
    "filters": {
        "weapon": "AK-47",
        "collection": "The Gallery Collection",
        "max_price": 500,
    },
    "sort": {
        "field": "price",
    },
    "raw_response": False,
}

response = requests.post(
    "https://api.cs2.sh/v1/live/youpin/search",
    headers=headers,
    json=payload,
)

response.raise_for_status()
data = response.json()
```

**Node**

```javascript
const headers = {
  "Authorization": "Bearer <<YOUR_API_KEY>>",
  "Accept-Encoding": "gzip",
  "Content-Type": "application/json",
};

const response = await fetch("https://api.cs2.sh/v1/live/youpin/search", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "filters": {
      "weapon": "AK-47",
      "collection": "The Gallery Collection",
      "max_price": 500
    },
    "sort": {
      "field": "price"
    },
    "raw_response": false
  }),
});

if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
```

**Go**

```go
package main

import (
    "bytes"
    "compress/gzip"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    payload := map[string]any{
        "filters": map[string]any{
            "weapon": "AK-47",
            "collection": "The Gallery Collection",
            "max_price": 500,
        },
        "sort": map[string]any{
            "field": "price",
        },
        "raw_response": false,
    }
    body, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", "https://api.cs2.sh/v1/live/youpin/search", bytes.NewReader(body))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer <<YOUR_API_KEY>>")
    req.Header.Set("Accept-Encoding", "gzip")

    resp, err := http.DefaultClient.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()

    if resp.StatusCode < 200 || resp.StatusCode >= 300 {
        body, _ := io.ReadAll(resp.Body)
        panic(fmt.Sprintf("HTTP %d: %s", resp.StatusCode, body))
    }

    var reader io.Reader = resp.Body
    if resp.Header.Get("Content-Encoding") == "gzip" {
        gz, err := gzip.NewReader(resp.Body)
        if err != nil { panic(err) }
        defer gz.Close()
        reader = gz
    }

    var data any
    if err := json.NewDecoder(reader).Decode(&data); err != nil { panic(err) }
    fmt.Printf("%#v\n", data)
}
```

**R**

```r
library(httr2)

payload <- list(
  filters = list(
    weapon = "AK-47",
    collection = "The Gallery Collection",
    max_price = 500
  ),
  sort = list(
    field = "price"
  ),
  raw_response = FALSE
)

resp <- request("https://api.cs2.sh/v1/live/youpin/search") |>
  req_headers(
    Authorization = "Bearer <<YOUR_API_KEY>>",
    `Accept-Encoding` = "gzip"
  ) |>
  req_body_json(payload) |>
  req_perform()

data <- resp_body_json(resp)
```

## Response

```json
{
  "market": "string",
  "operation": "string",
  "data": null,
  "page": {
    "page_size": 0,
    "has_next": false,
    "next_cursor": "string",
    "cursor_expires_at": "string",
    "total_count": 0,
    "total_exact": false
  },
  "warnings": [
    {
      "code": "string",
      "field": "string",
      "message": "string"
    }
  ],
  "response_time": "string"
}
```

## Response fields

[LiveResponse](/docs/objects#liveresponse) fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `market` | `string` | No | The marketplace: `youpin`, `csfloat`, or `steam`. |
| `operation` | `string` | No | The operation that ran, such as `listings`. |
| `data` | `object` | No | With `raw_response: true`, the default, the marketplace's own JSON, unchanged. With `raw_response: false`, the operation's structured object, which is one of `LiveListingsData`, `LiveListingDetailData`, `LiveBuyOrdersData`, `SteamBuyOrderBook`, `LiveFloatRankData`, or `LiveSearchData`. |
| `page` | [LivePage](/docs/objects#livepage) \| `null` | No | Paging for the next request. `null` on operations that aren't paged. |
| `warnings` | [LiveRequestWarning[]](/docs/objects#liverequestwarning) | No | Notes about the request itself. Absent when there are none. |
| `response_time` | `string (date-time)` | No | When cs2.sh sent the response (UTC). |

## Response data

With `raw_response: false`, `data.items[]` holds one [LiveSearchItem](/docs/objects#livesearchitem) per item:

| Field | Description |
| --- | --- |
| `market_hash_name` | The item's name, valid in any other request. |
| `item_id` | The item's Youpin template ID. |
| `lowest_price`, `listing_count` | The cheapest listing's price in CNY, and the number of listings. |
| `highest_buy_order`, `buy_order_quantity` | The best buy order, and how many units buyers want. |
| `rental` | Rental search only: `short_daily_rent`, `long_daily_rent`, `deposit`, `listing_count`. |
| `listings_query` | The [listings](/docs/live-youpin-listings) request for this item. |

An auction search returns auctions instead of items, in `data.listings[]`. Each one is a [LiveListing](/docs/objects#livelisting) with an `auction` object.

## Notes

A `stickers` filter with `min_price`, `max_price`, or `sort` returns `400`, because Youpin applies price and order before the sticker filter and the combined result would be wrong. To filter by stickers and price together, use [listings](/docs/live-youpin-listings) on one item.

An auction search reads Youpin's list of ending auctions, not every auction on Youpin. [Listings](/docs/live-youpin-listings) with `"listing_type": "auction"` can return auctions for an item that the search doesn't.

Pre-sales can't be searched. Read them per item with [listings](/docs/live-youpin-listings), or per seller with [store](/docs/live-youpin-store).

`page.total_count` isn't exact here, and `page.total_exact` is `false`.

## Errors

A filter value that Youpin doesn't have returns `400` with `details.code` set to `unknown_value`. Other errors are the [shared live errors](/docs/live-overview#errors-and-retries).

## POST /v1/live/youpin/search/options

Returns the valid [choices](/docs/live-overview#filter-options) for one field of a search request, and needs no item. These fields have choices:

| `field` | Choices |
| --- | --- |
| `filters.weapon`, `filters.item_type`, `filters.quality`, `filters.rarity`, `filters.wear` | Youpin's categories, in English |
| `filters.collection`, `filters.color`, `filters.knife_finish`, `filters.sticker_slab` | Youpin's groupings, in English |
| `filters.stickers.entries[].name`, `filters.stickers.entries[].category` | Sticker names and sticker categories |
| `filters.stickers.preset` | Youpin's sticker sets |
| `sort` | The sorts available |
| `listing_type` | The listing types |

To get one listing type's choices, send `listing_type` with `field`. Each option's `query` is a complete search request with the choice applied.

```json
{
  "field": "filters.collection",
  "contains": "Gallery"
}
```

### Request

`POST https://api.cs2.sh/v1/live/youpin/search/options`

**curl**

```bash
curl -X POST https://api.cs2.sh/v1/live/youpin/search/options \
  -H "Authorization: Bearer <<YOUR_API_KEY>>" \
  -H "Accept-Encoding: gzip" --compressed \
  -H "Content-Type: application/json" \
  -d '{
  "field": "filters.collection",
  "contains": "Gallery"
}'
```

**Python**

```python
import requests

headers = {
    "Authorization": "Bearer <<YOUR_API_KEY>>",
    "Accept-Encoding": "gzip",
    "Content-Type": "application/json",
}

payload = {
    "field": "filters.collection",
    "contains": "Gallery",
}

response = requests.post(
    "https://api.cs2.sh/v1/live/youpin/search/options",
    headers=headers,
    json=payload,
)

response.raise_for_status()
data = response.json()
```

**Node**

```javascript
const headers = {
  "Authorization": "Bearer <<YOUR_API_KEY>>",
  "Accept-Encoding": "gzip",
  "Content-Type": "application/json",
};

const response = await fetch("https://api.cs2.sh/v1/live/youpin/search/options", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "field": "filters.collection",
    "contains": "Gallery"
  }),
});

if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
```

**Go**

```go
package main

import (
    "bytes"
    "compress/gzip"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    payload := map[string]any{
        "field": "filters.collection",
        "contains": "Gallery",
    }
    body, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", "https://api.cs2.sh/v1/live/youpin/search/options", bytes.NewReader(body))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer <<YOUR_API_KEY>>")
    req.Header.Set("Accept-Encoding", "gzip")

    resp, err := http.DefaultClient.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()

    if resp.StatusCode < 200 || resp.StatusCode >= 300 {
        body, _ := io.ReadAll(resp.Body)
        panic(fmt.Sprintf("HTTP %d: %s", resp.StatusCode, body))
    }

    var reader io.Reader = resp.Body
    if resp.Header.Get("Content-Encoding") == "gzip" {
        gz, err := gzip.NewReader(resp.Body)
        if err != nil { panic(err) }
        defer gz.Close()
        reader = gz
    }

    var data any
    if err := json.NewDecoder(reader).Decode(&data); err != nil { panic(err) }
    fmt.Printf("%#v\n", data)
}
```

**R**

```r
library(httr2)

payload <- list(
  field = "filters.collection",
  contains = "Gallery"
)

resp <- request("https://api.cs2.sh/v1/live/youpin/search/options") |>
  req_headers(
    Authorization = "Bearer <<YOUR_API_KEY>>",
    `Accept-Encoding` = "gzip"
  ) |>
  req_body_json(payload) |>
  req_perform()

data <- resp_body_json(resp)
```

### Parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | `string` | Yes | The request field to list choices for, such as `filters.weapon` or `filters.stickers.entries[].name`. |
| `contains` | `string` | No | Text that a choice's label must contain, matched without regard to case. |
| `cursor` | `string` | No | The `page.next_cursor` from the previous page of choices, sent as the only field. |

### Response

```json
{
  "market": "string",
  "operation": "string",
  "field": "string",
  "availability": "string",
  "completeness": "string",
  "options": [
    {
      "label": "string",
      "query": {
        "path": "string",
        "body": null
      }
    }
  ],
  "metadata": null,
  "page": {
    "page_size": 0,
    "has_next": false,
    "next_cursor": "string",
    "cursor_expires_at": "string",
    "total_count": 0,
    "total_exact": false
  },
  "response_time": "string"
}
```

### Response fields

[LiveOptionsResponse](/docs/objects#liveoptionsresponse) fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `market` | `string` | No | The marketplace. |
| `operation` | `string` | No | The data operation the choices apply to. |
| `field` | `string` | No | The request field the choices are for. |
| `availability` | `string` | No | Whether choices could be loaded for this request. |
| `completeness` | `string` | No | `complete` when the list holds every accepted value. `partial` when it holds suggestions, and other values may also work. |
| `options` | [LiveOption[]](/docs/objects#liveoption) | No | The choices. |
| `metadata` | `object` | No | Information about the choice list, such as when it was fetched. |
| `page` | [LivePage](/docs/objects#livepage) | No | Paging for long choice lists. |
| `response_time` | `string (date-time)` | No | When cs2.sh sent the response (UTC). |
