This release is a pre-release and may not be stable for production use.
pyxpo-fetch
HTTP requests with streaming bodies for pyxpo apps, through the platform's own
networking. The API follows expo/fetch, which is the
WinterCG fetch.
pip install pyxpo-fetch
[tool.pyxpo]
modules = ["fetch"]
import json
from pyxpo_fetch import fetch, AbortController, FetchError
resp = await fetch("https://api.example.com/items", method="POST",
headers={"Content-Type": "application/json"}, body=json.dumps({"name": "pen"}))
if resp.ok:
item = await resp.json()
print(resp.status, resp.status_text, resp.headers.get("content-type"))
# Stream the body as it arrives (for example server-sent events or an LLM response).
resp = await fetch("https://example.com/stream")
async for chunk in resp.body: # bytes
...
# Stop a request, also while its body streams.
ctl = AbortController()
resp = await fetch(url, signal=ctl.signal)
ctl.abort() # pending awaits raise AbortError
fetch(url, *, method="GET", headers=None, body=None, redirect="follow", credentials="include", signal=None, timeout=None)
Returns a Response once the headers arrive. HTTP error statuses (404, 500) do not raise: check response.ok.
| Argument | Notes |
|---|---|
url |
http:// or https://. Plain HTTP needs the server allowed by the app (pyxpo apps allow local hosts). |
headers |
dict, list of pairs, or Headers. |
body |
str (sent as UTF-8, Content-Type defaults to text/plain;charset=UTF-8) or bytes. Not allowed for GET and HEAD. |
redirect |
"follow", "manual" (return the 3xx response) or "error" (raise FetchError on a redirect). |
credentials |
"include" sends and stores cookies; "omit" does neither. "same-origin" acts like "include". |
signal |
AbortController().signal. |
timeout |
Seconds. |
Errors: FetchError for network failures (no connection, DNS, TLS, timeout, refused redirect); AbortError
(a FetchError) when the signal aborts.
Response
| Member | Notes |
|---|---|
status, status_text, ok |
ok is true for 200-299. |
headers |
Headers: case-insensitive; get joins repeated values with ", "; get_set_cookie() lists Set-Cookie values. |
url, redirected |
The final URL, and whether a redirect led there. |
body |
Async iterator of bytes chunks. |
await text(), await json(), await bytes(), await array_buffer() |
Read the whole body. |
body_used |
The body can be read once. |
camelCase spellings work too (statusText, bodyUsed, arrayBuffer, getSetCookie).
Platforms
- iOS 15+:
URLSession. Cookies use the shared cookie store.URLSessionholds back the first 512 bytes of a body for MIME sniffing; streaming servers should sendX-Content-Type-Options: nosniff(or a type such astext/event-stream) so the first chunks arrive at once. - Android 7 (API 24)+: OkHttp 4.12. Cookies live in memory while the app runs. Adds the
INTERNETpermission. - Desktop:
urllibin a worker thread, with an in-memory cookie jar.
Metadata
Release files for pyxpo-fetch 0.1.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyxpo_fetch-0.1.0a1.tar.gz | 15.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyxpo_fetch-0.1.0a1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.0 kB
Release files / pyxpo_fetch-0.1.0a1.tar.gz
| Download URL | pyxpo_fetch-0.1.0a1.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8d877a37f7c030f34fcc0b08f097d9df27dca0885c1c8757f0de1c803061236
|
|
BLAKE2b-256 checksum How to use checksums |
ecaf96fc630278c777b1d78cd62d2cab3cc19e07b6e1f0ba2f7f3e9cbd24f118
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / pyxpo_fetch-0.1.0a1-py3-none-any.whl
| Download URL | pyxpo_fetch-0.1.0a1-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb4bb61c76332420821163747e949de94dd0024e69c599580f681f2dc31a8b49
|
|
BLAKE2b-256 checksum How to use checksums |
12d8aa8f9bf40c697a090679ce90169cc12a2660bf918831f951002d0b5a36cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency log