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.0.1.tar.gz (5.4 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.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for httplite-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4f545a6d146a19c069eae67be3b21530dacddeaed62ae8939c2c3c5d9bf70b1c
MD5 723ba3a0985ad996fc0bb87ccf293769
BLAKE2b-256 32fe4415cd52070199ef586e1c19123bfc5a2a62add0269f1277c277cc3197c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for httplite-1.0.1.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.0.1-py3-none-any.whl.

File metadata

  • Download URL: httplite-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c68597db8ecdd9e8bd670b217c9cde1df15e10c8684bb048ddb07acb9a95ae3
MD5 a731c521c91fe473538e053fe1c2e5d8
BLAKE2b-256 33dcfea09259b9c2c84972d619dbea458281299e401a5bb21f2f23083726920c

See more details on using hashes here.

Provenance

The following attestation bundles were made for httplite-1.0.1-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