A real-time trading terminal for Polymarket prediction markets with live order book data, WebSocket connectivity, and advanced search functionality.
- 🔄 Real-time WebSocket Connection - Live order book updates from Polymarket CLOB
- 🔍 Advanced Search - Search markets with intelligent debouncing and duplicate prevention
- 📊 Live Order Book - Real-time bid/ask data with price changes
- 🎯 Market Selection - Browse and select from available prediction markets
- ⚡ Terminal-style UI - Retro terminal interface with green-on-black aesthetics
- 📈 Activity Feed - Real-time trading activity and price updates
- Node.js 18+
- npm, yarn, pnpm, or bun
- Clone the repository:
git clone <repository-url>
cd polymarket-live-order-book- Install dependencies:
npm install
# or
yarn install
# or
pnpm install
# or
bun install- Set up environment variables (optional):
cp .env.example .env.localAdd your Polymarket API credentials to .env.local for live WebSocket data:
POLYMARKET_API_SECRET=your_api_secret
POLYMARKET_PASSPHRASE=your_passphrase
NEXT_PUBLIC_POLYMARKET_API_KEY=your_api_key
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the application. If port 3000 is in use, it will automatically use the next available port (e.g., 3001).
- Search Markets: Type in the search box to filter markets (500ms debounce)
- Select Market: Click on any market to view its order book
- Switch Outcomes: Press 'Q' to toggle between Yes/No outcomes
- Clear Search: Click the Clear button to reset search
- Real-time Search: Search triggers automatically 500ms after you stop typing
- Duplicate Prevention: Same query won't trigger multiple API calls
- Manual Search: Press Enter or click Search button for immediate results
- Multi-field Search: Searches through question, description, and market slug
When API credentials are provided:
- Live Updates: Real-time order book changes
- Price Alerts: Automatic notifications for price movements
- Trade Activity: Live trade execution updates
- Connection Status: Visual indicators for WebSocket connectivity
src/
├── app/ # Next.js app router
├── components/
│ └── PolymarketTerminal/ # Main terminal components
│ ├── SearchPanel.tsx # Market search with debouncing
│ ├── MarketsList.tsx # Market list display
│ ├── OrderBookPanel.tsx # Order book visualization
│ ├── StatusBar.tsx # Connection status
│ └── InfoBar.tsx # Activity feed
├── lib/
│ └── polymarket/ # Polymarket API integration
│ ├── api.ts # Market data fetching
│ ├── types.ts # TypeScript definitions
│ └── websocket-client.ts # WebSocket client
The application uses the Polymarket CLOB API for:
- Market data fetching via
/api/polymarket/marketsendpoint - Real-time WebSocket connections for order book updates
- Search functionality with client-side filtering
- Framework: Next.js 15 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- Real-time: WebSocket connections
- State Management: React hooks and context
The easiest way to deploy is using Vercel Platform:
- Connect your repository to Vercel
- Set environment variables in Vercel dashboard
- Deploy automatically
npm run build
npm start- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is for educational and demonstration purposes. Please respect Polymarket's terms of service when using their API.