Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ The library remains available for application code. Pass your key explicitly:
import os
from parlay_api import ParlayAPI

client = ParlayAPI(api_key=os.environ["PARLAY_API_KEY"])
key = os.environ.get("PARLAY_API_KEY", "").strip()
if not key:
raise SystemExit("Set PARLAY_API_KEY to the key for this account.")
client = ParlayAPI(api_key=key)
events = client.odds("baseball_mlb", regions="us", markets="h2h")
if not events:
print("No events returned for this request.")
Expand All @@ -135,7 +138,10 @@ for bet365 and Caesars:
import os
from parlay_api import ParlayAPI

client = ParlayAPI(api_key=os.environ["PARLAY_API_KEY"])
key = os.environ.get("PARLAY_API_KEY", "").strip()
if not key:
raise SystemExit("Set PARLAY_API_KEY to the key for this account.")
client = ParlayAPI(api_key=key)
filters = {"bookmakers": ["bet365", "caesars"], "markets": "h2h"}
report = client.odds_coverage("soccer_epl", **filters, fresh_within_seconds=900)
rows = {row["source"]: row for row in report["sources"]}
Expand Down Expand Up @@ -192,7 +198,7 @@ headers. Header fields may be `None` when the service does not provide them.
Practice a disconnect, duplicate update and reconnect using the [offline WebSocket replay](examples/websocket-replay).
It runs with Python alone and includes a fictional price trace.

The optional live WebSocket example requires `python -m pip install 'parlay-api[ws]'`.
With the wheel above installed, add the WebSocket dependency with `python -m pip install "websockets>=11.0"`.
WebSocket access is Business tier and up; see the current docs before connecting.

### Request delayed Pinnacle game lines
Expand All @@ -205,7 +211,10 @@ credit charges apply.
import os
from parlay_api import ParlayAPI

client = ParlayAPI(api_key=os.environ["PARLAY_API_KEY"])
key = os.environ.get("PARLAY_API_KEY", "").strip()
if not key:
raise SystemExit("Set PARLAY_API_KEY to the key for this account.")
client = ParlayAPI(api_key=key)
events = client.odds("basketball_nba", markets="h2h", bookmakers="pinnacle_delayed")
print("Events returned:", len(events))
```
Expand Down
15 changes: 15 additions & 0 deletions context7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://context7.com/schema/context7.json",
"projectTitle": "ParlayAPI Python SDK",
"description": "Python client and CSV starter for ParlayAPI sports data. Run one public odds sample, compare saved moneyline responses, or make an authenticated request with your own account.",
"excludeFolders": [
".github",
"tests"
],
"rules": [
"Use the GitHub wheel linked in the current README for its examples. Check the version installed from PyPI separately.",
"For a first keyless CSV, pass --sport basketball_nba. A successful header-only CSV contains zero usable observations for that request.",
"Before calling an account method with an explicit credential, check that PARLAY_API_KEY contains a nonblank value. Keep the credential in the local environment.",
"For migrations, compare actual event IDs, requested markets and filters, returned fields, timestamps and request costs. The repository includes an offline comparison."
]
}
65 changes: 19 additions & 46 deletions parlay_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,30 @@
"""ParlayAPI Python SDK.
"""Python client for ParlayAPI sports data.

A drop-in replacement for the ``the-odds-api`` Python clients with
extensions for player props, prediction markets, and WebSocket
streaming.
First public sample
===================

Quickstart
==========
Use the wheel linked in the repository README for the documented release.
With that release installed, this command makes one public NBA request and
writes the returned moneyline observations to CSV::

.. code-block:: python
python -m parlay_api --sport basketball_nba > odds.csv

from parlay_api import ParlayAPI
A header-only file contains zero usable observations. The program writes
diagnostics to stderr. For other supported boards see
``python -m parlay_api --help``.

client = ParlayAPI(api_key="YOUR_KEY")
Evaluating an existing integration
==================================

# TOA-compatible endpoints (identical paths and response shapes)
sports = client.sports()
odds = client.odds(
"baseball_mlb",
regions="us",
markets="h2h,spreads,totals",
odds_format="american",
)
events = client.events("baseball_mlb")
scores = client.scores("baseball_mlb", days_from=1)
For an existing v4 client, check the event identifiers, market and bookmaker
filters, response fields, timestamps and request costs your application uses.
The repository includes an offline example with two different IDs for one
fictional NBA fixture. From the repository root, run::

# ParlayAPI-specific extensions
props = client.props(
"baseball_mlb",
markets=["player_strikeouts", "player_total_bases"],
bookmakers=["draftkings", "fanduel"],
)

# Devig helpers
fair_over, fair_under = client.devig(over_price=-110, under_price=-110)

Migrating from the-odds-api
===========================

Step 1: ``pip install parlay-api``
Step 2: Change one import:

.. code-block:: python

# before
from the_odds_api import OddsAPI
client = OddsAPI(api_key=KEY)

# after
from parlay_api import ParlayAPI as OddsAPI # alias keeps the rest unchanged
client = OddsAPI(api_key=KEY)
python3 examples/odds-migration/compare.py examples/odds-migration/example.json

The same paths (``/v4/sports``, ``/v4/sports/{sport}/odds``, etc.) and
response shapes work without further changes.
See https://github.com/JacobiusMakes/parlay-api-python#readme for the current
installation command and instructions for making a private account request.
"""
from __future__ import annotations

Expand Down
Loading