manifold_betting_api_template
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
A simple API for placing bets on Manifold Markets via URL pings. Allows you to bet using market slugs instead of market IDs.
- Set the
MANIFOLD_API_KEY
environment variable with your Manifold API key - Get your API key from your Manifold profile page
Get market information by slug (JSON format).
Example:
GET /market/will-the-road-to-housing-act-become
Response:
{ "id": "NcISOAqL6n", "slug": "will-the-road-to-housing-act-become", "question": "Will the ROAD to Housing Act become law in 2025?", "probability": 0.20069534805930825, "isResolved": false, "resolution": null, "outcomeType": "BINARY", "url": "https://manifold.markets/bens/will-the-road-to-housing-act-become" }
Get market information by slug (HTML format for AI crawlers and web browsers).
Example:
GET /info/will-the-road-to-housing-act-become
Response: Clean HTML page with:
- Market question as heading
- Current probability as percentage
- Market status (open/resolved)
- Trading instructions
- Market details and links
Perfect for AI agents that prefer to crawl HTML instead of parsing JSON.
Place a bet on a market.
Parameters:
slug
- Market slug (from the URL path)outcome
- YES or NOamount
- Amount in mana to bet (positive number)
Example:
GET /bet/will-the-road-to-housing-act-become/YES/10
Response:
{ "success": true, "bet": { "id": "bet_id_here", "amount": 10, "outcome": "YES", "shares": 12.34, "probBefore": 0.20, "probAfter": 0.21, "fees": { "platformFee": 0.1, "liquidityFee": 0, "creatorFee": 0.05 } }, "market": { "id": "NcISOAqL6n", "slug": "will-the-road-to-housing-act-become", "question": "Will the ROAD to Housing Act become law in 2025?", "url": "https://manifold.markets/bens/will-the-road-to-housing-act-become" } }
- ✅ Bet using market slugs instead of IDs
- ✅ Simple GET request interface
- ✅ Supports binary markets only
- ✅ Returns current probability for markets
- ✅ HTML endpoint for AI crawlers
- ✅ Web interface for testing
- ✅ Error handling and validation
- ✅ CORS enabled for web usage
The root URL provides a web interface for testing the API endpoints.
You can also test the HTML crawler endpoint directly:
https://your-api-url/info/will-the-road-to-housing-act-become
The API returns appropriate HTTP status codes and error messages:
400
- Invalid parameters (bad outcome, negative amount, etc.)404
- Market not found500
- Server error (missing API key, network issues, etc.)
The /info/{slug}
endpoint is specifically designed for AI agents that prefer HTML over JSON:
- Clean, semantic HTML structure
- Probability displayed as percentage
- Market status clearly indicated
- Trading instructions included
- Meta tags for description
- No complex JavaScript or styling
- Only supports binary (YES/NO) markets
- Requires MANIFOLD_API_KEY environment variable
- No support for limit orders (uses market orders only)
Get started with a template: