Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.fieldfunded.com/llms.txt

Use this file to discover all available pages before exploring further.

Calculate Parlay Odds in JavaScript

A parlay (or accumulator) multiplies the odds of multiple selections together. If all legs win, the payout is much larger than individual bets. This tutorial shows how to calculate parlay odds, payouts, and implied probabilities in JavaScript — and how to use an API to settle them automatically.

The Math

For a parlay with legs at decimal odds o₁, o₂, …, oₙ:
Combined odds = o₁ × o₂ × ... × oₙ
Payout = stake × combined odds
Profit = payout - stake
Example: $10 parlay on three matches at 1.90, 2.10, 1.75:
Combined = 1.90 × 2.10 × 1.75 = 6.9825
Payout = $10 × 6.9825 = $69.83
Profit = $69.83 - $10.00 = $59.83

Step 1: Basic Parlay Calculator

function calculateParlay(legs) {
  const combinedOdds = legs.reduce((acc, leg) => acc * leg.odds, 1);

  return {
    legs: legs.length,
    combinedOdds: Math.round(combinedOdds * 100) / 100,
    impliedProbability: (1 / combinedOdds * 100).toFixed(1) + "%",
  };
}

// Example
const myParlay = calculateParlay([
  { name: "Arsenal Win", odds: 1.90 },
  { name: "Over 2.5 Goals", odds: 2.10 },
  { name: "BTTS Yes", odds: 1.75 },
]);

console.log(myParlay);
// { legs: 3, combinedOdds: 6.98, impliedProbability: "14.3%" }

Step 2: Add Payout Calculation

function parlayPayout(stake, legs) {
  const combined = legs.reduce((acc, leg) => acc * leg.odds, 1);

  return {
    stake,
    combinedOdds: Math.round(combined * 100) / 100,
    payout: Math.round(combined * stake * 100) / 100,
    profit: Math.round((combined * stake - stake) * 100) / 100,
  };
}

console.log(parlayPayout(25, [
  { name: "Lakers Win", odds: 1.45 },
  { name: "Celtics Win", odds: 1.60 },
  { name: "Warriors Win", odds: 2.20 },
]));
// { stake: 25, combinedOdds: 5.10, payout: 127.60, profit: 102.60 }

Step 3: Handle Refund Legs

When one leg in a parlay is voided (match postponed, player withdrawal), that leg is treated as odds 1.00 — effectively removed from the parlay:
function parlayWithRefunds(stake, legs) {
  let combined = 1;
  let activeLegCount = 0;
  let refundLegCount = 0;

  for (const leg of legs) {
    if (leg.status === "refund" || leg.status === "void") {
      combined *= 1.00; // Refund leg = odds 1.00
      refundLegCount++;
    } else {
      combined *= leg.odds;
      activeLegCount++;
    }
  }

  return {
    totalLegs: legs.length,
    activeLegs: activeLegCount,
    refundedLegs: refundLegCount,
    combinedOdds: Math.round(combined * 100) / 100,
    payout: Math.round(combined * stake * 100) / 100,
  };
}

// One leg refunded — parlay becomes a double
const result = parlayWithRefunds(50, [
  { name: "Arsenal Win", odds: 1.90, status: "won" },
  { name: "Chelsea Win", odds: 2.10, status: "refund" },  // Postponed
  { name: "Liverpool Win", odds: 1.75, status: "won" },
]);

console.log(result);
// { totalLegs: 3, activeLegs: 2, refundedLegs: 1,
//   combinedOdds: 3.33, payout: 166.25 }

Step 4: Odds Format Converter

Not everyone uses decimal odds. Here is a converter for American and fractional formats:
function decimalToAmerican(decimal) {
  if (decimal >= 2.0) return `+${Math.round((decimal - 1) * 100)}`;
  return `-${Math.round(100 / (decimal - 1))}`;
}

function decimalToFractional(decimal) {
  const fraction = decimal - 1;
  // Simple fraction approximation
  const denominator = 100;
  const numerator = Math.round(fraction * denominator);
  const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b));
  const d = gcd(numerator, denominator);
  return `${numerator / d}/${denominator / d}`;
}

console.log(decimalToAmerican(2.50));    // "+150"
console.log(decimalToAmerican(1.40));    // "-250"
console.log(decimalToFractional(2.50));  // "3/2"
console.log(decimalToFractional(1.75));  // "3/4"

Step 5: Settle a Parlay with the API

Instead of checking each leg manually, submit the entire parlay to the FieldFunded API and get the combined result:
const API_KEY = "your_api_key_here";

async function settleParlay(stake, legs) {
  const response = await fetch(
    "https://api.fieldfunded.com/v1/bets/check-parlay",
    {
      method: "POST",
      headers: {
        "X-API-Key": API_KEY,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ stake, legs }),
    }
  );

  return response.json();
}

// Submit a 3-leg parlay for settlement
const settlement = await settleParlay(50, [
  {
    event_id: "evt_abc123",
    market: "Match Winner",
    selection: "Arsenal",
    odds: 1.90,
    market_id: "mkt_001",
    selection_id: "sel_001",
  },
  {
    event_id: "evt_def456",
    market: "Over/Under 2.5",
    selection: "Over 2.5",
    odds: 2.10,
    market_id: "mkt_002",
    selection_id: "sel_002",
  },
  {
    event_id: "evt_ghi789",
    market: "BTTS",
    selection: "Yes",
    odds: 1.75,
    market_id: "mkt_003",
    selection_id: "sel_003",
  },
]);

console.log(`Status: ${settlement.status}`);
console.log(`Payout: $${settlement.payout}`);
// Status: won
// Payout: $348.25
The API handles refund legs automatically — you do not need to implement the refund logic yourself.

Rate Limit Math

Use caseRequests/dayMonthlyPlan
Calculate parlays (client-side math)00No API needed
Settle 10 parlays daily10300Free
Settle 100 parlays daily1003,000Free
Fetch odds + settle (production app)50015,000Starter ($29)
Parlay math is pure calculation — it runs in your browser or server with zero API calls. You only need the API when you want to settle bets automatically or fetch live odds.

Get Your Free API Key

Settle parlays automatically — 10,000 free requests/month

See Pricing

All plans compared side by side