Skip to main content

Lightweight async HTTP client with automatic retry

Project description

httplite

Lightweight async HTTP client with automatic retry on transient errors. Built on httpx and tenacity.

Installation

pip install httplite

Quick start

import asyncio
from httplite import send_request

async def main():
    # Simple GET
    resp = await send_request("GET", "https://httpbin.org/get")
    print(resp.status_code)
    print(resp.json())

    # POST with JSON body
    resp = await send_request("POST", "https://httpbin.org/post", json={"key": "value"})
    print(resp.json())

    # Custom timeout (seconds)
    resp = await send_request("GET", "https://httpbin.org/delay/2", timeout=10)

asyncio.run(main())

Features

  • Async-first – uses httpx.AsyncClient under the hood.
  • Automatic retry – retries up to 3 times with exponential backoff on transient connection errors (httpx.RequestError). HTTP error status codes (4xx, 5xx) are not retried.
  • Configurable timeout – defaults to 30 seconds; override per request.
  • Minimal API – a single send_request() function. Any extra keyword arguments are forwarded directly to httpx.AsyncClient.request.

API

send_request(method, url, *, timeout=30.0, **kwargs)

Parameter Type Description
method str HTTP method (GET, POST, PUT, DELETE, etc.)
url str Target URL (must use http or https scheme)
timeout float Request timeout in seconds (default 30.0)
**kwargs Forwarded to httpx.AsyncClient.request (e.g. json, headers, params)

Returns: httpx.Response

Raises: ValueError if the URL scheme is not http or https.

Running tests

pip install -e ".[test]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

httplite-1.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

httplite-1.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file httplite-1.1.0.tar.gz.

File metadata

  • Download URL: httplite-1.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for httplite-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4d2ca7edd301c5d15cc845cb2cbbcfd24e61da07d48aa509841502af8f85449b
MD5 a7503ce369c19e3d3e0e4f4cf27f36da
BLAKE2b-256 438c5d7b75feefee63431ae746430dd136e69982e36795e1fc79d8853cef82d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for httplite-1.1.0.tar.gz:

Publisher: python-publish.yml on kejun91/httplite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file httplite-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: httplite-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for httplite-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 823c7b9ef896b82348280b44d0f68b54ff7cba74209c4c2a55446941e841d431
MD5 aeaf7c2427052426d7db9d83df879df7
BLAKE2b-256 549122ef053bd499aeef726e4eca9d5b925eadddfc5e50b94bb018b00f49bcec

See more details on using hashes here.

Provenance

The following attestation bundles were made for httplite-1.1.0-py3-none-any.whl:

Publisher: python-publish.yml on kejun91/httplite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page