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

# API Reference

> REST API for the Predicta Markets platform — markets, trading, accounts, and referrals.

## Overview

The Predicta Markets API gives you programmatic access to markets, trading, account data, and the referral system. It is a REST API that accepts JSON request bodies and returns JSON responses.

<Info>
  API access is not open by default. To request credentials, email
  [api-support@predictamarkets.com](mailto:api-support@predictamarkets.com).
</Info>

## Base URL

```
https://api.predictamarkets.com
```

## Authentication

All authenticated endpoints require an **API key** passed in the `X-Api-Key` request header.

```http theme={null}
X-Api-Key: your-api-key-here
```

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.predictamarkets.com/v1/markets \
    -H "X-Api-Key: your-api-key-here"
  ```

  ```python Python theme={null}
  import httpx

  client = httpx.Client(headers={"X-Api-Key": "your-api-key-here"})
  response = client.get("https://api.predictamarkets.com/v1/markets")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.predictamarkets.com/v1/markets", {
    headers: { "X-Api-Key": "your-api-key-here" },
  });
  ```
</CodeGroup>

### Creating an API key

You can generate your own API key directly from your account — no need to contact support.

<Steps>
  <Step title="Open your Profile">
    Log in to [predictamarkets.com](https://predictamarkets.com) and click your avatar in the top-right corner, then select **Profile**.
  </Step>

  <Step title="Go to API Keys">
    Scroll to the **API Keys** section on your Profile page.
  </Step>

  <Step title="Create a new key">
    Click **Create API Key**, give it a name (e.g. `my-integration`), and optionally set an expiry date. Click **Create**.
  </Step>

  <Step title="Copy the key immediately">
    Your key is shown **only once**. Copy it now and store it somewhere safe — you cannot retrieve it again. If you lose it, rotate the key to get a new one.
  </Step>
</Steps>

<Warning>
  API keys grant full access to your account. Never share a key or commit it to source control. If a key is compromised, rotate or revoke it immediately from your Profile.
</Warning>

### Managing keys

From the **API Keys** section of your Profile you can:

| Action     | When to use                                                                                                           |
| ---------- | --------------------------------------------------------------------------------------------------------------------- |
| **Rotate** | Replace a key with a new one while keeping the same name and settings — use this if you suspect a key has been leaked |
| **Revoke** | Permanently delete a key — any integrations using it will stop working immediately                                    |

## Errors

All errors follow a consistent shape:

```json theme={null}
{ "detail": "Human-readable error message" }
```

| Status | Meaning                                                      |
| ------ | ------------------------------------------------------------ |
| `400`  | Bad request — check your parameters                          |
| `401`  | Missing or invalid API key                                   |
| `403`  | Authenticated but not authorised for this resource           |
| `404`  | Resource not found                                           |
| `422`  | Validation error — check the response body for field details |
| `500`  | Server error                                                 |

## Pagination

List endpoints accept `skip` and `limit` query parameters:

| Parameter | Default |
| --------- | ------- |
| `skip`    | `0`     |
| `limit`   | `10`    |

## Support

For API access requests or integration help: [api-support@predictamarkets.com](mailto:api-support@predictamarkets.com)
