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

# Overview

> Comprehensive API for querying prediction market data, user positions, and trading activity.

export const Callout = ({type = 'info', children}) => {
  const borderColor = ({
    info: '#007acc',
    warning: '#FFC263',
    danger: '#d9534f',
    success: '#00C256'
  })[type] || '#ccc';
  const bgColor = ({
    info: '#f3f9ff',
    warning: '#FFF2DE',
    danger: '#f7f2f1',
    note: '#f8f8f8',
    tip: '#f1f1f8',
    success: '#E0FFEE'
  })[type] || '#f3f9ff';
  return <div style={{
    borderLeft: `4px solid ${borderColor}`,
    backgroundColor: bgColor,
    padding: '0.5rem',
    borderRadius: '12px',
    margin: '1rem 0',
    fontSize: '14px'
  }}>
      {children}
    </div>;
};

Swaps enables users to trade on [Polymarket](https://polymarket.com) directly from their wallet using any token on any chain. The prediction market data endpoints provide real time market information to build comprehensive applications on Polymarket.

## Endpoint reference

### Market Discovery

| API                                                                            | Description                                                  |
| :----------------------------------------------------------------------------- | :----------------------------------------------------------- |
| [Search Markets](/prediction-market-data-reference/search-markets)             | Query markets by keywords or tags                            |
| [Get Trending Markets](/prediction-market-data-reference/get-trending-markets) | Discover high-volume markets sorted by 24hr trading activity |
| [Get Tags](/prediction-market-data-reference/get-tags)                         | Retrieve categories for filtering markets                    |

### Market Information

| API                                                                      | Description                                                   |
| :----------------------------------------------------------------------- | :------------------------------------------------------------ |
| [Get Event](/prediction-market-data-reference/get-event)                 | Retrieve complete event details with all associated markets   |
| [Get Markets](/prediction-market-data-reference/get-markets)             | Query specific markets by token ID, slug, or category         |
| [Get Market Price](/prediction-market-data-reference/get-market-price)   | Fetch current best bid/ask prices                             |
| [Get Price History](/prediction-market-data-reference/get-price-history) | Analyze historical price data across different time intervals |

### User Positions & Activity

| API                                                                              | Description                                             |
| :------------------------------------------------------------------------------- | :------------------------------------------------------ |
| [Get Current Positions](/prediction-market-data-reference/get-current-positions) | View all open positions with PnL calculations           |
| [Get Closed Positions](/prediction-market-data-reference/get-closed-positions)   | Access historical positions from resolved markets       |
| [Get Trades](/prediction-market-data-reference/get-trades)                       | Retrieve detailed trade history                         |
| [Get Activity](/prediction-market-data-reference/get-activity)                   | Comprehensive activity feed including orders and trades |
| [Get PnL](/prediction-market-data-reference/get-pnl)                             | Aggregate profit and loss summary                       |

## Authentication

All API endpoints require authentication using API keys passed via the `x-api-key` header. We have provided a highly ratelimited API key for testing in the API playground.

<Callout type="info">Create a key in the [Console](https://console.swaps.xyz).</Callout>

## Getting Started

1. **Discover Markets**: Start with the search or trending endpoints to find markets
2. **Get Details**: Use the market or event endpoints to fetch comprehensive information
3. **Track Prices**: Monitor real-time prices and historical data
4. **Analyze Users**: Query positions and activity for wallet addresses

<Callout type="warning">In accordance with the underlying prediction markets, Swaps' prediction market APIs are not available to users located in the United States.</Callout>

## Related Resources

* [Polymarket Demo App](https://box-monorepo-example-app.vercel.app/testApiPolymarket) - Test Swaps' prediction market APIs by sending live Polymarket orders. Provides a reference for the discovery path and network requests to quickly add prediction markets to your app.
  <img src="https://mintcdn.com/swaps/J12wbEzY9N1zdhok/images/polymarket-demo-app.png?fit=max&auto=format&n=J12wbEzY9N1zdhok&q=85&s=b810d8104501006de86ebc83cfaad062" alt="Polymarket Demo App" width="2894" height="1702" data-path="images/polymarket-demo-app.png" />
