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.2.0.tar.gz (37.3 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.2.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for magisterial-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e5b32718e809b996c8318309ca934763a8848bb297901094907a2264ea17d740
MD5 581c60b05a92f3c46edb3fc4ca28b1a2
BLAKE2b-256 68e859fa350b15574d8de609109a159946c270b290d6fe6d55b74a2d565af0e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for magisterial-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: magisterial-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c07819deb5edc0de1a7838dbf5a1b5b28cc6302af7bc876175543dac547c4972
MD5 90a5bb3c3e6164fa0e2676c9a268d62f
BLAKE2b-256 9bb56696153d2cffadee44b4c134abacf4e3423feb5100779d3dda635b8e9865

See more details on using hashes here.

Provenance

The following attestation bundles were made for magisterial-0.2.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