• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
dcm31

dcm31

manifold_betting_api_template

Public
Like
2
manifold_betting_api_template
Home
Code
2
backend
1
README.md
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
Code
/
Search
index.ts
https://dcm31--0198e41f223777529bb33c5fd294e4ca.web.val.run
README.md

Manifold Betting API

A simple API for placing bets on Manifold Markets via URL pings. Allows you to bet using market slugs instead of market IDs.

Setup

  1. Set the MANIFOLD_API_KEY environment variable with your Manifold API key
  2. Get your API key from your Manifold profile page

Endpoints

GET /market/{slug}

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 /info/{slug}

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.

GET /bet/{slug}/{outcome}/{amount}

Place a bet on a market.

Parameters:

  • slug - Market slug (from the URL path)
  • outcome - YES or NO
  • amount - 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" } }

Features

  • ✅ 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

Testing

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

Error Handling

The API returns appropriate HTTP status codes and error messages:

  • 400 - Invalid parameters (bad outcome, negative amount, etc.)
  • 404 - Market not found
  • 500 - Server error (missing API key, network issues, etc.)

AI Crawler Usage

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

Limitations

  • Only supports binary (YES/NO) markets
  • Requires MANIFOLD_API_KEY environment variable
  • No support for limit orders (uses market orders only)
HTTP
  • index.ts
    dcm31--01…ca.web.val.run
Code
backendREADME.md
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.