Skip to main content

hayate-fetch

Hayate ecosystem: Start here · Production golden app · Tested compatibility

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

Status: alpha (0.1.x), typed. 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; release history is in CHANGELOG.md.

Install

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

For pooled asynchronous CPython requests, install the optional HTTPX backend:

uv add "hayate-fetch[httpx]"

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 pass default_backend(redirect="manual") to surface redirects consistently on CPython and Workers.

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.
  • HTTPX (optional, CPython): HttpxBackend adapts an application-owned httpx.AsyncClient, preserving its connection pool, timeout, TLS, proxy, and optional HTTP/2 configuration.
  • Custom clients: implement the async FetchBackend.send(Request) -> Response protocol and pass it as backend=.

Keep one HTTPX client for the application lifetime rather than constructing it inside a hot request loop:

import httpx

from hayate_fetch import fetch
from hayate_fetch.httpx import HttpxBackend

async with httpx.AsyncClient() as client:
    response = await fetch(
        "https://api.example.com/books",
        backend=HttpxBackend(client),
    )

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: hayate_fetch-0.2.0.tar.gz
  • Upload date:
  • Size: 5.7 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.2.0.tar.gz
Algorithm Hash digest
SHA256 9a7844a1af480d416a4d066ddc4a46418d0d6c2523931f6658e53bed6eca94ea
MD5 efef2be898076cdc7adf9ad67b89f448
BLAKE2b-256 9732684ff144735b5f1b7dee95cbd0682a03a529d4fb799fd43e8466122001e4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: hayate_fetch-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7febf5a418a025a31ebf31443fe7d751c2d6f9ce1d35dec34c2feedf5532f132
MD5 d58b5f23969bc1c0c6fe3e9767713c96
BLAKE2b-256 bbbf4b8311a035bf8b73aaa6babfb94195740b16762d6ea2120f60159d26b115

See more details on using hashes here.

Provenance

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

Release history Release notifications | RSS feed

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page