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

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](https://docs.swaps.xyz/prediction-market-reference/integration-patterns.md) guide — it compares the one-call chain-abstracted flow against the direct three-step flow — then follow the [Transaction Lifecycle](https://docs.swaps.xyz/prediction-market-reference/transaction-lifecycle.md) walkthrough.

## Endpoint reference

### Trading

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

### Market Discovery

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

### Market Information

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

### User Positions & Activity

| API | Description |
| :- | :- |
| [Get Current Positions](https://docs.swaps.xyz/prediction-market-reference/get-current-positions.md) | View all open positions with PnL calculations |
| [Get Closed Positions](https://docs.swaps.xyz/prediction-market-reference/get-closed-positions.md) | Access historical positions from resolved markets |
| [Get Trades](https://docs.swaps.xyz/prediction-market-reference/get-trades.md) | Retrieve detailed trade history |
| [Get Activity](https://docs.swaps.xyz/prediction-market-reference/get-activity.md) | Comprehensive activity feed including orders and trades |
| [Get PnL](https://docs.swaps.xyz/prediction-market-reference/get-profit-and-loss.md) | 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.

Create a key in the [Console](https://console.swaps.xyz).

## Getting Started

1. **Discover Markets**: Start with the search or trending endpoints to find markets
2. **Place Orders**: Pick an [integration pattern](https://docs.swaps.xyz/prediction-market-reference/integration-patterns.md) and place your first order
3. **Track Workflows**: Follow execution with [Get Workflow Status](https://docs.swaps.xyz/prediction-market-reference/get-workflow-status.md)
4. **Manage Positions**: Sell, redeem, or merge positions and withdraw collateral

In accordance with the underlying prediction markets, Swaps' prediction market APIs are not available to users located in the United States.

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

  ![Polymarket Demo App](https://mintcdn.com/swaps/J12wbEzY9N1zdhok/images/polymarket-demo-app.png?fit=max\&auto=format\&n=J12wbEzY9N1zdhok\&q=85\&s=b810d8104501006de86ebc83cfaad062)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.