dr-manhattan is an open-source unified API for prediction markets, designed as the CCXT equivalent for the prediction market ecosystem. It provides a simple, scalable interface for developers to programmatically interact with multiple prediction market platforms including Polymarket, Kalshi, Opinion, Limitless, and Predict.fun. The core value lies in its exchange-agnostic approach: developers write code once using a consistent interface and deploy it across any supported exchange without modifications. This tool is built for software engineers, quantitative traders, and prediction market enthusiasts who need to build applications that fetch market data, execute trades, or analyze market trends across fragmented platforms. By abstracting away the underlying differences between each exchange’s API, dr-manhattan significantly reduces integration effort and maintenance overhead, allowing users to focus on crafting their trading strategies and analytical models rather than dealing with platform-specific quirks.
Prediction markets have grown rapidly, but each platform exposes its own unique API with different endpoints, data formats, authentication methods, and rate limits. This fragmentation creates a major pain point for developers who want to build cross-platform applications: they must write and maintain separate adapters for each exchange, duplicating logic and increasing the risk of errors. dr-manhattan solves this problem by providing a unified abstraction layer that normalizes all exchanges into a single, predictable interface. Instead of learning multiple APIs, developers learn one. Instead of rewriting code for each new platform, they simply add a new exchange implementation. This matters because it drastically reduces time to market for prediction market tools and enables developers to seamlessly scale their applications to include new markets as they emerge, without incurring additional technical debt.
The Unified Interface is the cornerstone of dr-manhattan. It exposes a consistent set of methods—such as fetch_markets, fetch_order_book, create_order, and cancel_order—across all supported exchanges. Developers initialize an exchange object (e.g., dr_manhattan.Polymarket({...})) and then call these methods identically regardless of whether they’re working with Polymarket, Kalshi, or Opinion. Under the hood, dr-manhattan handles the conversion between the unified interface and each exchange’s proprietary API. This design is useful because it allows developers to write portable code that can be tested on one exchange and deployed on another with zero changes to the core logic. Furthermore, if a new exchange appears, the same codebase can be extended to support it by implementing the abstract methods, preserving the investment in existing application code.
admin
Real-time data is critical for prediction market trading, and dr-manhattan provides built-in WebSocket support for streaming live market data. This feature enables developers to receive continuous updates on order book changes, trade executions, and market price movements without constant polling. The WebSocket connections are automatically managed by the library, ensuring reliable, low-latency data feeds. For applications that require up-to-the-second information—such as high-frequency trading bots or real-time dashboard displays—this eliminates the overhead and complexity of manually implementing WebSocket handlers. dr-manhattan’s WebSocket implementation is integrated directly into the unified interface, so developers can subscribe to streams using the same exchange-agnostic patterns they use for REST calls. This seamless transition between request-response and streaming modes empowers developers to build responsive, event-driven systems that react instantly to market changes.
dr-manhattan includes a Strategy Framework that provides a base class for building trading strategies. This framework handles common infrastructure tasks such as order tracking, position management, and event logging, so developers can focus on strategy logic. It also integrates with the Order Management system, which offers standardized methods to create, cancel, and track orders across all exchanges. Error handling is unified, meaning that regardless of which exchange returns an error, the developer sees a consistent error format. The combination of these features allows users to rapidly prototype and backtest strategies, then deploy them to live markets with minimal friction. Additionally, the library is fully type-safe, with extensive type hints that catch errors at compile time and provide superior autocomplete in modern IDEs, further reducing bugs and development time.
Using dr-manhattan begins with installation via the uv package manager: uv pip install -e git+https://github.com/guzus/dr-manhattan. Once installed, developers import the library and initialize an exchange object by passing configuration options such as API keys and timeouts. They can then call methods like fetch_markets() to retrieve all available markets from that exchange. The library’s clean architecture makes it easy to add support for new exchanges: one simply implements the abstract methods defined in the base exchange class. The entire codebase is open source under the MIT license, hosted on GitHub, with a community-supported ecosystem including a Telegram group and a Twitter account. This design encourages contributions and ensures that the library evolves to meet the needs of the prediction market community.
Developers leverage dr-manhattan to build trading bots that automatically execute strategies across multiple prediction markets. For example, a quant trader might use the framework to implement a sentiment-based strategy that monitors Polymarket’s election markets and Kalshi’s economic indicators, executing trades when conditions align. Market researchers can use the unified API to aggregate data from all exchanges for analysis, constructing dashboards that show price discrepancies or liquidity trends. Another use case is arbitrage: by fetching order books from several platforms simultaneously, a bot can identify and exploit price differences before they disappear. The outcome is a significant acceleration in development speed, reduced code complexity, and the ability to adapt quickly to new market opportunities. These capabilities empower users to focus on strategy and analysis rather than API integration.
dr-manhattan is designed for developers, quantitative analysts, and cryptocurrency or prediction market enthusiasts who need a robust, flexible API layer. Target users include individual traders building personal bots, startups creating prediction market applications, and researchers analyzing market behavior. The library supports Polymarket, Kalshi, Opinion, Limitless, and Predict.fun, with the potential to add more through its extensible design. It is completely open source under the MIT license, with no pricing or subscription required—developers can use it freely and even contribute to its development. In summary, dr-manhattan delivers on its promise of being the "CCXT for prediction markets": a simple, scalable unified API that dramatically simplifies cross-platform trading and data access, enabling the prediction market community to build richer, more powerful applications with less effort.
dr-manhattan is built for software developers, quantitative analysts, and prediction market enthusiasts who need a robust, unified API layer. Target roles include full-stack developers building trading dashboards, quant traders automating strategies across platforms, data scientists aggregating market data for predictive models, and product teams creating consumer-facing prediction market apps. It is also ideal for open-source contributors interested in expanding exchange support. The library is open source and free, making it accessible to individual developers and startups alike.