chumicro-requests
A non-blocking HTTP/1.1 client that keeps your LED blinking through a TLS handshake.
A requests-flavored surface that advances one chunk per runner tick (connect, send, recv, parse), so your control loop never stalls waiting for a peer. It covers plain HTTP and HTTPS (live-verified on real boards), the POST / PUT / PATCH / DELETE verbs with a JSON helper, redirect handling, and Transfer-Encoding: chunked decode. For bodies bigger than RAM, stream=True reads a firmware image into a 512-byte buffer one chunk at a time.
Part of the ChuMicro family: small, focused Python libraries for microcontrollers and laptops. Browse all libraries.
Install
# CircuitPython (after `circup bundle-add ChuMicro/ChuMicro-Bundle-Experimental`)
circup install chumicro_requests
# MicroPython
mpremote mip install github:ChuMicro/ChuMicro-Bundle-Experimental/chumicro_requests
# CPython
pip install chumicro-requests-experimental
For bundle setup, pre-compiled .mpy bundles, the experimental channel, and details on PyPI naming, see the ChuMicro install guide.
Quick example
from chumicro_requests import HttpClient
from chumicro_sockets.sockets_factory import connector_factory
from chumicro_timing import ticks_ms
client = HttpClient(transport_factory=connector_factory())
handle = client.get("http://api.example.com/now", timeout_ms=5000)
while not handle.done:
if client.check(ticks_ms()):
client.handle(ticks_ms())
response = handle.result # raises HttpError on failure
print(response.status_code) # 200
print(response.headers["content-type"])
print(response.body) # raw response bytes
print(response.text) # decoded str (charset sniffed from Content-Type)
print(response.json()) # parsed JSON when Content-Type is application/json
What's included
| Symbol | Purpose |
|---|---|
HttpClient |
Runner-shaped HTTP/1.1 client; check(now_ms) / handle(now_ms); per-verb methods plus generic request(...); stream=True for incremental bodies; cancel() aborts in flight. |
RequestHandle |
Per-request handle: .done, .result, .error; .read_body_into(buffer) drains a streamed body. |
Response |
Status code, reason, headers, raw body, URL; .text, .json(), .encoding; .streamed on streamed exchanges. |
chumicro_requests.generators |
Opt-in submodule: yield from-shaped fetch / get / post / ... one-shots and stream + BodyReader for chunked body reads under Runner.add_generator. |
CaseInsensitiveDict |
Header dict with case-insensitive lookups. |
WhenOversized |
Policy enum for responses past max_body_bytes. |
chumicro_sockets.sockets_factory.connector_factory(...) |
Shared module: convenience connection-factory wired to chumicro-sockets. |
parse_url(url) |
URL → (scheme, host, port, path). |
parse_charset(content_type) |
Extract charset from a Content-Type header value. |
encode_request(...) |
Build raw HTTP request bytes. |
ResponseParser |
Streaming response state machine. |
HttpError + subclasses |
HttpBusyError, HttpTimeoutError, HttpProtocolError, HttpURLError, HttpOversizedError. |
chumicro_requests.testing.FakeHttpClient |
Host-only fake for downstream test suites. |
Where this fits
Depends on chumicro-sockets for TCP / TLS and chumicro-timing for ticks. Used directly in app code.
Platform support
Works on CPython, MicroPython, and CircuitPython. Pure Python, no native extensions.
Examples
| Example | What it shows |
|---|---|
periodic_get.py |
Periodic GET on a real CP/MP board. Brings wifi up, hits a configured URL every N seconds, prints status + body length, drives an LED-blink counter to verify the request never blocks the loop. Reads wifi + target URL from runtime_config.msgpack (chumicro-workspace) with a constants fallback. Cross-runtime (CP + MP). |
generator_fetch.py |
The generator surface: a straight-line yield from get(...) fetch driven by runner.add_generator, no callbacks or state polling. |
Wiring wifi credentials for examples
The board-side examples need wifi credentials to reach the network. periodic_get.py reads them (and its target URL) from a runtime_config.msgpack written by chumicro-workspace, and falls back to in-file placeholder constants you edit directly when no config file is deployed. The library itself never reads config: it takes a transport_factory and goes, so credential and config wiring stay in your application.
Contributing
Issues, bug reports, and pull requests are welcome, and so is "I ran it on this board and here's what happened", some of the most useful feedback a hardware project can get. Development happens in the ChuMicro repository, whose contributing guide covers setup and the test workflow.
Docs
📖 Stable docs · Experimental docs
Find this library
- PyPI: chumicro-requests
- Bundle: ChuMicro-Bundle (CircuitPython & MicroPython)
- Experimental bundle: ChuMicro-Bundle-Experimental
- Source: libraries/requests
License
Metadata
Release files for chumicro-requests-experimental 0.21.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| chumicro_requests_experimental-0.21.3.tar.gz | 69.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chumicro_requests_experimental-0.21.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 96.5 kB
Release files / chumicro_requests_experimental-0.21.3.tar.gz
| Download URL | chumicro_requests_experimental-0.21.3.tar.gz |
|---|---|
| Size | 69.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a72cd278b658eaffcead4515874375286b3d4d509f6765464b44a5720e33bc05
|
|
BLAKE2b-256 checksum How to use checksums |
e85e9497b3fcd75f91b4af09ce8867dbbe858f8ca9e06c0e491601964d049d30
|
| 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 Aug 23, 2026.
Transparency logRelease files / chumicro_requests_experimental-0.21.3-py3-none-any.whl
| Download URL | chumicro_requests_experimental-0.21.3-py3-none-any.whl |
|---|---|
| Size | 27.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
072f3a2b8c04b1db8557ecbc445443226c64caff3426acd5566972a37ec6f4be
|
|
BLAKE2b-256 checksum How to use checksums |
826d0b8c6c611b0377671367ee6561485df6dd677bee32261da9af7a4e535aab
|
| 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 Aug 23, 2026.
Transparency log