# Trades

Retrieve trade history for markets and users.

## Get Trade History

Returns recent trades for a market.

```
GET /api/v1/trades/{marketId}
```

### Path Parameters

| Parameter  | Type    | Description       |
| ---------- | ------- | ----------------- |
| `marketId` | bytes32 | Market identifier |

### Response

{% code title="response.json" %}

```json
{
  "marketId": "0x1234...abcd",
  "trades": [
    {
      "price": 550000,
      "size": 10000000,
      "buyer": "0xBuyerAddress...",
      "seller": "0xSellerAddress...",
      "outcome": 0,
      "timestamp": 1735689000,
      "txHash": "0xTransactionHash..."
    }
  ],
  "count": 5
}
```

{% endcode %}

| Field       | Type    | Description                                     |
| ----------- | ------- | ----------------------------------------------- |
| `price`     | uint64  | Trade price (6 decimals). `550000` = $0.55      |
| `size`      | uint64  | Trade size (6 decimals). `10000000` = 10 shares |
| `buyer`     | address | Buyer's wallet address                          |
| `seller`    | address | Seller's wallet address                         |
| `outcome`   | uint8   | `0` = YES, `1` = NO                             |
| `timestamp` | int64   | Unix timestamp of the trade                     |
| `txHash`    | string  | On-chain settlement transaction hash            |

Returns up to 100 most recent trades, sorted by timestamp descending.

### Example

{% code title="curl" %}

```bash
curl "https://api.turbinefi.com/api/v1/trades/0x1234...abcd"
```

{% endcode %}

***

## Get User Activity

Returns trade history and settlement activity for a user on a specific chain.

```
GET /api/v1/users/{address}/activity
```

### Path Parameters

| Parameter | Type    | Description           |
| --------- | ------- | --------------------- |
| `address` | address | User's wallet address |

### Query Parameters

| Parameter  | Type    | Required | Description                               |
| ---------- | ------- | -------- | ----------------------------------------- |
| `chain_id` | integer | Yes      | Chain ID (e.g., `137`)                    |
| `limit`    | integer | No       | Number of results (default: 50, max: 100) |

### Response

{% code title="response.json" %}

```json
{
  "activity": [
    {
      "marketId": "0x...",
      "marketQuestion": "Will ETH reach $5000?",
      "price": 550000,
      "size": 10000000,
      "userRole": "buyer",
      "timestamp": 1735689000,
      "txHash": "0x..."
    }
  ],
  "settlements": [
    {
      "marketId": "0x...",
      "marketQuestion": "Will BTC hit $100k?",
      "payout": 50000000,
      "winningOutcome": 0,
      "timestamp": 1735700000
    }
  ]
}
```

{% endcode %}

| Field         | Type  | Description                       |
| ------------- | ----- | --------------------------------- |
| `activity`    | array | User's trades with market context |
| `settlements` | array | User's market settlement payouts  |

### Example

{% code title="curl" %}

```bash
curl "https://api.turbinefi.com/api/v1/users/0xYourAddress/activity?chain_id=137&limit=20"
```

{% endcode %}
