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

# Markets API

> Endpoints for listing and inspecting prediction markets.

<Note>
  All Markets API endpoints hit the **Arc Testnet** deployment at `https://api.pulsmarket.tech`.
  Data and balances on testnet are not real and may be reset without notice.
</Note>

## Authentication

| Endpoint                           | Auth Required                       |
| ---------------------------------- | ----------------------------------- |
| `GET /api/markets`                 | No                                  |
| `GET /api/markets/:slug`           | No                                  |
| `GET /api/markets/:slug/prices`    | No                                  |
| `POST /api/markets/:slug/activate` | **Yes** — Supabase JWT Bearer token |

For authenticated endpoints, include the header:

```
Authorization: Bearer <SUPABASE_JWT>
```

***

## List Markets

```
GET /api/markets
```

Returns all available prediction markets.

### Query Parameters

| Parameter | Type     | Required | Description                                              |
| --------- | -------- | -------- | -------------------------------------------------------- |
| `status`  | `string` | No       | Filter by market status (`active`, `closed`, `pending`). |
| `limit`   | `number` | No       | Maximum number of markets to return. Default `50`.       |
| `offset`  | `number` | No       | Pagination offset. Default `0`.                          |

### Response

```json theme={null}
{
  "markets": [
    {
      "id": "cm_01abc",
      "slug": "btc-100k-july-2026",
      "title": "Will BTC reach $100k by July 2026?",
      "status": "active",
      "outcomes": ["Yes", "No"],
      "prices": { "Yes": 0.62, "No": 0.38 },
      "volume": 14200.50,
      "liquidity": 8500.00,
      "createdAt": "2026-06-15T12:00:00Z",
      "closesAt": "2026-07-31T23:59:59Z"
    },
    {
      "id": "cm_02def",
      "slug": "eth-merge-v2-q3",
      "title": "Will Ethereum ship Merge v2 in Q3 2026?",
      "status": "active",
      "outcomes": ["Yes", "No"],
      "prices": { "Yes": 0.45, "No": 0.55 },
      "volume": 7300.00,
      "liquidity": 4100.00,
      "createdAt": "2026-06-20T09:30:00Z",
      "closesAt": "2026-09-30T23:59:59Z"
    }
  ],
  "total": 2,
  "limit": 50,
  "offset": 0
}
```

***

## Get Market Detail

```
GET /api/markets/:slug
```

Returns full details for a single market by its slug.

### Path Parameters

| Parameter | Type     | Required | Description                 |
| --------- | -------- | -------- | --------------------------- |
| `slug`    | `string` | Yes      | URL-safe market identifier. |

### Response

```json theme={null}
{
  "id": "cm_01abc",
  "slug": "btc-100k-july-2026",
  "title": "Will BTC reach $100k by July 2026?",
  "description": "Resolves Yes if the BTC/USD spot price on any major exchange reaches $100,000 before August 1, 2026.",
  "status": "active",
  "outcomes": ["Yes", "No"],
  "prices": { "Yes": 0.62, "No": 0.38 },
  "volume": 14200.50,
  "liquidity": 8500.00,
  "contractAddress": "0x1a2b3c4d5e6f...",
  "chainId": 2010111,
  "createdAt": "2026-06-15T12:00:00Z",
  "closesAt": "2026-07-31T23:59:59Z"
}
```

***

## Get Price History

```
GET /api/markets/:slug/prices
```

Returns historical price data for a market's outcomes.

### Path Parameters

| Parameter | Type     | Required | Description                 |
| --------- | -------- | -------- | --------------------------- |
| `slug`    | `string` | Yes      | URL-safe market identifier. |

### Query Parameters

| Parameter  | Type     | Required | Description                                       |
| ---------- | -------- | -------- | ------------------------------------------------- |
| `interval` | `string` | No       | Time bucket size: `1h`, `4h`, `1d`. Default `1h`. |
| `from`     | `string` | No       | ISO 8601 start timestamp.                         |
| `to`       | `string` | No       | ISO 8601 end timestamp.                           |

### Response

```json theme={null}
{
  "slug": "btc-100k-july-2026",
  "interval": "1h",
  "prices": [
    { "timestamp": "2026-06-28T00:00:00Z", "Yes": 0.58, "No": 0.42 },
    { "timestamp": "2026-06-28T01:00:00Z", "Yes": 0.60, "No": 0.40 },
    { "timestamp": "2026-06-28T02:00:00Z", "Yes": 0.62, "No": 0.38 }
  ]
}
```

***

## Activate Market (Deploy Contract)

```
POST /api/markets/:slug/activate
```

Deploys the on-chain prediction market contract for a pending market. Requires authentication.

### Path Parameters

| Parameter | Type     | Required | Description                 |
| --------- | -------- | -------- | --------------------------- |
| `slug`    | `string` | Yes      | URL-safe market identifier. |

### Headers

| Header          | Value                   |
| --------------- | ----------------------- |
| `Authorization` | `Bearer <SUPABASE_JWT>` |

### Response

```json theme={null}
{
  "slug": "btc-100k-july-2026",
  "status": "active",
  "contractAddress": "0x1a2b3c4d5e6f...",
  "chainId": 2010111,
  "txHash": "0xabc123..."
}
```

### Error Codes

| Status | Description                  |
| ------ | ---------------------------- |
| `401`  | Missing or invalid JWT.      |
| `404`  | Market not found.            |
| `409`  | Market is already activated. |
