Skip to main content

A lightweight HTTP client with retry and form/JSON support

Project description

HTTP Client

A lightweight, chainable HTTP client for Python that supports automatic retries, custom retry callbacks, and easy JSON or form submissions.

Features

  • Simple and expressive chainable API
  • Built-in retry support with customizable retry callbacks
  • Automatic JSON and form data handling
  • Fully testable with responses
  • No heavy dependencies — designed to be minimal and easy to extend

Usage

  1. Basic GET request
from event_scale_http_client import Http

response = Http().get("http://127.0.0.1:7000/", {
    "name": "Alex"
})
print(response.status_code)
print(response.json())
  1. Automatic retries with callback

You can define how many times the request should retry and handle each failed attempt with a callback:

from event_scale_http_client import Http


def retry_callback(attempt, error):
    print(f"Attempt {attempt} failed due to: {error}")


(
    Http()
    .retry(3, retry_callback)
    .get("http://127.0.0.1:7000/")
)

Explanation:

  • retry(3, callback) → retries up to 3 times if the request fails.
  • The callback function receives two arguments: attempt → current attempt number (starting at 1) error → the exception or status that caused the failure
  1. POST request with JSON body
from event_scale_http_client import Http

data = {
    "name": "Bedram",
    "email": "tmgbedu@gmail.com"
}

response = Http().post("http://127.0.0.1:7000", data)
print(response.status_code)
  • Sends JSON data by default (Content-Type: application/json).
  1. POST request as form data
from event_scale_http_client import Http

(
    Http()
    .asForm()
    .post("http://127.0.0.1:7000", {
        "name": "Bedram",
        "email": "tmgbedu@gmail.com"
    })
)
  • Sends data as application/x-www-form-urlencoded.
  • Automatically encodes form fields.

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

event_scale_http_client-0.1.1.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

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

event_scale_http_client-0.1.1-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file event_scale_http_client-0.1.1.tar.gz.

File metadata

  • Download URL: event_scale_http_client-0.1.1.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.8 Darwin/23.5.0

File hashes

Hashes for event_scale_http_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 68433f830f5abf8f36f3a9bfb66e6a55b57787dd52d8bbeb0efc45e6b8303e5b
MD5 edaf0ee407f4520fed0706d18a962030
BLAKE2b-256 7536ce582a0b9e4e20624161b2a0360c8f070ffc6b256fff978a41ba659e7df5

See more details on using hashes here.

File details

Details for the file event_scale_http_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for event_scale_http_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 514c1d6b933f1417ac59f1a4a572d2f9724ab40c46ad6d22932aba5fd2c921b0
MD5 5794ecb590dda85be90a7d75c217c3de
BLAKE2b-256 a12377c7a24138a8e49f5d23e4a2253643f6d098dbda1eb691323d6e65737807

See more details on using hashes here.

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