SDK quickstarts

Drop-in quickstart for every ParlayAPI reference client. Every client implements the same patterns: X-API-Key auth, capped exponential backoff on 429/5xx, Retry-After honoring, per-request X-Request-ID surfacing, and Idempotency-Key support on writes. Each is a single file with minimal dependencies. Pick your language and start.

Python

3.10+ · single file · requests is the only dep (stdlib otherwise).

File: examples/parlay_api_client.py Tested on: 3.10, 3.11, 3.12, 3.13

Install

pip install requests
curl -O https://raw.githubusercontent.com/JacobiusMakes/ParlayAPI/main/examples/parlay_api_client.py

First call

import os
from parlay_api_client import Client

client = Client(api_key=os.environ["PARLAY_API_KEY"])
odds = client.odds("baseball_mlb", regions="us", markets="h2h,spreads")
print(odds[0])

JavaScript / Node

Node 18+ or any modern browser · zero dependencies · uses native fetch.

File: examples/parlay_api_client.js Tested on: Node 18, 20, 22

Install

curl -O https://raw.githubusercontent.com/JacobiusMakes/ParlayAPI/main/examples/parlay_api_client.js

First call

import { Client } from "./parlay_api_client.js";

const client = new Client({ apiKey: process.env.PARLAY_API_KEY });
const odds = await client.odds("baseball_mlb",
  { regions: "us", markets: "h2h,spreads" });
console.log(odds[0]);

Go

1.21+ · single .go file · stdlib only (net/http + encoding/json + context).

File: examples/parlay_api_client.go Tested on: Go 1.21, 1.22, 1.23

Install

curl -O https://raw.githubusercontent.com/JacobiusMakes/ParlayAPI/main/examples/parlay_api_client.go
# drop into your package; no go.mod entries required

First call

package main

import (
    "context"
    "fmt"
    "os"
)

func main() {
    c, _ := NewClient(WithAPIKey(os.Getenv("PARLAY_API_KEY")))
    odds, err := c.Odds(context.Background(), "baseball_mlb",
        map[string]string{"regions": "us", "markets": "h2h,spreads"})
    if err != nil { panic(err) }
    fmt.Println(odds[0])
}

Ruby

3.0+ · stdlib only (net/http + json + securerandom).

File: examples/parlay_api_client.rb Tested on: Ruby 3.0, 3.1, 3.2, 3.3

Install

curl -O https://raw.githubusercontent.com/JacobiusMakes/ParlayAPI/main/examples/parlay_api_client.rb

First call

require_relative 'parlay_api_client'

client = ParlayAPI::Client.new(api_key: ENV.fetch('PARLAY_API_KEY'))
odds = client.odds('baseball_mlb', regions: 'us', markets: 'h2h,spreads')
puts odds.first

Java

17+ · stdlib only (java.net.http) · no Jackson/Gson.

File: examples/ParlayAPIClient.java Tested on: Java 17, 21

Install

curl -O https://raw.githubusercontent.com/JacobiusMakes/ParlayAPI/main/examples/ParlayAPIClient.java

First call

import java.util.Map;

public class Main {
    public static void main(String[] args) {
        var client = ParlayAPIClient.builder()
            .apiKey(System.getenv("PARLAY_API_KEY"))
            .build();
        String json = client.oddsJson("baseball_mlb",
            Map.of("regions", "us", "markets", "h2h,spreads"));
        System.out.println(json);
    }
}

PHP

8.1+ · strict types · curl extension only · no Composer.

File: examples/parlay_api_client.php Tested on: PHP 8.1, 8.2, 8.3

Install

curl -O https://raw.githubusercontent.com/JacobiusMakes/ParlayAPI/main/examples/parlay_api_client.php

First call

<?php
require_once __DIR__ . '/parlay_api_client.php';

$client = new ParlayAPI\Client(apiKey: getenv('PARLAY_API_KEY'));
$odds = $client->odds('baseball_mlb', regions: 'us',
                       markets: 'h2h,spreads');
print_r($odds[0] ?? $odds);

C# / .NET

.NET 6+ · single file · System.Net.Http + System.Text.Json · no NuGet.

File: examples/ParlayApiClient.cs Tested on: .NET 6, 7, 8

Install

curl -O https://raw.githubusercontent.com/JacobiusMakes/ParlayAPI/main/examples/ParlayApiClient.cs

First call

using ParlayApi;

using var client = ParlayApiClient.Builder()
    .ApiKey(Environment.GetEnvironmentVariable("PARLAY_API_KEY"))
    .Build();
string json = await client.OddsJsonAsync("baseball_mlb",
    new Dictionary<string, string> {
        ["regions"] = "us", ["markets"] = "h2h,spreads"
    });
Console.WriteLine(json);

Rust

1.75+ · async via tokio · reqwest + serde_json + thiserror + uuid.

File: examples/parlay_api_client.rs Tested on: Rust 1.75, 1.80, 1.85

Install

# Cargo.toml
[dependencies]
reqwest    = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
tokio      = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
serde      = { version = "1", features = ["derive"] }
serde_json = "1"
uuid       = { version = "1", features = ["v4"] }
thiserror  = "1"
url        = "2"

First call

use parlay_api::Client;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Client::builder()
        .api_key(std::env::var("PARLAY_API_KEY")?)
        .build()?;
    let odds = client.odds_json(
        "baseball_mlb",
        &[("regions", "us"), ("markets", "h2h,spreads")]
    ).await?;
    println!("{}", odds);
    Ok(())
}

Common error envelope

Every client surfaces the same structured error: status (HTTP code), code (machine-readable string), message, request_id (X-Request-ID header value, include this when filing support issues), and docs_url (link to the relevant docs section). 429 responses are retried automatically with Retry-After. 502/503/504 use capped exponential backoff. 4xx other than 429 throw immediately with no retry.

Missing your language?

Generate a client in any language directly from the OpenAPI spec:

openapi-generator-cli generate \
  -i https://parlay-api.com/openapi.json \
  -g $LANGUAGE -o ./parlay-api-$LANGUAGE

Or open an issue at github.com/JacobiusMakes/ParlayAPI/issues and we'll add it.