# How to Build a CS2 Trade-Up Calculator

> cs2.sh provides the three pricing inputs a CS2 trade-up calculator needs: item metadata from the schema, exact-float BUFF input buckets, and current bids for valuing possible outputs.

The API does not return a finished contract or outcome-probability table. A calculator must supply and validate the game rules, then use cs2.sh to resolve and price the resulting items.

## 1. Resolve inputs and possible outputs

`GET /v1/schema` is keyed by exact `market_hash_name`. Skin records can include rarity, collections, containers, available wears, native `float_range`, StatTrak and Souvenir flags, `def_index`, and `paint_index`.

Use those fields to verify item identity and map each modeled output to the correct wear row. Doppler, Gamma Doppler, and Case Hardened variants appear both under their base item's `variants` list and as linked standalone rows.

## 2. Cost inputs at their actual float range

`GET /v1/market/buff/latest` splits each item into `base`, `float`, `fade`, and `float_fade` buckets. Every bucket has a stable `bucket_id` and its own `ask`, `avg_ask`, `bid`, `ask_volume`, and `bid_volume`.

Match an exact input float where `float.min` is inclusive and `float.max` is exclusive. The matched bucket's `ask` is a more relevant acquisition floor than the exterior-wide `base` ask, especially near a low-float boundary. Variants carry their own bucket arrays.

## 3. Value outputs at a chosen exit quote

Read current prices from `GET /v1/prices/latest`. For an immediate-sale model, use positive, fresh `bid` values from the chosen cash sources and calculate the probability-weighted output value. For an acquisition-value model, use `ask` and label it separately.

Source field coverage differs. BUFF, Youpin, and Steam include `bid_volume`; CSFloat and C5Game provide bids without bid volume; Skinport has no bid. Keep missing sources out of the calculation rather than replacing them with zero.

## Applicable endpoints

| Endpoint | Calculator input | Plans |
| --- | --- | --- |
| `GET /v1/schema` | Identity, rarity, collections, wears, and native float bounds | All plans |
| `GET /v1/market/buff/latest` | Current BUFF prices by float and fade bucket | All plans |
| `GET /v1/prices/latest` | Current cross-market asks and bids | All plans |

## Pricing limits

- A BUFF bucket `ask` is the lowest listing in that range. `ask_volume` counts all listings in the range, not quantity at the floor, so it cannot price a multi-unit fill by itself.
- A highest bid is an observed buy order, not a completed sale. Fees and trade restrictions remain external to the response.
- Exact float, paint seed, and stickers are not priced at the individual asset level. BUFF ranges provide narrower market buckets, not a quote for a unique inventory item.
- A crossed source pair can reflect asynchronous collection. Exclude that source's bid from exit value when its positive ask is lower.

The [BUFF float-range history guide](/resources/how-to-get-buff-float-range-price-history) covers bucket selection in more detail.
