Skip to main content

Overview

A client-side library that wraps server-side functions to enable RPC-style HTTP calls while allowing you to maintain control over HTTP requests.

Why?

Working across HTTP boundaries with a HTTP client and server introduces friction:

  1. Type information from the backend is lost — No type inference or validation for payloads and parameters sent in your HTTP requests
  2. Forced to rely on out-of-band documentation — All the information about the backend schema lives in OpenAPI/Swagger docs, where it's not visible in your editor.

Your client side code can now have descriptive type information and docstrings right in the editor!

Screenshot of editor with type information for a backend function

How it works:

  • Import server functions decorated with FastAPI/Flask on the client side
  • Wrap them with wrap_backend_call()
  • Call them as regular functions; the library translates calls into HTTP requests
  • Handle the HTTP responses as per usual

A simple default HTTP implementation is included, but you can substitute your own with retry logic, caching, error handling, logging, etc.

Here is an example:

from server import get_item 
from http_clientlib import set_default_configuration, wrap_backend_call
from http_clientlib.http import make_http_request

set_default_configuration(
   base_url="http://production.backend.com", http_request_function=make_http_request
)

# Wrap the backend function and invoke it to make a HTTP request
get_item_http = wrap_backend_call(get_item)
response = get_item_http(item_id=42, page=2)
print(response) # HTTPResponse

An example with a POST endpoint and request body

# POST request with Pydantic model for the request body 
create_item_http = wrap_backend_call(post_endpoint)
response = create_item_http(data=ItemData(id=1, name="A Box"))

# POST request using a dictionary directly
response = create_item_http(data={"id": 1, "name": "Sample Item"})
print(response)
@app.get("/items/{item_id}")
def get_item(item_id: int, page: int = 0) -> Annotated[dict, "GET /items/{item_id}"]:
   """A GET endpoint with both path and query parameters."""
   return {"item_id": item_id}


class ItemData(BaseModel):
   id: int
   name: str

@app.post("/items")
def post_endpoint(data: ItemData) -> Annotated[dict, "POST /items"]:
   """A POST endpoint that accepts a Pydantic model as the request body."""
   return {"message": f"Item {data} created"}

Benefits

  1. Type safety in the editor — Full type information available for IDE autocomplete and validation
  2. Endpoint schema visibility — Query params, path params, request body, headers, cookies are all immediately apparent in your code
  3. Docstring availability — Server function docstrings show up in the client IDE
  4. Code Generation not required — Additional tooling or auto-generated code Changes to server signatures are immediately caught on the client side.

Limitations

  1. Python-only — Works for a frontend/backend stack built in python
  2. Server code must be imported — Client needs access to server function definitions

Metadata

Release files for http_clientlib 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for http_clientlib 0.1.3
File Size Uploaded Provenance
http_clientlib-0.1.3.tar.gz 6.6 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 14.9 kB

Release files / http_clientlib-0.1.3.tar.gz

Download URL http_clientlib-0.1.3.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cdb255d49322e6d9060f22543659a13b281c1e10d28a84092437b9201854de23
BLAKE2b-256 checksum
How to use checksums
97d404b53457a80ad00a58ab5a620eaaf77d8de4e3d6c4f81d23062c1242eb4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.12

Release files / http_clientlib-0.1.3-py3-none-any.whl

Download URL http_clientlib-0.1.3-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d92010d30948a8eab36cc1d13d38420f5c379f50ba698641bc1767437068a72a
BLAKE2b-256 checksum
How to use checksums
94c4cfec11014ec3f1d76a6b8c1607175bc7f4675ed0db7ba9ee45184f14efb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.12

Security for http_clientlib 0.1.3

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