The ccxt for prediction markets. A unified API for accessing prediction market data across multiple exchanges.
Different prediction market platforms have different APIs, data formats, and conventions. pmxt provides a single, consistent interface to work with all of them.
Get the current price for any market in seconds:
import pmxt from 'pmxtjs';
async function main() {
const poly = new pmxt.Polymarket();
const [market] = await poly.searchMarkets('Trump');
console.log(`${market.title} - ${market.outcomes[0].label}: ${market.outcomes[0].price * 100}%`);
}
main();npm install pmxtjspmxt is currently CommonJS-only. If you're using "type": "module" in your package.json, use the default import:
import pmxt from 'pmxtjs';
const poly = new pmxt.Polymarket();Named exports like import { Polymarket } from 'pmxtjs' will not work in ESM projects. See the API Reference for more details.
- Polymarket
- Kalshi
pmxt supports trading functionality (placing and cancelling orders).
To trade, you must provide your private credentials.
- Polymarket: Requires your Polygon Private Key. View Setup Guide
- Kalshi: Requires API Key & Private Key.
import pmxt from 'pmxtjs';
const exchange = new pmxt.Polymarket({
privateKey: process.env.POLYMARKET_PRIVATE_KEY
});
// Check Balance
const balance = await exchange.fetchBalance();
console.log('Balance:', balance);
// Place an Order
const order = await exchange.createOrder({
marketId: 'market-123',
outcomeId: 'token-id-456',
side: 'buy',
type: 'limit',
price: 0.50,
amount: 100
});
console.log('Order:', order);See the API Reference for detailed documentation and more examples.
Check out the examples directory for more use cases:
- Market search
- Order book data
- Historical prices
- Event price tracking
- Recent trades