API Documentation

Submit your Polymarket trades to Bag so followers can copy your positions.

Base URL

https://api.bag.trading/api

Quick Start

Step 1

Get your API key

Sign up, verify your wallet, then generate an API key from your dashboard.

Step 2

Submit a trade

bash
curl -X POST https://api.bag.trading/api/trades \ -H "Content-Type: application/json" \ -H "X-API-Key: your_api_key" \ -d '{ "token_id": "71321045863...", "market_id": "0x123abc...", "outcome": "YES", "position_type": "buy", "amount": 100, "price": 0.65, "timestamp": "2024-01-15T10:30:00Z" }'

How it works

Your API key is tied to your Bag account. When you submit a trade, we automatically associate it with your profile and verify it came from you.

Include your key in the X-API-Key header with every request. No additional authentication steps required.

bash
curl -H "X-API-Key: bag_k_abc123..."

Rate Limits

EndpointLimitWindow
POST /trades100 requestsper minute
GET /traders60 requestsper minute
All other endpoints30 requestsper minute

Rate limit headers are included in all responses: X-RateLimit-Remaining

Error Codes

400Bad Request

Invalid request body or missing required fields.

401Unauthorized

Missing or invalid API key.

403Forbidden

API key lacks required permissions for this action.

404Not Found

Requested resource does not exist.

429Too Many Requests

Rate limit exceeded. Wait and retry.

500Internal Server Error

Something went wrong on our end. Please try again.

View full endpoint reference →