B2B: Omnibus - API Integration

Learn how to set up and integrate with the B2B API, including technical requirements, key concepts, and major integration steps.

NOTE: You should only be using this guide if you are flagged as a B2B User, NOT a Market Maker or Affliate

Getting Started

Technical Requirements

  • Programming Language: Python (examples provided) or any language capable of making HTTP requests.
  • Security: Ability to generate and manage RSA keys.
  • Real-time Data: WebSocket support for live updates.
  • JSON Handling: All data is exchanged in JSON format.

Key Concepts to Understand

  • Authentication: JWT tokens signed with RSA private keys.
  • REST API: Standard HTTP requests for placing orders and retrieving data.
  • WebSockets: Live data streams for real-time updates.
  • Market Data: Understanding tournaments, events, markets, and selections.
  • Order Management: Tracking orders with unique external IDs and detailed information of already placed orders.

Note: B2B API access requires institutional partnership approval and account setup by the Prophet team. They will provide you with testing funds for sandbox integration.

Sample Integration Script

API Documentation

Major Integration Steps

  1. Generate And Import API Keys - Create authentication keys
  2. Get Account Balance - Get account balance and simply verify that your account is working
  3. Browse Available Games - See what tournaments and games are available
  4. Connect to Live Updates - Get real-time game and market updates
  5. Place and Cancel Orders - Start placing orders
  6. Order management - Get your detailed orders information history

Step 1: Create B2B API Keys

Before using the API, you need to create security keys for authentication. Think of this as obtaining a special password that proves you're authorized to use the system.

What You Need To Do

  • Create Private and Public Key Pair: This is your secret authentication key.
  • Import Public Key to Prophet System: Prophet will verify every request using this public key.
  • Keep Private Key Safe: Never share this with anyone.
  • Use Private Key to Sign JWT Token: How to sign a request?

How Authentication Works

Every time you make an API call, you create a special JWT "token."

  • This token is signed with your private key and expires after a set period.
  • All API requests include this token in the header to prove you're authorized.

Example of What Happens Behind the Scenes:

  • Your API Call → Create Token → Sign with Private Key → Send Request → Get Response

Step 2: Check Your Account Balance

  • API Endpoint: /api/v1/balance

This is a simple test to ensure your authentication is working and to see how much money you have available for trading.

What It Does

  • Connects to your Prophet account.
  • Shows your current balance.
  • Confirms your API access is working properly.

Response Example

When successful, you'll receive information like:

"balance": 9999772.43,          // Total account balance
"unmatched_balance": 230,       // Total current unmatched order balance
"matched_balance": 100          // Total matched balance

This step is optional but recommended to verify everything is set up correctly before moving to more complex operations.

Step 3: Browse Available Games and Markets

API Endpoints:

How It Works

  • Get Tournaments: First, see what sports leagues are available (NBA, NFL, MLB, etc.).
  • Get Games: For each tournament, see what games are happening.
  • Get Markets: For each game, see what you can play on (moneyline, spread, totals).

What You Can Access

  • Live Games: Games happening now (live).
  • Upcoming Games: Games scheduled for later (booked).
  • Markets Info: Different types of orders available:
    • Moneyline: Predict who wins.
    • Spread: Predict the point difference.
    • Totals: Predict over/under total points.
    • Half-time Markets: Predict just the first half.

Example Flow

  1. Get Tournaments → Find "NBA"
  2. Get Sport Events → Find "Lakers vs Warriors"
  3. Get Markets → See "Lakers +150" or "Total Points Over 215.5"

This gives you all the information you need to know what's available for trading.

Step 4: Connect to Live Data Updates

Why You Need This

Sports market info changes constantly - odds move up and down as money comes in. To play effectively, you need real-time updates rather than repeatedly asking for new information.

What You Get

  • Live Odds Updates: See when odds change immediately.
  • Game Status Updates: Know when games start, end, or have important events.
  • Your Order Updates: Get notified when your orders are matched, cancelled, or settled.

How It Works

The system uses WebSockets (powered by Pusher) to "push" updates to you automatically:

  • Connect: Establish a live connection to Prophet's data feed.
  • Authorize: Prove you're allowed to receive data.
  • Subscribe: Choose what types of updates you want.
  • Receive: Get automatic notifications when things change.

Types of Updates

  • Market Updates: When odds change for games you're watching.
  • Order Updates: When something happens with your orders.
  • Tournament Updates: When games start/end or have significant events.

Important: The connection configuration should be refreshed every 30 minutes to ensure uninterrupted service.

Step 5: Place and Cancel Orders

API Endpoints:

Placing Order

Each order you place needs:

  • External ID: Your unique identifier for tracking (like a receipt number).
  • External User ID: Your system user ID.
  • Line ID: What you're placing an order on (from the market data).
  • Stake: How much money you want to place.
  • Odds: What odds you want (from market data).

Important Rules

  • Unique External IDs: Each place must have a unique ID. If you use the same ID twice, the second place will be rejected.
  • Valid Markets: You can only place on active markets with available odds.
  • Account Balance: You can't place more than your available balance.

Cancelling Order

To cancel an order, you need:

  • Order ID: The order ID you get after placing an order.

You can only cancel orders that haven't been fully matched yet.

Example Trading Flow

  1. See Lakers vs Warriors game.
  2. Notice Lakers moneyline at +150 (good value).
  3. Place order: $100 on Lakers +150.
  4. Get confirmation: "Order #123 placed successfully."
  5. Watch game/market changes.
  6. If odds move unfavorably, cancel: "Cancel order #123."

Batch Operations

You can also:

  • Place Multiple Orders: Submit several orders at once.
  • Cancel Multiple Orders: Cancel several orders with one request.

This is more efficient than placing/cancelling one order at a time.

Step 6: Orders Management

API Endpoints:

How It Works

This provides all information about your orders (succeeded orders). We support several filter parameters to limit the amount of data you will get.

  • From timestamp (Unix timestamp)
  • To timestamp (Unix timestamp)
  • Status filter (open, settled, manually_settled, closed, void)
  • Matching status filter (partially_matched, unmatched, fully_matched)
  • External User ID filter
  • Cursor pagination
  • Limit (default 20, max 100)

Note: This API may experience delays, as data needs to be synchronized.

Complete Integration Example

Here's what a simple playing flow looks like:

  1. Start Up:

    • Check account balance.
    • Connect to live data feeds.
    • Get a list of available games.
  2. Find Trading Opportunities:

    • Monitor NBA games.
    • Look for favorable moneyline odds.
    • Check market liquidity (how much money is available).
  3. Execute Orders:

    • Place a $10 order when odds look good.
    • Set up automatic order tracking.
    • Cancel orders if odds move against us.
  4. Monitor & Manage:

    • Watch for order updates via WebSocket.
    • Track wins/losses.
    • Adjust strategy based on performance.
    • Get history orders to obtain detailed information.

Safety Best Practices

  • Sandbox Protection: Code prevents running against production accidentally.
  • Error Handling: Gracefully handles network issues and API errors.

Security Best Practices

  • Store private keys securely (never in code).
  • Use unique external IDs for all orders.
  • Validate all inputs before sending to API.
  • Monitor for suspicious activity or errors.