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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ See the [method reference](docs/methods.md) for the full method documentation th

Both clients use explicit timeouts, structured exceptions, and pooled HTTP connections. `strict_http=True` is the default. Final non-404 4xx responses raise `MlbHttpError`, while existing endpoint-specific 404 behavior is preserved.

Library-created clients send a versioned User-Agent. The current package version sends `python-mlb-statsapi/1.0.1`. See the [HTTP transport documentation](docs/http-transport.md) for the full transport contract.
Library-created clients send a versioned User-Agent. The current package version sends `python-mlb-statsapi/1.1.0`. See the [HTTP transport documentation](docs/http-transport.md) for the full transport contract.

The main transport exceptions are:

Expand Down
53 changes: 31 additions & 22 deletions docs/http-transport.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# HTTP Transport

This document describes the HTTP transport behavior of the current release,
version 1.0.0.
version 1.1.0.

Version 0.8.0 introduced shared Sessions, explicit timeouts, bounded retries,
and structured exceptions. Version 0.9.0 introduced configurable strict
behavior and compatibility warnings. Version 1.0.0 makes strict handling the
default and defines the stable public contract.

The public client remains synchronous. Ordinary usage does not need to
configure sessions or retries.
Version 1.1.0 adds the optional asynchronous `AsyncMlb` and
`AsyncMlbDataAdapter` clients while preserving the existing synchronous API.
Ordinary usage does not need to configure sessions, clients, or retries.

See [the 1.0.0 release notes](releases/1.0.0.md) for a shorter summary of what
changed. For the authoritative public API boundary see
See [the 1.1.0 release notes](releases/1.1.0.md) for a shorter summary of what
changed in the current release. For the authoritative public API boundary see
[the public API contract](public-api.md).

## Public transport API
Expand All @@ -21,6 +22,8 @@ Everything this document describes is reachable from the package root:

```python
from mlbstatsapi import (
AsyncMlb,
AsyncMlbDataAdapter,
Mlb,
MlbDataAdapter,
MlbDecodeError,
Expand All @@ -33,6 +36,9 @@ from mlbstatsapi import (
)
```

The async symbols require the optional `async` installation extra. The
synchronous symbols remain available without HTTPX.

Names that are not exported from `mlbstatsapi` are internal and may change
without a deprecation cycle. See [public-api.md](public-api.md) for the
complete stability classification.
Expand All @@ -48,8 +54,10 @@ mlb = mlbstatsapi.Mlb()
player = mlb.get_person(664034)
```

In version 1.0.0 that construction uses strict HTTP handling by default. The
client remains synchronous. Async support is not part of version 1.0.0.
Version 1.0.0 made strict HTTP handling the default for this construction.
That synchronous behavior is unchanged in 1.1.0, and existing synchronous
users require no code changes. Version 1.1.0 also provides the optional
`AsyncMlb` client; see [Async usage](async.md).

## Context manager

Expand Down Expand Up @@ -189,7 +197,7 @@ to the library's tested retry policy.

## User-Agent

Library-created Sessions send a package-specific User-Agent:
Library-created Sessions and async clients send a package-specific User-Agent:

```text
python-mlb-statsapi/<installed-version>
Expand All @@ -198,7 +206,7 @@ python-mlb-statsapi/<installed-version>
With the package version currently declared in project metadata that resolves to:

```text
python-mlb-statsapi/1.0.1
python-mlb-statsapi/1.1.0
```

The version comes from the installed package metadata, so it always matches
Expand All @@ -207,10 +215,10 @@ the installed release without a separately maintained version string.
Notes:

* The header helps identify package traffic while debugging
* Other Requests default headers such as `Accept-Encoding`, `Accept`, and `Connection` remain intact
* Other transport default headers remain intact
* Only `User-Agent` is set; the full header mapping is never replaced
* Caller-injected Sessions are never modified
* Applications using an injected Session may set their own User-Agent
* Caller-injected Sessions and HTTPX clients are never modified
* Applications using an injected Session or client may set their own User-Agent
* The header contains no machine identifiers, installation identifiers, hostnames, or user tracking data
* This is not telemetry and sends no analytics

Expand Down Expand Up @@ -243,12 +251,12 @@ finally:

## Default retry policy

Library-created Sessions mount a bounded retry policy for GET requests
automatically.
Library-created Sessions and async clients use a bounded retry policy for GET
requests automatically.

