Skip to main content

httpee

httpee is a thin wrapper around fetch.py (by Kenneth Reitz). It uses the Eel dialect of Python.

Eel adds two features to Python — assert patterns and pipelines — and = can break onto the next line:

# assert pattern — checks the shape and binds names; failure → MatchError
# you can use anything you would use with match..case
assert Point(x, y) = get_point()

# pipeline — the value flows into the call as the last argument
squares =
    [1, 2, 3]
    ..map(lambda x: x * x)

A request is a pipeline of httpee verbs and modifiers:

from httpee import GET, httpee, Response

resp =
    httpee()
    ..GET:
        'https://api.example.com/users'
    ..assert:
        Response(status=200)

Installation

pip install httpee

Requires Python 3.15+ (eelang 0.1.6+ to run the bare-pipeline .eel examples). No external dependencies — fetch.py (MIT © Kenneth Reitz) is vendored inside as httpee/_fetch.py. Works with regular Python and with gevent (gevent.monkey.patch_all()).

Cheatsheet

A request is a pipeline

httpee()
..data: {'name': 'kenneth', 'role': 'admin'}  # mapping → form-encoded
..headers: {'X-Key': v}                  # headers (repeats add keys)
..query: {'page': 2}                     # query parameters (repeats add keys)
..POST: 'https://api.example.com/users'  # verb performs the request
..assert:
    Response(status=201)                 # failure → MatchError

Bodies

Every request starts with httpee(); the body goes through ..json: or ..data:. They are mutually exclusive — using both raises ValueError.

Modifier Value Sent as
— httpee() empty request — no body
..json: any JSON value application/json
..data: mapping form-encoded (data=, like requests)
..data: str text (text/plain; charset=utf-8)
..data: bytes raw bytes (application/octet-stream)

Dynamic method — ..fetch()

httpee()
..data: {'role': 'moderator'}
..method: m                          # any method, even from a variable
..url: 'https://…'
..fetch()                             # without ..method: defaults to GET
..assert:
    Response(status=200)

Pattern checks

# ..assert: — shape check, binds variables, failure → MatchError
httpee()
..GET: url
..assert:
    Response(status=s)               # s is available afterwards

# ..match: — branch on status; no match → the value is unchanged
httpee()
..GET: url
..match:
    case Response(status=200): 'ok'
    case Response(status=n): f'HTTP {n}'

Errors

  • 4xx/5xx do not raise: check the status with a pattern.
  • ..json: together with ..data: raises ValueError.
  • Network errors and timeouts are fetch.py exceptions (RequestError, Timeout).
  • Response is fetch.py's Response (it has a status field): .json(), .text, .headers work as usual.

Modifiers at a glance

..headers: · ..query: · ..timeout: 5.0 · ..json: · ..data: · ..method: · ..url:

How it works

  • Every request starts with httpee(). The body goes through ..json: (JSON) or ..data: (mapping → form-encoded, str → text, bytes → raw bytes); the two are mutually exclusive.
  • Modifiers accumulate parameters (repeatable, in any order); the verb at the end performs the request and returns a Response.
  • 4xx/5xx do not raise — the status is checked with a pattern; a failed ..assert: raises MatchError. Network errors and timeouts are fetch.py exceptions.
  • Redirects are followed (up to 10), as in fetch.py.

Verbs

Verb Example What it does
GET … OPTIONS ..GET: url performs the request with this method
fetch ..fetch() performs the request with a previously set ..method:/..url:

The method can be set up front — and can be anything:

httpee()
..data: {'role': 'moderator'}
..method: 'PATCH'                          # or from a variable
..url:
    'https://api.example.com/users/1'
..fetch()
..assert:
    Response(status=200)

Modifiers

Modifier Example What it does
headers ..headers: {'X-Key': v} headers (repeats add keys)
query ..query: {'page': 2} URL query parameters (repeats add keys)
timeout ..timeout: 5.0 request timeout, seconds (default 30)
json ..json: {…} JSON body (exclusive with ..data:)
data ..data: {…} / 'text' / b'…' body: mapping → form, str → text, bytes → raw
method ..method: 'PATCH' method up front — for ..fetch()
url ..url: 'https://…' URL up front — for ..fetch()

Tests

python -m unittest discover -s tests

License

MIT (LICENSE).

Metadata

Release files for httpee 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for httpee 0.3.0
File Size Uploaded Provenance Actions
httpee-0.3.0.tar.gz 20.5 kB Without provenance Details for httpee-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for httpee 0.3.0
File Interpreter ABI Platform Actions
httpee-0.3.0-py3-none-any.whl Python 3 none any Details for httpee-0.3.0-py3-none-any.whl

Total release size: 36.3 kB

Release files / httpee-0.3.0.tar.gz

Download URL httpee-0.3.0.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8ed2ccf1b866ef1526d2390ca44b268633abaf3d07013aacaf973143ce377f5f
BLAKE2b-256 checksum
How to use checksums
62952952382d51bc628fba1dfc6585602e75ab9226beaa99539b6722fe5d46de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / httpee-0.3.0-py3-none-any.whl

Download URL httpee-0.3.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9c789e155c6164ac43616e9d2d345f93c5644b1c4b37e78e8785a2e09eb1805
BLAKE2b-256 checksum
How to use checksums
a99cb56b8aed57fd44d396cc97aa1abaddfa8b4adc00241da4a3cede920b0a3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Security for httpee 0.3.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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