Automate your trading with API keys
Build trading bots, automate strategies, and access market data programmatically. Generate an API key in your account settings to get started.
Go to Settings → API and create a new key
The API secret is shown only once at creation. Store it securely.
Sign every request with HMAC-SHA256 using the required headers
Place orders, read market data, and manage positions via the API
Two-factor authentication (2FA) may be required to generate API keys, depending on platform settings. Enable 2FA in Security settings before generating keys.
All trading API requests require authentication using your API key and an HMAC-SHA256 signature. Market data endpoints (GET /api/markets/*) are public and do not require authentication.
First, hash your API secret with SHA-256. Then compute the HMAC-SHA256 of the payload timestamp + method + path + body using the hashed secret as the key.
secret_hash = SHA-256(api_secret)signature = HMAC-SHA256(timestamp + method + path + body, secret_hash)Important: The path must include the full pathname and query string (e.g. /api/trading/orders?orderId=abc).
Timestamps must be within a 5-minute window of the server time.
For GET requests with no body, use an empty string for the body portion.
const crypto = require('crypto');
// Step 1: Hash your API secret (do this once and cache the result)
function hashSecret(apiSecret) {
return crypto.createHash('sha256').update(apiSecret).digest('hex');
}
// Step 2: Sign each request using the hashed secret
function signRequest(secretHash, method, path, body, timestamp) {
const payload = `${timestamp}${method}${path}${body}`;
return crypto
.createHmac('sha256', secretHash)
.update(payload)
.digest('hex');
}
// Setup: Hash your secret once
const API_KEY = 'pbp_user_your_api_key_here';
const API_SECRET = 'pbpus_your_api_secret_here';
const SECRET_HASH = hashSecret(API_SECRET);
// Example: Place an order
const timestamp = Math.floor(Date.now() / 1000).toString();
const body = JSON.stringify({
marketId: 'market-uuid',
outcome: 'YES',
side: 'buy',
price: 65,
amount: 1000,
orderType: 'limit',
});
// Note: 'path' must include the full path + query string
// e.g. '/api/trading/orders' for POST,
// '/api/trading/orders?orderId=abc' for DELETE
const path = '/api/trading/orders';
const signature = signRequest(SECRET_HASH, 'POST', path, body, timestamp);
const response = await fetch('https://predictbet.pro/api/trading/orders', {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'X-API-Signature': signature,
'X-Timestamp': timestamp,
'Content-Type': 'application/json',
},
body,
});
const result = await response.json();
console.log(result);The Trading API enforces guardrails to maintain fair and orderly markets. These apply to all API-originated orders.
Orders must remain on the book for at least 5 seconds before they can be cancelled. Attempting to cancel earlier returns a 400 error with the remaining seconds. IOC (Immediate-or-Cancel) and FOK (Fill-or-Kill) orders are exempt.
No single user can hold more than 25%of any market's total open interest. Orders that would exceed this threshold are rejected.
The platform monitors your ratio of orders placed to trades executed. An OTR exceeding 50:1 within a rolling window may trigger rate throttling or manual review. This deters spoofing and layering.
Keys are created with default scopes: trading:read, trading:write, market:read. You can restrict scopes per key in Settings.
Optionally restrict API key usage to specific IP addresses. Configure allowed IPs per key in Settings → API.
https://predictbet.proRate limit headers are included in every response:X-RateLimit-RemainingX-RateLimit-Reset
Volume-based tier discounts apply on top of the base rate. See fee schedule for details.
400Bad Request401Unauthorized403Forbidden / Suspended404Not Found429Rate Limited500Server Errorpbp_user_pbpus_Maximum 5 active keys per account. Keys can be rotated with a configurable grace period.