Skip to main content

httpee

httpee is a thin wrapper around httpx for eelang: requests are written as pipelines, responses are checked with patterns.

from httpee import POST, headers, httpee, Response

user =
    {'name': 'kenneth', 'role': 'admin'}      # dict → form-encoded, like requests data=
    ..headers: {'Authorization': f'Bearer {token}'}
    ..POST: 'https://api.example.com/users'
    ..assert:
        Response(status=201)

page =
    httpee()                                  # empty request — no body
    ..query: {'page': 2}
    ..GET: 'https://api.example.com/users'
    ..assert:
        Response(status=200)

Cheatsheet

from httpee import (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, send,
                    httpee, headers, query, timeout, cookies, auth, json,
                    method, url, Response)
from eelang import MatchError

A request is a pipeline

r =
    {'name': 'kenneth', 'role': 'admin'}     # dict → 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

Value Sent as
dict form-encoded (data=, like requests)
str text
bytes raw bytes
httpee() empty request — no body
..json: {…} JSON — takes precedence over the pipeline body

Dynamic method — ..send()

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

Pattern checks

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

# ..match: — branch on status; no match → the value is unchanged
verdict =
    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.
  • Network errors and timeouts are httpx exceptions (ConnectError, TimeoutException).
  • Response is httpx.Response plus .status: .json(), .text, .headers work as usual.

Modifiers at a glance

..headers: · ..query: · ..timeout: 5.0 · ..cookies: · ..auth: (u, p) · ..json: · ..method: · ..url:

How it works

  • The pipeline's initial value is the request body: dict → form-encoded, str → text, bytes → raw bytes. JSON goes through an explicit ..json: {…}. A request without a body starts with httpee().
  • 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 httpx exceptions.

Verbs

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

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

patch =
    {'role': 'moderator'}
    ..method: 'PATCH'                          # or from a variable
    ..url: 'https://api.example.com/users/1'
    ..send()
    ..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
cookies ..cookies: {'sid': v} cookies
auth ..auth: ('user', 'pass') basic auth (any httpx.Auth works)
json ..json: {…} JSON body (takes precedence over the pipeline body)
method ..method: 'PATCH' method up front — for ..send()
url ..url: 'https://…' URL up front — for ..send()

Installation

pip install httpee

From source:

git clone https://github.com/eel-lang/httpee
pip install ./httpee

Requires CPython 3.15 + eelang to run .eel files — the package itself is plain Python, and httpx is its only dependency. Works under gevent (gevent.monkey.patch_all()).

Tests

python -m unittest discover -s tests

License

MIT (LICENSE).

Metadata

Release files for httpee 0.1.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.1.0
File Size Uploaded Provenance Actions
httpee-0.1.0.tar.gz 9.6 kB Without provenance Details for httpee-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 15.6 kB

Release files / httpee-0.1.0.tar.gz

Download URL httpee-0.1.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bd39f2446e8c9ad7a90a13f5be5457c50c5296c202e78e0a7be028aa8040e1f4
BLAKE2b-256 checksum
How to use checksums
0ae3cbcaacdfa344cfb819658c9052735ef98a7346b3b33ac8ea3305d028c3a1
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.1.0-py3-none-any.whl

Download URL httpee-0.1.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7702235611df5abf48549e5d9b2efaf1296eecb82cc79cb84e3fec263ccdc33d
BLAKE2b-256 checksum
How to use checksums
9bbaba76f4264f6ed0ecc04d8ee686aaf4a84f609ed58cc2521605b4a4991704
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.1.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