STAT-API

Java SDK

The official STAT-API client for Java. A typed wrapper over the REST surface, SIM engines, and DFS optimizers — construct StatApi and every request and response is statically typed. Version v0.3.1.

SDK Source →Cookbook Repository →Maven Central (coming soon)

Install

git clone https://github.com/stat-api/stat-api

Build from source via the monorepo using Gradle or JitPack while registry publishing completes.

Quickstart

Construct StatApi with STAT_API_KEY set, list rows, and print them.

// Hello, NBA
// Generated from schema/api/examples/hello-stat-api.yml — do not edit.
package com.statapi.cookbook;

import com.statapi.StatApi;
import com.statapi.nba.*;
import java.util.*;

public final class NbaHelloStatApi {
    public static void main(String[] args) {
        StatApi api = new StatApi(); // reads STAT_API_KEY from the environment

        // List a few teams
        List<NBATeam> teams = api.nba().teams().list(new NBATeamsListParams().limit(3L)).rows();

        // Print what came back
        System.out.println(teams);

    }
}

Client method reference

Tables & auto-paging
  • api.<league>().<table>().list(params)
  • api.<league>().<table>().get(id)
  • for (var row : api.<league>().<table>().iterate(params))
NFL Play-by-Play SIM (beta)
  • api.nfl().weeks(season)
  • api.sim().nfl().run(new NFLSimPublicRunRequest(gameId)...)
NBA Possession SIM (beta)
  • api.nba().weeks(season)
  • api.sim().nba().run(new NBASimPublicRunRequest(gameId)...)
DFS Fast Optimizer & Late Swap (mode="fast")
  • api.dfs().slates().optimizerLineups(slateId, new DfsLineups.OptimizerLineupsRequest()...)
  • api.dfs().slates().optimizerLineupsCsv(slateId, new DfsLineups.OptimizerLineupsRequest()...)
DFS SIM Lineups, Scenarios, Pool Re-Select & Async Jobs
  • api.dfs().slates().simLineups(slateId, req, new DfsLineups.SimRequestOptions().wait(true))
  • api.dfs().contests().buildLineups(contestId, req, new DfsLineups.SimRequestOptions().wait(true))
  • api.dfs().slates().simLineupsCsv(slateId, req, opts)
  • api.dfs().slates().simLineupsStart(slateId, req)
  • api.dfs().slates().simJob(slateId, jobId)
  • api.dfs().slates().simSelectPool(slateId, req)
  • api.dfs().slates().simLateSwap(slateId, req, opts)

SIM & Optimizer starter templates

Copy-pasteable runnable templates generated from the same YAML specs as the cookbook, verified to produce identical output across all 4 languages.

Run your first NFL game simulationOpen full recipe & verified output →
package com.statapi.cookbook;

import com.statapi.*;
import com.statapi.nfl.*;
import java.util.*;

public final class NFLSimSummary {
    public static void main(String[] args) {
        StatApi api = new StatApi(); // reads STAT_API_KEY from the environment

        // Find the free game
        NFLWeeksResponse weeks = api.nfl().weeks(2026);
        long gameId = weeks.freeGameId();
        System.out.println("Season " + weeks.season() + " | free game " + gameId + " | " + weeks.games().size() + " games");

        // Run the game 5,000 times
        NFLSimPublicRunResponse run = api.sim().nfl().run(
            new NFLSimPublicRunRequest(gameId)
                .nDraws(5000)
                .seed(42L)
                .include(new NFLSimInclude()
                    .summary(true)
                    .distributions(false)
                    .scorebox(false)
                    .pbp(false)));
        NFLSimSummarySection summary = run.output().summary();
        if (summary == null) {
            throw new IllegalStateException("the run returned no summary");
        }
        System.out.println(String.format(Locale.ROOT,
            "Simulated total %.2f (SD %.2f) | home win %.1f%% | home cover %.1f%% | over %.1f%%",
            summary.simTotalMean(), summary.simTotalSd(), summary.homeWinProb() * 100,
            summary.homeCoverProb() * 100, summary.overProb() * 100));
        System.out.println("Box-score checks: " + (summary.conservationOk() ? "passed" : "failed"));

        // Rank the players
        List<NFLSimPlayerSummary> players = new ArrayList<>(summary.players());
        players.sort(Comparator.comparingDouble(NFLSimPlayerSummary::recYdMean).reversed());
        System.out.println("Top 5 players by mean receiving yards:");
        for (NFLSimPlayerSummary p : players.subList(0, 5)) {
            System.out.println(String.format(Locale.ROOT,
                "  Player %d (%s/%s) | mean %.1f | median %.1f | 90th percentile %.1f",
                p.playerId(), p.position(), p.depthRole(), p.recYdMean(), p.recYdP50(), p.recYdP90()));
        }

    }
}

Unified modes, scenarios, async 202 jobs & <50ms pool re-selection

  • Zero-param optimal SIM & execution modes: both POST /dfs/slates/{slate_id}/optimizer/lineups and POST /dfs/contests/{contest_id}/optimizer/lineups default to mode: "sim" + strategy: "optimal", returning correlated games[].scenarios[] and live NFL/NBA games[].correlations (override per-game weights or add custom branches with scenarios[]). Explicit caller overrides always win over strategy defaults. Call optimizerLineups to run synchronous mode: "fast" MILP.
  • Synchronous vs. background 202 polling: simLineups and contests.buildLineups poll 202 Accepted jobs automatically via GET /api/v1/dfs/jobs/{job_id} (respecting Retry-After), or accept wait: true to send Prefer: wait for inline completion. Use simLineupsStart + simJob to manage non-blocking queues explicitly.
  • Instant pool_id re-selection: read sim.versions.pool_id from any completed build and pass it to simSelectPool with updated scenarios[], diversity weights, exposure bounds, or include_diversity_frontier: true without re-simulating draws.
  • Direct operator CSV strings: call the CSV helper (e.g. api.dfs().slates().optimizerLineupsCsv(slateId, new DfsLineups.OptimizerLineupsRequest()...)) to receive ready-to-upload rows preserving Entry IDs on late swap.

Authentication, pagination & errors

Reads STAT_API_KEY automatically (default base URL https://api.stat-api.com). Get a key on the pricing page.

Table endpoints return bounded pages with next_from_id or stream all rows via iterate(). HTTP failures raise typed StatApiError subclasses (AuthenticationError 401, PlanRequiredError 402, ValidationError 400, NotFoundError 404, QuotaExceededError 429) with Quota counts from X-Quota-* headers.

Free SIM games: NFL 43418 (2026 Week 1 DEN @ KC) and NBA 6029936 (DET @ BOS); other games require a Pro or Elite plan, or the DFS add-on.