Back to Developer Tutorials
Allotment & Lottery Odds• 7 min read•Updated: October 2026

How to Fetch Live IPO Allotment Status & Lottery Odds via API

Every retail investor in India wants to know their true statistical probability of winning an IPO allotment. In this tutorial, you will use Python to query the Subscription with App-Wise Intelligence endpoint to extract mathematical 1-in-X lottery odds (PeopleBase) and certified Basis of Allotment PDF documents.

The Mathematical Mechanics of SEBI Retail Allotment

In standard Indian public offerings, the retail category is allocated using an electronic randomized computerized lottery when oversubscribed. The formula for the lottery odds ratio (peopleBase) is:

PeopleBase = Total Valid Retail Applications / Maximum Retail Allottees

For example, if 1,20,000 retail applications are submitted for 20,000 available lots, the PeopleBase is 6, which translates to a exact 1-in-6 chance of winning an allotment per applicant PAN.

Complete Python Implementation

The following Python script authenticates with your API keys, fetches granular application statistics for Retail, sNII, and bNII tranches, and downloads certified registrar Basis of Allotment document links.

allotment_odds.py
python
import requests
import json
import os

API_KEY = os.getenv("IPO_API_KEY", "YOUR_API_KEY")
API_SECRET = os.getenv("IPO_API_SECRET", "YOUR_API_SECRET")
HEADERS = {
    "ApiKey": API_KEY,
    "ApiSecret": API_SECRET,
    "Accept": "application/json"
}

def analyze_ipo_allotment_odds(ipo_id):
    """
    Fetches category-wise application counts, maximum allottees,
    and returns computed 1-in-X lottery odds (PeopleBase).
    """
    url = f"https://api.ipoapipro.in/api/ipo/subscription-with-appwise/{ipo_id}"
    response = requests.get(url, headers=HEADERS, timeout=10)
    response.raise_for_status()
    payload = response.json()

    if not payload.get("isSuccess"):
        print(f"Failed to fetch data for IPO ID {ipo_id}")
        return

    data = payload.get("data", {})
    company = data.get("companyName")
    app_stats = data.get("appWiseSubscription", [])

    print(f"\n=======================================================")
    print(f"Allotment Odds Intelligence: {company} (ID: {ipo_id})")
    print(f"=======================================================")

    for cat in app_stats:
        name = cat.get("name")
        reserved_lots = cat.get("reserved")
        applied_apps = cat.get("applied")
        sub_times = cat.get("subscriptionTimes")
        odds = cat.get("peopleBase")

        print(f"Category: {name}")
        print(f"  • Quota Lots Available: {reserved_lots:,}")
        print(f"  • Total Applications:   {applied_apps:,}")
        print(f"  • Subscription Multiple: {sub_times}x")
        print(f"  • Lottery Odds (PeopleBase): 1 in {odds} applicants wins allotment!\n")

    print(f"AI Market Summary:")
    print(f"{data.get('appWiseSummary')}\n")

def fetch_official_basis_of_allotment(year=2026, ipo_type="mainboard"):
    """
    Fetches certified registrar Basis of Allotment PDF download links.
    """
    url = f"https://api.ipoapipro.in/api/allotment/basis-records/{year}/{ipo_type}"
    res = requests.get(url, headers=HEADERS, timeout=10)
    records = res.json().get("data", [])

    print(f"Found {len(records)} official Basis of Allotment records for {year} ({ipo_type}):")
    for r in records[:5]:
        print(f"  • {r.get('companyName')}: {r.get('basicOfAllotment')}")

if __name__ == "__main__":
    # Example: Analyze IPO ID 257
    analyze_ipo_allotment_odds(ipo_id=257)
    fetch_official_basis_of_allotment(year=2026, ipo_type="mainboard")

Script Execution Output

=======================================================
Allotment Odds Intelligence: Shah Investor's Home (ID: 257)
=======================================================
Category: Retail
• Quota Lots Available: 22,232
• Total Applications: 1,24,525
• Subscription Multiple: 5.60x
• Lottery Odds (PeopleBase): 1 in 6 applicants wins allotment!

Related Endpoints Used in this Guide