Caller-injected Sessions are never automatically reconfigured. Retry settings
on an injected Session remain under the caller's control unless the caller
opts in.
Caller-injected Sessions and HTTPX clients are never automatically
reconfigured. Retry settings on injected Sessions and clients remain under
the caller's control.

```text
Initial request: 1
Expand Down Expand Up @@ -638,7 +646,7 @@ Notes:
* `MlbTimeoutError` is a subtype of `MlbTransportError`
* All new errors inherit from `TheMlbStatsApiException`
* Existing broad exception handling remains valid
* Original Requests or JSON decoding failures are preserved through exception chaining
* Original Requests, HTTPX, or JSON decoding failures are preserved through exception chaining

## HTTP exception attributes

Expand Down Expand Up @@ -735,7 +743,8 @@ configured with its own proxy settings.

## Scope of this document

The retry, timeout, User-Agent, and strict-HTTP behavior documented above
apply to the synchronous `Mlb` client. For the asynchronous client, see
[async.md](async.md); it shares this document's retry, timeout, and
error-handling contract except where noted above.
The retry, timeout, User-Agent, strict-HTTP, and error-handling contract applies
to both `Mlb` and `AsyncMlb`. Session-specific sections describe the
synchronous Requests transport; `AsyncMlb` uses a caller-owned or
library-created HTTPX client with the corresponding ownership rules. See
[async.md](async.md) for async lifecycle, concurrency, and client injection.
69 changes: 69 additions & 0 deletions docs/releases/1.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# python-mlb-statsapi 1.1.0

Version 1.1.0 adds first-class asynchronous access to the MLB Stats API while
preserving the existing synchronous API. Applications upgrading from 1.0.x
that use `Mlb` or `MlbDataAdapter` require no code changes.

## Async support

Install the optional `async` extra to add HTTPX, the asynchronous transport
dependency:

```bash
python3 -m pip install "python-mlb-statsapi[async]"
```

The extra provides the public `AsyncMlb` and `AsyncMlbDataAdapter` classes.
`AsyncMlb` covers the full endpoint surface exposed by `Mlb`. Sync and async
endpoints share the same parsing functions and return matching public Pydantic
models, values, and endpoint-specific empty-result shapes.

```python
from mlbstatsapi import AsyncMlb


async def get_player(person_id: int):
async with AsyncMlb() as mlb:
return await mlb.get_person(person_id)
```

`async with AsyncMlb(...)` returns the client and closes library-owned HTTPX
resources when the block exits. Directly constructed clients support explicit
`await mlb.aclose()`, and repeated `aclose()` calls are safe. An injected
`httpx.AsyncClient` remains caller-owned and is never closed or reconfigured by
`AsyncMlb`.

One `AsyncMlb` instance supports caller-controlled concurrent requests on the
same event loop. It does not create hidden request fanout or background tasks,
and cross-event-loop use is not promised. Caller cancellation propagates
without blocking unrelated concurrent requests.

Library-created HTTPX clients honor `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`,
and `NO_PROXY` from the environment while retaining the library's bounded
retry policy. Injected clients keep their caller-provided proxy and transport
configuration.

## HTTP compatibility

`strict_http=True` remains the default for both synchronous and asynchronous
clients. New code should use `strict_http=True` and handle `MlbHttpError`.

`strict_http=False` remains supported throughout the 1.x release series and
may be removed in 2.0. It continues to provide the documented compatibility
path for final non-404 4xx responses; it is not removed or deprecated in
1.1.0.

The base installation remains synchronous-only and does not require HTTPX.
Existing 1.0.x synchronous users require zero code changes for 1.1.0.

## Python and release validation

python-mlb-statsapi requires Python >=3.10. CI validates Python 3.10 through 3.14
(`3.10`, `3.11`, `3.12`, `3.13`, and `3.14`) for the deterministic offline sync
and async suites.

Release validation now checks both wheel and source-distribution installs in
separate clean environments. Each artifact retains its existing synchronous
smoke validation and is also installed with the `async` extra to verify the
public async imports, lifecycle, ownership, strict/compatibility behavior, and
versioned User-Agent without contacting the live MLB API.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "python-mlb-statsapi"
version = "1.0.1"
version = "1.1.0"
description = "mlbstatsapi python wrapper"
authors = [
"Matthew Spah <spahmatthew@gmail.com>",
Expand Down
Loading
Loading