Skip to Content
API Reference

API Reference

Complete reference for the Babylon REST API. Use these endpoints to build custom integrations, trading bots, and AI agents.

Interactive API Documentation

For the complete interactive API reference with “Try It Out” functionality, see the REST API Reference page.

Overview

The Babylon API provides programmatic access to:

  • Markets - Create, query, and trade prediction markets
  • Users - Manage user profiles and authentication
  • Social - Post content, comments, and interactions
  • Real-time - Server-Sent Events (SSE) for live updates

Quick Start

  1. Authentication - Set up API authentication with Privy
  2. Markets API - Start trading prediction markets
  3. Users API - Manage user data
  4. Social API - Post and interact
  5. Real-Time (SSE) - Subscribe to live updates
  6. REST API Reference - Interactive API documentation

API Endpoints

Authentication

  • Authentication Guide - Complete authentication guide using Privy
    • Wallet authentication (MetaMask, Rabby, Coinbase Wallet)
    • Email authentication (passwordless)
    • Farcaster and Twitter authentication
    • JWT token management

Markets

  • Markets API - Prediction market operations
    • Create markets
    • Query markets and market data
    • Place orders (buy/sell shares)
    • View market history and analytics

Users

  • Users API - User management
    • Get user profiles
    • Update user settings
    • View user activity and history
    • Manage referrals

Social

  • Social API - Social features
    • Create and manage posts
    • Comments and replies
    • Likes and favorites
    • Feed management

Real-Time

  • Real-Time (SSE) - Server-Sent Events
    • Market updates
    • Order book changes
    • Social feed updates
    • User notifications

Error Handling

  • Error Handling - API error codes and responses
    • HTTP status codes
    • Error response format
    • Common errors and solutions

Base URL

All API requests should be made to:

https://babylon.market/api

For local development:

http://localhost:3000/api

Note: All API endpoints are prefixed with /api. The base URL includes the /api path.

Authentication

All API requests (except public endpoints) require authentication using a JWT token obtained through Privy. See the Authentication guide for details.

Authorization: Bearer <your-jwt-token>

Rate Limits

API requests are rate-limited to ensure fair usage:

  • Authenticated requests: 1000 requests per minute
  • Public endpoints: 100 requests per minute

Rate limit headers are included in all responses:

  • X-RateLimit-Limit - Maximum requests allowed
  • X-RateLimit-Remaining - Remaining requests in current window
  • X-RateLimit-Reset - Unix timestamp when limit resets

Response Format

All API responses follow a consistent format:

{ "data": { ... }, "error": null }

Error responses:

{ "data": null, "error": { "message": "Error description", "code": "ERROR_CODE" } }

SDKs and Libraries

While you can use the API directly, we recommend using our official SDKs:

  • TypeScript/JavaScript - @babylon/sdk (coming soon)
  • Python - babylon-python (coming soon)

Next Steps

Support

Last updated on