API Documentation
Submit your Polymarket trades to Bag so followers can copy your positions.
Base URL
https://api.bag.trading/apiQuick 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
| Endpoint | Limit | Window |
|---|---|---|
POST /trades | 100 requests | per minute |
GET /traders | 60 requests | per minute |
| All other endpoints | 30 requests | per minute |
Rate limit headers are included in all responses: X-RateLimit-Remaining
Error Codes
400Bad RequestInvalid request body or missing required fields.
401UnauthorizedMissing or invalid API key.
403ForbiddenAPI key lacks required permissions for this action.
404Not FoundRequested resource does not exist.
429Too Many RequestsRate limit exceeded. Wait and retry.
500Internal Server ErrorSomething went wrong on our end. Please try again.