Skip to main content

Official Python SDK for the Magisterial college sports data API

Project description

Magisterial Python SDK

The official Python library for the Magisterial developer API — college sports data across NCAA D1/D2/D3, NAIA, and NJCAA: players, teams, rosters, cross-program careers, games, the live transfer portal, and an agent-backed natural-language query endpoint.

Installation

pip install magisterial

Requires Python 3.10+.

Usage

Create an API key at magisterial.ai/console/api-keys and set MAGISTERIAL_API_KEY (or pass api_key= to the client).

from magisterial import Magisterial

client = Magisterial()

# Search players (auto-pagination follows the cursor for you)
page = client.players.search(
    sport="soccer", division="D1", gender="women",
    position="Forward", sort_by="goals",
)
for player in page.auto_paging_iter():
    print(player.name, player.team, player.stats.get("goals"))

# One player's full profile
player = client.players.get(184223, sport="soccer", division="D3")

# Live transfer portal (usage-billed; use `since` for incremental polling)
portal = client.portal.list(sport="basketball", division="D1", status="INC")

# Natural-language query (usage-billed): submit and wait for the answer
run = client.query.create_and_poll(
    prompt="Who led the NESCAC in assists this season?",
    sport="soccer", division="D3", gender="men",
)
print(run.answer)

Async

Every method is mirrored on AsyncMagisterial:

import asyncio
from magisterial import AsyncMagisterial

async def main():
    async with AsyncMagisterial() as client:
        page = await client.players.search(sport="soccer", division="D1")
        async for player in page.auto_paging_iter():
            print(player.name)

asyncio.run(main())

Errors

Non-2xx responses raise typed exceptions carrying the API's error envelope:

from magisterial import Magisterial, NotFoundError, RateLimitError

client = Magisterial()
try:
    client.players.get(1, sport="soccer", division="D1")
except NotFoundError as e:
    print(e.error_code)   # "player_not_found"
except RateLimitError as e:
    print(e.retry_after)  # seconds, from the Retry-After header

BillingError (402) means API billing is not enabled or the monthly budget is exhausted — manage both in the developer console.

Retries

Idempotent requests (and players.search) are retried automatically on 429s, 5xx and connection failures — up to max_retries (default 2), honoring the server's Retry-After. Billable creates (query.create, alerts.create) are never retried automatically.

Types

All request/response models live in magisterial.types and are generated from the published OpenAPI spec (scripts/sync-types.sh), so they cannot drift from the live API contract.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magisterial-0.1.0.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magisterial-0.1.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file magisterial-0.1.0.tar.gz.

File metadata

  • Download URL: magisterial-0.1.0.tar.gz
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for magisterial-0.1.0.tar.gz
Algorithm Hash digest
SHA256 260339c1b5882a8e8e287179cb7c671b91cdc225770c4714da88e8946d37d775
MD5 cf28e3a01ca9a62a3fe9eb98da378420
BLAKE2b-256 dc02e37526ec8466218c40500cb94f9e73ee5450cf48fa82404b475333efa7b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for magisterial-0.1.0.tar.gz:

Publisher: publish.yml on bluemens/magisterial-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file magisterial-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: magisterial-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for magisterial-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3de0438e6e24d82600687f64489ed5146a5a7f6da006f96d4d45475a24999c93
MD5 89e825e95101750e4e71aa0e2df1bfc6
BLAKE2b-256 541cdc7482486f10c93ac3890a0e316d2cad81ea2766a806a61064a8414e5791

See more details on using hashes here.

Provenance

The following attestation bundles were made for magisterial-0.1.0-py3-none-any.whl:

Publisher: publish.yml on bluemens/magisterial-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page