# POST /v1/live/youpin/buy_orders

Current Youpin (youpin898) buy orders for a CS2 item: each order's price in CNY, quantity, and float, phase, or fade conditions.

Returns the open Youpin buy orders for one item, each with its price, its quantity, and the conditions it puts on the item, such as a float range, a phase, or a fade range.

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

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

## Inputs

Send exactly one of `market_hash_name` and `item_id`. Everything else is optional.

| Field | Type | Meaning |
| --- | --- | --- |
| `market_hash_name` | `string` | The item. |
| `item_id` | `string` | The item's Youpin [template ID](/docs/live-youpin#ids). |
| `filters` | `object` | See [Filters](#filters). |
| `raw_response` | `boolean` | `false` returns [structured rows](/docs/live-overview#raw-and-structured-responses). Without it, `data` is Youpin's own JSON. |

```json
{
  "market_hash_name": "AWP | Asiimov (Field-Tested)"
}
```

Buy orders have no listing types and no sorting, and come back in Youpin's order.

## Filters

| Filter | Type | Meaning |
| --- | --- | --- |
| `min_float`, `max_float` | `number` | Orders whose float condition is [exactly this range](#float-filters-match-exact-ranges), from 0 to 1. Send both. |
| `fade_bucket` | `object` | Orders for exactly this fade range, as `min` and `max` from 0 to 100. The range must be one Youpin offers for the item. |
| `phase` | `string` | Orders for one Doppler phase or gem, such as `Ruby`. The response can also include orders that accept any phase. |

`weapon`, `finish`, `wear`, and `quality` are accepted, but cs2.sh only checks them against the item, and a mismatch returns `400`.

Youpin's own request parameters go in [`market_parameters`](/docs/live-overview#filters-and-sorting).

## Request

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

**curl**

```bash
curl -X POST https://api.cs2.sh/v1/live/youpin/buy_orders \
  -H "Authorization: Bearer <<YOUR_API_KEY>>" \
  -H "Accept-Encoding: gzip" --compressed \
  -H "Content-Type: application/json" \
  -d '{
  "market_hash_name": "AWP | Asiimov (Field-Tested)",
  "raw_response": false
}'
```

**Python**

```python
import requests

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

payload = {
    "market_hash_name": "AWP | Asiimov (Field-Tested)",
    "raw_response": False,
}

response = requests.post(
    "https://api.cs2.sh/v1/live/youpin/buy_orders",
    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/buy_orders", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "market_hash_name": "AWP | Asiimov (Field-Tested)",
    "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{
        "market_hash_name": "AWP | Asiimov (Field-Tested)",
        "raw_response": false,
    }
    body, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", "https://api.cs2.sh/v1/live/youpin/buy_orders", 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(
  market_hash_name = "AWP | Asiimov (Field-Tested)",
  raw_response = FALSE
)

resp <- request("https://api.cs2.sh/v1/live/youpin/buy_orders") |>
  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.buy_orders[]` holds one [LiveBuyOrder](/docs/objects#livebuyorder) per order:

| Field | Description |
| --- | --- |
| `id` | The order ID. |
| `price`, `currency` | What the buyer pays per item, in CNY. |
| `quantity` | How many the buyer wants. |
| `market_hash_name` | The item the order is for. |
| `conditions` | What the order requires of the item: `min_float` and `max_float`, `min_fade` and `max_fade`, or `variant`. `null` means the order takes any copy of the item. |
| `created_at` | When the buyer placed the order. |

An order with `conditions` set to `{}` and an `unmapped_condition` entry in `data.warnings` has a condition cs2.sh couldn't read. Treat it as a restricted order, not one that takes any copy.

In a `phase` request, an order that accepts any phase has no `variant` in its `conditions`.

## Float filters match exact ranges

`min_float` and `max_float` return the orders whose float condition is exactly that range, not every order that would accept a float in it. An order that accepts floats from 0.06 to 0.07 is returned for this request:

```json
{
  "market_hash_name": "AK-47 | Red Laminate (Factory New)",
  "filters": { "min_float": 0.06, "max_float": 0.07 }
}
```

It isn't returned for `0.063` to `0.067`, even though that range sits inside it. A float filter can also leave out orders with no float condition.

On [CSFloat](/docs/live-csfloat-buy-orders), a float range returns every order that would accept it. The float ranges buyers use on an item come from the options path below, or from each order's `conditions` in a request without a float filter.

## Errors

A request returns `400` when it sends only one of `min_float` and `max_float`, or a `fade_bucket` that Youpin doesn't offer for the item. Other errors are the [shared live errors](/docs/live-overview#errors-and-retries).

## POST /v1/live/youpin/buy_orders/options

Returns the valid [choices](/docs/live-overview#filter-options) for one field of a buy orders request. Every field needs an item:

| `field` | Choices |
| --- | --- |
| `filters.min_float`, `filters.max_float` | The float ranges Youpin suggests for the item, as pairs |
| `filters.fade_bucket` | The fade ranges Youpin offers for the item |
| `filters.phase` | The phases and gems the item has |

Each option's `query` is a complete buy orders request with the choice applied.

```json
{
  "market_hash_name": "AK-47 | Red Laminate (Factory New)",
  "field": "filters.min_float"
}
```

The float ranges are suggestions, so `completeness` is `partial`. Any valid pair works, and some items have no suggestions. The listed fade ranges are the only ones the filter accepts.

### Request

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

**curl**

```bash
curl -X POST https://api.cs2.sh/v1/live/youpin/buy_orders/options \
  -H "Authorization: Bearer <<YOUR_API_KEY>>" \
  -H "Accept-Encoding: gzip" --compressed \
  -H "Content-Type: application/json" \
  -d '{
  "market_hash_name": "AK-47 | Red Laminate (Factory New)",
  "field": "filters.min_float"
}'
```

**Python**

```python
import requests

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

payload = {
    "market_hash_name": "AK-47 | Red Laminate (Factory New)",
    "field": "filters.min_float",
}

response = requests.post(
    "https://api.cs2.sh/v1/live/youpin/buy_orders/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/buy_orders/options", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "market_hash_name": "AK-47 | Red Laminate (Factory New)",
    "field": "filters.min_float"
  }),
});

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{
        "market_hash_name": "AK-47 | Red Laminate (Factory New)",
        "field": "filters.min_float",
    }
    body, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", "https://api.cs2.sh/v1/live/youpin/buy_orders/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(
  market_hash_name = "AK-47 | Red Laminate (Factory New)",
  field = "filters.min_float"
)

resp <- request("https://api.cs2.sh/v1/live/youpin/buy_orders/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). |
