Skip to main content

Client-side WHATWG fetch for hayate: the same Request/Response types, pointed outward

Project description

hayate-fetch

Client-side WHATWG fetch for hayate: the same Request/Response types your server handles, pointed outward.

Status: alpha (0.1.x). fetch(), the FetchBackend protocol, and the CPython and Cloudflare Workers backends are implemented and used by hayate-auth for OAuth token exchange. The design memo (Japanese, per project convention) lives in DESIGN.md.

Install

uv add hayate-fetch        # or: pip install hayate-fetch

Use

from hayate_fetch import fetch

response = await fetch(
    "https://api.example.com/books",
    method="POST",
    headers={"content-type": "application/json"},
    body='{"title":"Standards first"}',
)

if response.ok:
    book = await response.json()

Pass a prebuilt hayate Request when that is already the natural object:

from hayate import Request
from hayate_fetch import fetch

response = await fetch(Request("https://api.example.com/health"))

HTTP error statuses resolve to a Response; network failures raise OSError. Responses are buffered in the public 0.1 contract. Redirects follow by default, or use UrllibBackend(redirect="manual") to surface the redirect response.

Backends

  • CPython: UrllibBackend uses the standard library through asyncio.to_thread, so the package adds no HTTP dependency.
  • Cloudflare Workers: WorkersBackend passes through to the platform's JavaScript fetch.
  • Custom clients: implement the async FetchBackend.send(Request) -> Response protocol and pass it as backend=.

The default backend is selected from the runtime. Browser-only Fetch fields such as mode, credentials, and cache are intentionally outside the server-side subset.

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

hayate_fetch-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

hayate_fetch-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file hayate_fetch-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for hayate_fetch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 557b98ee300d90543af2a2f543e6f72c322b7a421f7d6263c8f32fd48eaec23f
MD5 114a7b782b2010dd6919a75086ff6b80
BLAKE2b-256 e7839025d8a3e227073cb2748664a52e9d87fff04ee3fef3b89ea9a8e2df3537

See more details on using hashes here.

Provenance

The following attestation bundles were made for hayate_fetch-0.1.1.tar.gz:

Publisher: release.yml on hayatepy/hayate-fetch

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

File details

Details for the file hayate_fetch-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for hayate_fetch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d56ddd3cddc136d5c260e8d2c887ef3cd0256bafcb16b496b292bb2bfe7d0537
MD5 d2cf84f5610eb2c86c384d766afb6e52
BLAKE2b-256 8241f2ad93702aa82f4aaf6ebc3292f1614c6933a2e00c6ca395f667552d3e9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for hayate_fetch-0.1.1-py3-none-any.whl:

Publisher: release.yml on hayatepy/hayate-fetch

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