> ## 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

> Trade on prediction markets and query 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) using **any token on any chain, directly from their existing wallet** — instead of needing a Polymarket trading account and pUSD. This reference covers the full lifecycle: discovering markets, placing orders, tracking workflows, managing positions, and withdrawing funds.

**Why build prediction markets on Swaps:**

* **One call to place a bet.** A single `getAction` request swaps any token on any chain into collateral and places the order — the fastest path from "user holds ETH on Base" to "position on Polymarket".
* **The full stack in one API.** Market discovery, live prices, order placement, position management, PnL, and withdrawals — no stitching together separate data and execution providers.
* **Non-custodial by design.** Every user gets a deposit wallet keyed to their own EOA, and every trading call is authorized by the user's EIP-712 signature.

New to the integration? Start with the [Integration Patterns](/prediction-market-reference/integration-patterns) guide — it compares the one-call chain-abstracted flow against the direct three-step flow — then follow the [Transaction Lifecycle](/prediction-market-reference/transaction-lifecycle) walkthrough.

## Endpoint reference

### Trading

| API                                                                                         | Description                                                                                                 |
| :------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------- |
| [Place Order (Chain Abstracted)](/prediction-market-reference/place-order-chain-abstracted) | Place an order with a single `getAction` call using any token on any chain, from the user's existing wallet |
| [Create or Fetch User](/prediction-market-reference/create-or-fetch-user)                   | Deploy or fetch the user's deposit (proxy) wallet                                                           |
| [Place Order](/prediction-market-reference/place-order)                                     | Place a signed order directly against the Polymarket CLOB                                                   |
| [Sell Position](/prediction-market-reference/sell-position)                                 | Exit a position with a market order                                                                         |
| [Redeem Position](/prediction-market-reference/redeem-position)                             | Claim winnings from a resolved market                                                                       |
| [Merge Position](/prediction-market-reference/merge-position)                               | Combine complementary YES/NO holdings back into collateral                                                  |
| [Withdraw](/prediction-market-reference/withdraw)                                           | Withdraw collateral to any wallet, token, or chain                                                          |
| [Get Workflow Status](/prediction-market-reference/get-workflow-status)                     | Track the status of a workflow execution                                                                    |

### Market Discovery

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

### Market Information

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

### User Positions & Activity

| API                                                                         | Description                                             |
| :-------------------------------------------------------------------------- | :------------------------------------------------------ |
| [Get Current Positions](/prediction-market-reference/get-current-positions) | View all open positions with PnL calculations           |
| [Get Closed Positions](/prediction-market-reference/get-closed-positions)   | Access historical positions from resolved markets       |
| [Get Trades](/prediction-market-reference/get-trades)                       | Retrieve detailed trade history                         |
| [Get Activity](/prediction-market-reference/get-activity)                   | Comprehensive activity feed including orders and trades |
| [Get PnL](/prediction-market-reference/get-profit-and-loss)                 | 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. **Place Orders**: Pick an [integration pattern](/prediction-market-reference/integration-patterns) and place your first order
3. **Track Workflows**: Follow execution with [Get Workflow Status](/prediction-market-reference/get-workflow-status)
4. **Manage Positions**: Sell, redeem, or merge positions and withdraw collateral

<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" />
