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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for httplite-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d2c3a49101e578b46c93a02ed0965146dd3e14d2bcfa88a179868bc385669215
MD5 e7488c0140c7ff2cda4492b6db1d0fb4
BLAKE2b-256 19a185f93eb7b81aae53c410f41b2fd4622d22697981c8c9c7727f2cbe589c4a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: httplite-1.0.0-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.7

File hashes

Hashes for httplite-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b609e298c09c865f6dac82c49224caa41d026742ac5edb5e9eb07ec7202025f
MD5 dfd20edf579628a92a1f3a68bcb8a681
BLAKE2b-256 d1466c763710f8c39bb5e31d50e3794e69f0a22993f7e06cb0d5dd7f78650fec

See more details on using hashes here.

Provenance

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