diff --git a/README.md b/README.md index 46069e8..877ac07 100644 --- a/README.md +++ b/README.md @@ -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.") @@ -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"]} @@ -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 @@ -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)) ``` diff --git a/context7.json b/context7.json new file mode 100644 index 0000000..f552073 --- /dev/null +++ b/context7.json @@ -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." + ] +} diff --git a/parlay_api/__init__.py b/parlay_api/__init__.py index 815408d..a0fbe1d 100644 --- a/parlay_api/__init__.py +++ b/parlay_api/__init__.py @@ -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