> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bayse.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# API reference

> Complete reference for all Bayse Markets API endpoints

## Base URL

```
https://relay.bayse.markets
```

<Warning>
  Our sandbox environment is currently a work in progress. For now, please use the production URL and sign in with your production credentials.
</Warning>

## Authentication

Authentication requirements vary by endpoint. See the [Authentication guide](/authentication) for full details.

<CardGroup cols={2}>
  <Card title="Public" icon="globe" color="#10B981">
    No authentication required.
  </Card>

  <Card title="Session" icon="right-to-bracket" color="#F59E0B">
    Requires `x-auth-token` + `x-device-id` (from login).
  </Card>

  <Card title="Read" icon="book-open" color="#3B82F6">
    Requires `X-Public-Key` header.
  </Card>

  <Card title="Write" icon="pen" color="#EF4444">
    Requires `X-Public-Key` + `X-Timestamp` + `X-Signature`.
  </Card>
</CardGroup>

## Error responses

All errors return a consistent JSON body:

```json theme={null}
{
  "error": "error_code",
  "message": "Human-readable description",
  "statusCode": 400
}
```

Common status codes:

| Code | Meaning                                        |
| ---- | ---------------------------------------------- |
| 400  | Bad request — invalid parameters.              |
| 401  | Unauthorized — missing or invalid credentials. |
| 404  | Not found — resource does not exist.           |
| 422  | Unprocessable entity — validation failed.      |
| 500  | Internal server error.                         |

## Pagination

List endpoints use `page` and `size` query parameters:

```
GET /v1/pm/events?page=1&size=20
```

Paginated responses include a `pagination` object:

```json theme={null}
{
  "pagination": {
    "page": 1,
    "size": 20,
    "lastPage": 5,
    "totalCount": 98
  }
}
```

## Request tracing

You can provide a custom trace ID for debugging:

```bash theme={null}
curl -H "x-trace-id: my-trace-123" https://relay.bayse.markets/v1/pm/events
```

The trace ID is echoed back in response headers.

## Endpoints

### System

<CardGroup cols={2}>
  <Card title="Health check" href="/api-reference/system/health" icon="heart-pulse">
    `GET /health`
  </Card>

  <Card title="Version" href="/api-reference/system/version" icon="code-branch">
    `GET /version`
  </Card>
</CardGroup>

### User

<CardGroup cols={2}>
  <Card title="Login" href="/api-reference/user/login" icon="right-to-bracket">
    `POST /v1/user/login`
  </Card>

  <Card title="Create API key" href="/api-reference/user/create-api-key" icon="key">
    `POST /v1/user/me/api-keys`
  </Card>

  <Card title="List API keys" href="/api-reference/user/list-api-keys" icon="list">
    `GET /v1/user/me/api-keys`
  </Card>

  <Card title="Revoke API key" href="/api-reference/user/revoke-api-key" icon="trash">
    `DELETE /v1/user/me/api-keys/{keyId}`
  </Card>

  <Card title="Rotate API key" href="/api-reference/user/rotate-api-key" icon="rotate">
    `POST /v1/user/me/api-keys/{keyId}/rotate`
  </Card>
</CardGroup>

### Trading

<CardGroup cols={2}>
  <Card title="List events" href="/api-reference/pm/list-events" icon="calendar">
    `GET /v1/pm/events`
  </Card>

  <Card title="Get event" href="/api-reference/pm/get-event" icon="circle-info">
    `GET /v1/pm/events/{eventId}`
  </Card>

  <Card title="Get quote" href="/api-reference/pm/get-quote" icon="calculator">
    `POST /v1/pm/events/{eventId}/markets/{marketId}/quote`
  </Card>

  <Card title="Place order" href="/api-reference/pm/place-order" icon="cart-shopping">
    `POST /v1/pm/events/{eventId}/markets/{marketId}/orders`
  </Card>

  <Card title="Get portfolio" href="/api-reference/pm/get-portfolio" icon="briefcase">
    `GET /v1/pm/portfolio`
  </Card>

  <Card title="List orders" href="/api-reference/pm/list-orders" icon="list-check">
    `GET /v1/pm/orders`
  </Card>

  <Card title="Get order" href="/api-reference/pm/get-order" icon="receipt">
    `GET /v1/pm/orders/{orderId}`
  </Card>

  <Card title="Cancel order" href="/api-reference/pm/cancel-order" icon="xmark">
    `DELETE /v1/pm/orders/{orderId}`
  </Card>

  <Card title="Mint shares" href="/api-reference/pm/mint-shares" icon="coins">
    `POST /v1/pm/markets/{marketId}/mint`
  </Card>

  <Card title="Burn shares" href="/api-reference/pm/burn-shares" icon="fire">
    `POST /v1/pm/markets/{marketId}/burn`
  </Card>

  <Card title="Activities" href="/api-reference/pm/activities" icon="clock-rotate-left">
    `GET /v1/pm/activities`
  </Card>
</CardGroup>

### Wallet

<CardGroup cols={2}>
  <Card title="Get assets" href="/api-reference/wallet/get-assets" icon="wallet">
    `GET /v1/wallet/assets`
  </Card>
</CardGroup>

### Market data

<CardGroup cols={2}>
  <Card title="Price history" href="/api-reference/pm/price-history" icon="chart-line">
    `GET /v1/pm/events/{eventId}/price-history`
  </Card>

  <Card title="Order book" href="/api-reference/pm/order-book" icon="book-open">
    `GET /v1/pm/books`
  </Card>

  <Card title="Ticker" href="/api-reference/pm/ticker" icon="gauge-high">
    `GET /v1/pm/markets/{marketId}/ticker`
  </Card>

  <Card title="Trades" href="/api-reference/pm/trades" icon="arrow-right-arrow-left">
    `GET /v1/pm/trades`
  </Card>
</CardGroup>

### Sports data

<CardGroup cols={2}>
  <Card title="Sports Leagues" href="/api-reference/pm/list-sports-leagues" icon="football">
    `GET /v1/pm/sports/leagues`
  </Card>

  <Card title="Sports Teams" href="/api-reference/pm/list-sports-teams" icon="soccer-ball">
    `GET /v1/pm/sports/teams`
  </Card>

  <Card title="Sports Games" href="/api-reference/pm/list-sports-games" icon="trophy">
    `GET /v1/pm/sports/games`
  </Card>
</CardGroup>
