API Specification: Polymarket Endpoints
Overview
This document provides comprehensive API specifications for all Polymarket-related endpoints, including the main/api/getAction endpoint for executing orders and all supporting workflow endpoints.
Table of Contents
- Authentication
- Base URL
- Main Endpoint:
/api/getAction - Workflow Endpoints
- Create or Fetch Polymarket User
- Get Workflow Status
- Cancel Order
- Search Markets
- Get Markets
- Get Price
- Get Trending Markets
- Get Trades
- Get Activity
- Get Current Positions
- Get Closed Positions
- Get PnL
- Get Tags
- Sell: coming soon
- Redeem: coming soon
Authentication
All requests require an API key in the request header:Base URL
Main Endpoint: /api/getAction
Overview
The/api/getAction endpoint generates a transaction for executing Polymarket orders. This endpoint accepts query parameters and returns an ActionResponse containing the transaction details.
Endpoint
Request Parameters
Base Action Request Parameters (Required)
| Parameter | Type | Description | Example |
|---|---|---|---|
sender | Address | The wallet address initiating the transaction | 0x1234...5678 |
srcChainId | ChainId (number) | Source chain ID | 8453 |
srcToken | Address | Source token address | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 |
dstChainId | ChainId (number) | Destination chain ID = Polygon: 137 | 137 |
dstToken | Address | Destination token address = USDC.e on Polygon | 0x2791bca1f2de4661ed88a30c99a7a9449aa84174 |
slippage | number | Slippage tolerance in basis points (0-10000) | 100 |
actionType | string | Must be "polymarket" | polymarket |
Polymarket-Specific Parameters (Required)
| Parameter | Type | Description | Example |
|---|---|---|---|
userId | string | Polymarket user ID - returned from createOrFetchPolymarketUser | "0x123...789" |
side | string | Order side: "BUY" or "SELL" | BUY |
tokenID | string | Polymarket clob token ID | "80746058984644290629624903019922696017323803605256698757445938534814122585786" |
orderType | string | Order type: "FOK", "FAK", "GTC", or "GTD" | FOK |
feeRateBps | number | Fee rate in basis points (non-negative) | 0 |
tickSize | string | Price tick size: "0.01", "0.001", or "0.0001" | 0.01 |
negRisk | string | Negative risk flag: "true" or "false" | false |
recipient | Address | Recipient address should be the proxyWallet returned from createOrFetchPolymarketUser | 0xabcd...efgh |
swapDirection | string | Swap direction: Use "exact-amount-out" | |
amount | string | Amount as bigint string (required for market orders: "FOK" or "FAK") | "5000000" (5 USDC with 6 decimals) |
Order Type-Specific Parameters
Limit Orders (GTC/GTD) - Required Fields
| Parameter | Type | Description | Example |
|---|---|---|---|
price | number | Price per share (0-1) | 0.5 |
size | number | Number of shares (positive) | 10 |
expiration | number | (Optional) Expiration time in seconds | 1735689600 |
price + size.
Market Orders (FOK/FAK) - Optional Fields
| Parameter | Type | Description | Example |
|---|---|---|---|
price | number | (Optional) Price per share (0-1) | 0.5 |
size | number | (Optional) Number of shares (positive) | 10 |
amount. This amount should be in terms of USD.
Response
The API returns anActionResponse object containing:
tx: Transaction object (EvmTransaction for Polygon)txId: Transaction IDamountIn: Input payment detailsamountInMax: Maximum input paymentamountOutMin: Minimum output paymentamountOut: Output payment detailsprotocolFee: Protocol feeapplicationFee: Application feeexchangeRate: Exchange rateestimatedTxTime: Estimated transaction timeestimatedPriceImpact: Estimated price impactvmId: Virtual machine IDrequiresTokenApproval: Whether token approval is neededrequiresRegisterTransaction: Whether transaction registration is needed
Example cURL Requests
Example 1: Market Order (FOK) - Buy
Example 2: Limit Order (GTC) - Sell with Price and Size
Example 3: Limit Order (GTD) - Buy with Expiration
Example 4: Market Order (FAK) - Buy with Price and Size (amount calculated)
URL Encoding Notes
When constructing the URL manually, ensure proper URL encoding:- Spaces should be encoded as
%20or+ - Special characters should be URL-encoded
- The
appFeesparameter (if used) should be JSON-encoded:appFees=[{"bps":10,"flatFee":"0","receiverAddress":"0x..."}]
Parameter Validation
Side
- Must be exactly
"BUY"or"SELL"(case-sensitive)
OrderType
- Must be exactly
"FOK","FAK","GTC", or"GTD"(case-sensitive)
Price
- Must be a number between 0 and 1 (exclusive of 0, inclusive of 1)
- Required for limit orders (GTC/GTD)
- Optional for market orders (FOK/FAK)
Size
- Must be a positive number
- Required for limit orders (GTC/GTD)
- Optional for market orders (FOK/FAK)
- The market details will contain a minimum size. Generally, the minimum size is 5.
Amount
- Must be provided as a string representation of a bigint
- For USDC on Polygon (6 decimals), 1 USDC =
"1000000" - Required for market orders unless both price and size are provided
Slippage
- Must be between 0 and 100 (for Polymarket orders)
- Represented in basis points (100 = 1%)
FeeRateBps
- The fee rate is currently 0 for Polymarket.
- Must be a non-negative number
- Represented in basis points
TickSize
- Common values:
"0.01","0.001","0.0001" - Can be any string value
NegRisk
- Must be the string
"true"or"false"(not boolean)
SwapDirection
- Must be
"exact-amount-in"or"exact-amount-out" - Defaults to
"exact-amount-in"if not provided
Error Responses
The API may return the following error responses:400 Bad Request: Missing required field or invalid parameter401 Unauthorized: Invalid or missing API key500 Internal Server Error: Server error
Workflow Endpoints
All workflow endpoints are located under/api/workflows/polymarket/ and provide supporting functionality for Polymarket operations.
1. Create or Fetch Polymarket User
Creates a new Polymarket user or fetches an existing one based on the provided EVM address. Endpoint:POST /api/workflows/polymarket/createOrFetchPolymarketUser
Request Body:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
evmEoa | Address | Yes | EVM address (wallet address) | 0x1234...5678 |
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
userCredentials | object | Yes | User credentials object containing wallet information | See UserCredentials object below |
userCredentials.evmEoa | Address | Yes | The “home” EOA address (wallet address) | "0x1234567890123456789012345678901234567890" |
userCredentials.proxyWallet | Address | No | Proxy wallet address (if available) | "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd" |
userCredentials.proxyWalletStatus | string | No | Status of the proxy wallet (maps to ProxyWalletStatus enum) | "ready", "deploying", "permissioning", "failed-deploy", "failed-permission", "not-created" |
newUser | boolean | Yes | Whether this is a newly created user (true) or existing user (false) | true |
userId | string | Yes | Polymarket user ID | "user_123" |
proxyWalletStatus field uses ProxyWalletStatus enum values:
"ready": Proxy wallet is ready to use"deploying": Proxy wallet is being deployed"permissioning": Proxy wallet permissions are being set up"failed-deploy": Proxy wallet deployment failed"failed-permission": Proxy wallet permission setup failed"not-created": Proxy wallet has not been created
- Use the returned
userIdin/api/getActionrequests - Use the returned
userCredentials.proxyWalletas therecipientaddress in/api/getActionrequests (if available) - The
newUserfield indicates whether a new user was created or an existing user was fetched - Check
proxyWalletStatusto determine if the proxy wallet is ready for use - This endpoint should be called before placing orders
2. Search Markets
Searches for Polymarket markets by query string. Endpoint:GET /api/workflows/polymarket/search
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
q | string | No | Search query string | "american election" |
tagIds | number | No | Array of event tags ids (categories) to filter by. Retrieve ids from the getTags endpoint | |
page | number | No | Page number for pagination | 1 |
limit | number | No | Limit results per type (tags, events, profiles) | 1 |
activeOnly | boolean | No | Only return markets currently accepting orders | true |
View full response structure
View full response structure
| Field | Type | Description |
|---|---|---|
events | array | Array of event objects, each containing markets and tags |
pagination | object | Pagination information |
pagination.hasMore | boolean | Whether there are more results available |
pagination.totalResults | number | Total number of results |
- The
qparameter should be URL-encoded - Event tags are categories used to filter Polymarket markets (e.g., “nfl”, “sports”, “politics”)
- Multiple event tags will search on events with all tags vs. returning events that match any tag
- Only markets with
acceptingOrders: truecan be used for orders - The
clobTokenIdsfield contains a JSON array of token IDs (use index 0 for “Yes”, index 1 for “No”) - The response includes pagination information in the
paginationobject
3. Get Markets
Retrieves market information by CLOB token IDs or slugs. Endpoint:GET /api/workflows/polymarket/getMarkets
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
clobTokenIds | string[] | No | Array of CLOB token IDs (can be comma-separated or JSON array) | "tokenId1,tokenId2" or ["tokenId1","tokenId2"] |
slug | string | No | Array of market slugs (can be comma-separated or JSON array) | "slug1,slug2" or ["slug1","slug2"] |
tagId | number | No | Tag Id from the getTags endpoint | 450 |
clobTokenIds or slugs must be provided.
Response:
The response follows the standardized response format with events, tags, and pagination information.
View full response structure
View full response structure
| Field | Type | Description |
|---|---|---|
events | array | Array of event objects, each containing markets and tags |
pagination | object | Pagination information |
pagination.hasMore | boolean | Whether there are more results available |
pagination.totalResults | number | Total number of results |
- Token IDs can be provided as comma-separated strings or as a JSON array
- Multiple parameters can be passed by repeating the query parameter or using comma separation
- The response follows the standardized response format with
eventsandpaginationfields - Only markets with
acceptingOrders: truecan be used for orders - The
clobTokenIdsfield contains a JSON array of token IDs (use index 0 for “Yes”, index 1 for “No”)
4. Get Price
Retrieves the current market price for a specific token and side. Endpoint:GET /api/workflows/polymarket/getPrice
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
clobTokenId | string | Yes | CLOB token ID | "80746058984644290629624903019922696017323803605256698757445938534814122585786" |
side | string | Yes | Order side: "BUY" or "SELL" (case-insensitive) | "BUY" |
- The
sideparameter is case-insensitive (will be converted to uppercase) - Returns the best available price for the specified side
5. Get Trending Markets
Retrieves trending markets on Polymarket. Endpoint:GET /api/workflows/polymarket/getTrendingMarkets
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
limit | number | No | Maximum number of results to return | 20 |
page | number | No | Page number for pagination | 2 |
View full response structure
View full response structure
| Field | Type | Description |
|---|---|---|
events | array | Array of event objects, each containing markets and tags |
pagination | object | Pagination information |
pagination.hasMore | boolean | Whether there are more results available |
pagination.totalResults | number | Total number of results |
- Returns active markets sorted by 24hr volume. Markets must have minimum $150K of volume
- The
limitparameter controls how many trending markets are returned - The response follows the standardized response format with
eventsandpaginationfields - Only markets with
acceptingOrders: truecan be used for orders - The
clobTokenIdsfield contains a JSON array of token IDs (use index 0 for “Yes”, index 1 for “No”)
6. Get Trades
Retrieves trade history for a specific user. Endpoint:GET /api/workflows/polymarket/getTrades
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
userId | string | Yes | User EVM EOA Address | 0x123..789 |
proxyWallet | string | No | Polymarket proxy wallet address | 0x456..789 |
limit | number | No | Maximum number of results to return | 50 |
offset | number | No | Number of results to skip (for pagination) | 0 |
- Results are paginated using
limitandoffset - Use
offsetto fetch subsequent pages
7. Get Activity
Retrieves activity history for a specific user. Endpoint:GET /api/workflows/polymarket/getActivity
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
userId | string | Yes | User EVM EOA Address | 0x123..789 |
proxyWallet | string | No | Polymarket proxy wallet address | 0x456..789 |
limit | number | No | Maximum number of results to return | 50 |
offset | number | No | Number of results to skip (for pagination) | 0 |
- Returns a comprehensive activity feed including orders, trades, and other actions
- Results are paginated using
limitandoffset
8. Get Current Positions
Retrieves current open positions for a specific user. Endpoint:GET /api/workflows/polymarket/getCurrentPositions
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
userId | string | Yes | User EVM EOA Address | 0x123..789 |
proxyWallet | string | No | Polymarket proxy wallet address | 0x456..789 |
redeemable | boolean | No | Filter for redeemable positions only | true |
mergable | boolean | No | Filter for mergable positions only | true |
limit | number | No | Maximum number of results to return | 50 |
offset | number | No | Number of results to skip (for pagination) | 0 |
redeemableandmergableare boolean query parameters (usetrueorfalseas strings)- Results are paginated using
limitandoffset
9. Get Closed Positions
Retrieves closed positions (resolved markets) for a specific user. Endpoint:GET /api/workflows/polymarket/getClosedPositions
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
userId | string | Yes | User EVM EOA Address | 0x123..789 |
proxyWallet | string | No | Polymarket proxy wallet address | 0x456..789 |
limit | number | No | Maximum number of results to return | 50 |
offset | number | No | Number of results to skip (for pagination) | 0 |
- Returns positions from markets that have been resolved
- Results are paginated using
limitandoffset
10. Get PnL
Retrieves profit and loss information for a specific user. Endpoint:GET /api/workflows/polymarket/getPnL
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
userId | string | Yes | User EVM EOA Address | 0x123..789 |
proxyWallet | string | No | Polymarket proxy wallet address | 0x456..789 |
- Returns aggregate PnL across all positions
realizedPnLincludes profits/losses from closed positionsunrealizedPnLincludes profits/losses from open positions based on current prices
11. Cancel Order
Cancels one or more open orders. Endpoint:POST /api/workflows/polymarket/cancelOrder
Request Body:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
evmEoa | Address | Yes | EVM address (wallet address) | 0x1234...5678 |
proxyWallet | Address | No | Proxy wallet address (if different from evmEoa) | 0xabcd...efgh |
orderIDs | string[] | Yes | Array of order IDs to cancel | ["order_id_1", "order_id_2"] |
orderIDsmust be a non-empty arrayproxyWalletis optional but recommended if you have a proxy wallet associated with the user- Only open orders can be cancelled
12. Get Workflow Status
Retrieves the status of a workflow transaction. Endpoint:GET /api/workflows/getStatus
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
txId | string | Yes | Transaction ID from /getAction request | "0x30e7dc0566713417a7bc136ad3bb4f8525e005e2e024ef696b7b88f497e394e8" |
View full response structure
View full response structure
| Field | Type | Description |
|---|---|---|
txId | string | Transaction ID from workflow |
workflow | object | Workflow information object |
workflow.data | object | Workflow data containing order request and response |
workflow.data.userId | string | User ID from create or fetch user response |
workflow.data.orderRequest | object | Original order request parameters |
workflow.data.orderResponse | object | Order response from Polymarket (if order was placed) |
workflow.name | string | Workflow name (e.g., "polymarket") |
workflow.operation | string | Operation type (e.g., "placeOrder") |
workflow.status | string | Workflow status: "pending", "success", or "failed" |
workflow.timestamp | number | Timestamp of the workflow operation |
- Use this endpoint to check the status of a workflow transaction after submission
- The
txIdis typically returned from the/api/getActionendpoint - Status values:
pending,success,failed
13. Get Tags
Retrieves the status of a workflow transaction. Endpoint:GET /api/workflows/getTags
Query Parameters:
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
limit | number | No | Number of tags to return | 5 |
offset | number | No | Zero-based index of first index to return | 5 |
slug | string | No | Transaction ID from /getAction request | "nfl" |
View full response structure
View full response structure
| Field | Type | Description |
|---|---|---|
id | string | Tag ID. Can search markets based on tag ID. |
label | string | Label for tag |
slug | string | Slug for tag. Can search tags based on slug. |
publishedAt | string | Tag publish date |
createdAt | string | Tag creation date |
updatedAt | string | Tag updated date |
General Notes
- Chain Support: Polymarket operates on Polygon. The destination chain should always be Polygon (137).
- Token: Polymarket settles trades in USDC.e on Polygon. The destination token should always be the USDC.e address:
0x2791bca1f2de4661ed88a30c99a7a9449aa84174 - Amount Format: Amounts are provided as string representations of bigint values. For USDC (6 decimals), multiply the USD amount by 1,000,000
- Order Types:
- FOK (Fill or Kill): Order must fill completely or be cancelled
- FAK (Fill and Kill): Order fills as much as possible, then cancels remainder
- GTC (Good til Cancelled): Limit order that remains active until filled or cancelled
- GTD (Good til Date): Limit order that expires at a specific time
- Response Parsing: The response contains bigint values that need to be deserialized. Use a bigint deserializer when parsing JSON responses.
- Error Handling: All endpoints may return standard HTTP error codes (400, 401, 500) with error messages in JSON format
- Pagination: Endpoints that support pagination use
limitandoffsetquery parameters - URL Encoding: When constructing URLs manually, ensure proper URL encoding for query parameters