> For the complete documentation index, see [llms.txt](https://roqqu-api-services.gitbook.io/ras/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://roqqu-api-services.gitbook.io/ras/trade/buy.md).

# Buy

Buy cryptocurrency.

**Endpoint:** `POST /trade/buy`

**Authentication:** Required (x-api-key header)

**Authentication:** Required (`x-api-key` for live, `x-staging-api-key` for test)

**Fees**

Fees are taken from the token you use for the trade (USDT).

#### Request Parameters <a href="#request-parameters-11" id="request-parameters-11"></a>

| Parameter | Type   | Required | Description                                              |
| --------- | ------ | -------- | -------------------------------------------------------- |
| amount    | number | Yes      | Amount of token you want to buy (must be greater than 0) |
| token     | string | Yes      | Token to buy (e.g., btc, eth)                            |

#### Example Request <a href="#example-request-21" id="example-request-21"></a>

```
curl -X POST https://service.roqqu.com/v1/trade/buy \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "amount=0.00002" \
  -d "token=btc"
```

#### Example Response <a href="#example-response-21" id="example-response-21"></a>

```
{
  "status": "success",
  "message": "buy operation successful",
  "data": null
}
```

> Buy is a ledger operation. It does **not** emit a webhook. Confirm via balances / history.

#### **Error** Response <a href="#example-response-21" id="example-response-21"></a>

**Invalid token:**

```
{
  "status": "success",
  "message": "buy operation successful",
  "data": null
}
```

**Buys not enabled:**

```
{
  "status": "fail",
  "message": "buys not currently enabled for token"
}
```

**Insufficient USDT (source for buy):**

```
{
  "status": "fail",
  "message": "insufficient USDT balance"
}
```

**Fee too high (fee ≥ source amount):**

```
{
  "status": "fail",
  "message": "fee cannot be greater than or equal to amount"
}
```

**Below minimum:**

```
{
  "status": "fail",
  "message": "amount cannot be less than 0.00001"
}
```

**Above maximum:**

```
{
  "status": "fail",
  "message": "amount cannot be more than 1"
}
```

**Amount must be positive:**

```
{
  "status": "fail",
  "message": "amount must be greater than 0"
}
```

**Unable to load token data:**

```
{
  "status": "fail",
  "message": "unable to get token data"
}
```
