Orionis HTTP Client
Use Http to read data from another application, create a resource, update it or delete it. Select the destination, await the request and read its response. The examples below use a product catalog.
Make your first request
Section titled “Make your first request”Save this function in app/services/catalog_lookup.py in your Orionis project. If you are creating the services package, add an empty app/services/__init__.py. A controller or command can call await fetch_product(42) once the catalog profile is configured below.
from orionis.support.facades import Http
async def fetch_product(product_id: int): catalog = Http.client("catalog").acceptJson() response = await catalog.get(f"/products/{product_id}") return response.throw().json()client("catalog") selects the provider and acceptJson() sets the Accept header. get() sends GET /products/42. If the API returns 200 with {"data":{"id":42,"name":"Desk lamp"}}, the function returns that document as a Python dictionary. throw() raises on a 4xx or 5xx response. Read responses and handle failures
Choose a request method
Section titled “Choose a request method”Inside an async function, prepare the client and sample product. This catalog uses JSON Merge Patch for partial updates. Each table row is a separate call. Follow the method link for a full example of what goes on the wire and how to read the response.
from orionis.support.facades import Http
catalog = Http.client("catalog")product = {"sku": "NB-42", "name": "Notebook", "stock": 8}merge_patch = {"Content-Type": "application/merge-patch+json"}| I want to… | Method and example |
|---|---|
| List the second page of products | GET · await catalog.get("/products", params={"page": "2"}) |
| Create a product | POST · await catalog.post("/products", json=product) |
| Replace a product | PUT · await catalog.put("/products/42", json=product) |
| Change just the stock | PATCH · await catalog.patch("/products/42", json={"stock": 5}, headers=merge_patch) |
| Delete a product | DELETE · await catalog.delete("/products/42") |
| Read the headers without downloading a body | HEAD · await catalog.head("/products/42") |
| Discover which operations the server advertises | OPTIONS · await catalog.options("/products") |
| Search with a body when the API supports it | QUERY · await catalog.query("/products", json={"in_stock": True}) |
If your application chooses the verb at runtime, pass it explicitly, for example await catalog.send("GET", "/products/42"). Use the generic sender
Choose how to send the data
Section titled “Choose how to send the data”Use params= for values in the URL, such as filters and page numbers. Use json= for JSON, data= for an HTML-style form, or content= for raw bytes. The server determines the format. You can combine URL parameters with one body format in the same call. Examples of each format, headers and authentication
Configure the destination
Section titled “Configure the destination”From the root of an Orionis 1.10.0 application with Python 3.14 or later, run this command if config/http_client.py is missing. In an existing file, edit the corresponding fields. Install Orionis
uv run python -B reactor bootstrap:config http_clientfrom dataclasses import dataclass, field
from orionis.foundation.config.http_client import HttpClientConfig
@dataclass(frozen=True, kw_only=True)class BootstrapHttpClient(HttpClientConfig): allowed_origins: tuple[str, ...] = ("https://catalog.example.com",) clients: dict[str, dict] = field( default_factory=lambda: {"catalog": {"base_url": "https://catalog.example.com"}} )allowed_origins lists the HTTPS origins your application may contact. clients gives one of them the name catalog. The default allowlist is empty. Use the example hostname with the test below. For a live integration put your provider’s origin in both fields, choose a route it serves and restart the application process. Profiles, ports and limits
Run the first request without a provider account
Section titled “Run the first request without a provider account”Save this test in tests/test_http_client.py. It calls the function you wrote above and supplies the response the catalog would return. A mistake in the HTTP method or URL causes the test to fail.
from app.services.catalog_lookup import fetch_productfrom orionis.support.facades import Httpfrom orionis.test import TestCase
class TestCatalog(TestCase): async def test_fetch_product(self) -> None: url = "https://catalog.example.com/products/42" fixtures = {("GET", url): Http.response({"data": {"id": 42, "name": "Desk lamp"}})}
async with Http.fake(fixtures) as fake: product = await fetch_product(42) self.assertEqual(product["data"]["name"], "Desk lamp") fake.assertSentCount(1)uv run python -B reactor test --start-dir tests --file-pattern test_http_client.py --no-panelExpect one passing test. If Reactor discovers zero tests, check the file and method names. For HttpConfigurationException, check that the profile exists. For HttpDestinationException, check the HTTPS origin and that the bound path starts with /. Test additional scenarios
Use the client in your application
Section titled “Use the client in your application”- Application integrations — use the same service in a controller, a command, a queue job or a script.
- Concurrency and lifecycle — bound concurrent calls and deadlines, handle cancellation and close resources.
- Integration recipes — paginate, use ETags, upload small files or handle rate limits.
The API reference lists signatures, accepted types and return values. IHttpManager · PendingRequest · ClientResponse