Paid partnership with Polymarket.
Sponsored by Polymarket US
18+ Only. Restrictions and eligibility requirements apply. Not available in all jurisdictions. Trading is risky. 100% loss can occur. See https://polymarketexchange.com/files/legal/Polymarket%20US%20Rulebook%20(2026.09.30).pdf for more information. The Polymarket US App serves as an independent software provider and affiliate of Polymarket US and Polymarket Clearing, the CFTC-regulated exchange and clearing organization.
Polymarket US has a real retail API: developer keys, signed REST, live WebSockets and an official SDK. Here's how to connect a bot to it, build it with AI, and fund it with a hard ceiling on what it can lose.
New to the overall setup? Read the prediction market bot overview first.
Step 1: connect your Polymarket US account
Open an account in the Polymarket US app. New users get a $25 trading bonus when they deposit $10 with code PMP. The code has to go in at sign-up; it can't be added later. Finish KYC, because API keys only unlock after it.
Create your API keys. Once you're verified, go to the developer page at polymarket.us/developer and create a key. You get a Key ID and a Secret Key (base64). Store the secret like a password: a password manager or a file outside your code folder, read by an environment variable. Never paste it into a chat or a repo.
How signing works, so the code the AI writes makes sense to you:
| Header | What goes in it |
|---|---|
X-PM-Access-Key | Your Key ID |
X-PM-Timestamp | The current time in milliseconds |
X-PM-Signature | Base64 Ed25519 signature over timestamp + METHOD + path |
The pieces you'll use:
- REST base:
https://api.polymarket.us - Market data stream:
wss://api.polymarket.us/v1/ws/markets - Your orders, positions and balance stream:
wss://api.polymarket.us/v1/ws/private - Official TypeScript SDK:
npm install polymarket-us - Docs:
docs.polymarket.us(there's also a plain-text index atdocs.polymarket.us/llms.txt, which is handy to hand to an AI)
Contracts trade in one-cent ticks from $0.01 to $0.99 and pay $1. There's a weekly maintenance window on Thursdays, 6:00 to 8:00 AM ET. Build the bot to pause through it.
Step 2: build the bot with AI
Paste this into Claude or ChatGPT, then fill in the market and your rule.
You are a senior engineer helping me build a small, safe trading bot for Polymarket US
(the US exchange; never Polymarket.com, and no VPNs or proxies).
API facts:
- REST base: https://api.polymarket.us
- Docs: https://docs.polymarket.us (index: https://docs.polymarket.us/llms.txt)
- Official TypeScript SDK: npm package "polymarket-us". Prefer it where it covers a call.
- Auth headers: X-PM-Access-Key (Key ID), X-PM-Timestamp (ms),
X-PM-Signature = base64 Ed25519 signature over timestamp + METHOD + path.
The Secret Key is base64. Read PMUS_KEY_ID and PMUS_SECRET_PATH from environment
variables. Never print or log the secret. Never ask me to paste it here.
- WebSockets: wss://api.polymarket.us/v1/ws/markets (market data) and
wss://api.polymarket.us/v1/ws/private (orders, positions, balance), both signed.
- Weekly maintenance: Thursday 6:00-8:00 AM ET. Pause, don't error.
Market: [e.g. Bitcoin 15-minute up/down windows].
Rule: [YOUR RULE IN ONE OR TWO SENTENCES].
Build:
1. Node 24, TypeScript. No axios.
2. ingest.ts: subscribe to the market stream, keep a fresh order book,
and refuse to act on a book older than [N] seconds.
3. decide.ts: apply my rule, return side, limit price and size.
4. execute.ts: place limit orders, track them on the private stream,
cancel anything still resting at window close.
5. Rails in config.json: max dollars per position, max open positions,
daily loss stop, and a KILL file that halts all trading.
6. DRY_RUN=true by default. Log every decision and every skip, with a reason, to CSV.
7. Reconnect with backoff. Stale data = no trade.
8. If you are unsure of an endpoint or field, say so and tell me which page of
docs.polymarket.us to check. Do not invent endpoints.
List the files first, then write them one at a time, then give me a dry-run test plan.
Before arming it, have the AI explain execute.ts back to you line by line and write tests for every rail. Fees decide whether a small edge survives; we ran the numbers on a common idea in the Polymarket US 5-minute fee math.
Step 3: fund it and fence it
Deposit in the Polymarket US app. Then put the fence in code, because the API key can trade whatever the account holds:
- A max per position and a max number of open positions.
- A daily loss stop that halts the bot until tomorrow.
- A lifetime stop and a kill switch: one file or flag that stops everything.
- Keep the account balance to what the bot may lose. Leave the rest off the exchange.
Then dry-run against live prices, and arm at minimum size only once the log reads like your own judgment.
Step 4: the data to build on
The boards below are information, not trade calls. They show what the market priced and how each window settled:
- Polymarket US 5-minute Bitcoin board: every 5-minute window and how it settled.
- Polymarket US 15-minute Bitcoin board.
- BTC 15-minute venue pairs: the same 15 minutes priced on Kalshi and Polymarket US, side by side.
Want to see how a full bot stack is wired? The Bot Playbook is the build sheet for our three-machine setup: a server that ingests prices, an engine that does the math, and a bot that places only what the math recommends. Get it with Pro →
Other venues: Kalshi · Novig · ProphetX
18+ Only. Restrictions and eligibility requirements apply. Not available in all jurisdictions. Trading is risky. 100% loss can occur. See https://polymarketexchange.com/files/legal/Polymarket%20US%20Rulebook%20(2026.09.30).pdf for more information. The Polymarket US App serves as an independent software provider and affiliate of Polymarket US and Polymarket Clearing, the CFTC-regulated exchange and clearing organization.
