Metadata-Version: 2.5
Name: onice
Version: 0.2.0
Summary: Python client and MCP server of the onice.dev API: advanced NHL statistics
Project-URL: Homepage, https://onice.dev/developers/
Project-URL: Documentation, https://onice.dev/docs/api/
Project-URL: Plans, https://onice.dev/developers/plans/
Author-email: onice <support@onice.dev>
License: MIT
License-File: LICENSE
Keywords: api,expected-goals,hockey,mcp,nhl,statistics,war,xg
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.10
Requires-Dist: requests>=2.28
Provides-Extra: mcp
Requires-Dist: mcp>=1.2; extra == 'mcp'
Provides-Extra: pandas
Requires-Dist: pandas>=1.5; extra == 'pandas'
Description-Content-Type: text/markdown

# onice

Python client and MCP server of the [onice.dev](https://onice.dev/developers/) API: advanced NHL
statistics (Corsi, expected goals, on-ice numbers, lines and pairs, WOWY, goalies, RAPM, GAR and WAR)
calculated from public NHL data. These are not official NHL numbers.

```
pip install onice
```

Get a free API key on <https://onice.dev/developers/>. The key is read from the environment
variable `ONICE_API_KEY`, or give it to the client.

```python
import onice

client = onice.Client("YOUR_KEY")

client.find_player("mcdavid")  # NHL ids by name
page = client.skaters(seasons="20252026", sit="5v5", sort="xgf_pct", limit=50)
page.data[0], page.cost, page.remaining  # rows, what the request cost in credits, what is left

rows = client.rows("tables/skaters", seasons="20252026", sit="5v5", sort="xgf_pct", max_rows=3000)
frame = client.skaters(seasons="20252026", limit=100).to_pandas()  # needs pandas
```

Every endpoint of the API is a method named like its operation (`client.tables_lines(...)`,
`client.player_profile(player_id=8478402)`); `client.operations` lists them with their parameters,
and the documentation is on <https://onice.dev/docs/api/>. A list is read page after page with
`client.rows(...)` (one answer has at most 1000 rows).

## Fantasy hockey

```python
client.fantasy_points(seasons="20262027", g=3, a=2, sog=0.4, limit=50)  # your league's points
client.fantasy_goal_scorers()  # the skaters of today's games with their shooting numbers
client.fantasy_playoff_schedule(start="2027-03-15", weeks=3)  # games and off-nights by team
```

## What it costs

A request costs one credit of your quota for every started 100 rows it returns, times the
seasons you ask for (up to 10). `Result.cost` tells what an answer cost and `Result.remaining` what
is left; `onice.estimate_cost(rows, seasons)` counts it before you ask. Please credit onice.dev where
you show the numbers.

## Errors

`AuthError` (no or wrong key), `BadRequestError` (a parameter), `NotFoundError`, `RateLimitError`
(too many requests in a minute: the client waits a short `Retry-After` by itself) and `QuotaError`
(the quota is used up, or the request could cost more than what is left: ask for fewer rows or
seasons). All are `OniceError`.

## For AI assistants (MCP)

```
pip install "onice[mcp]"
```

or run it without installing, with [uv](https://docs.astral.sh/uv/): `uvx onice-mcp`. Settings of
Claude Desktop, Cursor and others:

```json
{
  "mcpServers": {
    "onice": {
      "command": "uvx",
      "args": ["onice-mcp"],
      "env": { "ONICE_API_KEY": "YOUR_KEY" }
    }
  }
}
```

The tools: `find_player`, `skater_table`, `goalie_table`, `team_table`, `player_profile`,
`player_percentiles`, `compare_players`, `glossary`, `methodology`, `data_status`, `list_endpoints`
and `call_endpoint` (any other endpoint). The server runs on your computer and spends the quota of
your own key. Without uv: `python -m onice.mcp_server`.

## Licence

The code of this client is MIT. The numbers belong to onice.dev and follow the terms of your plan.
