Python hosted quickstart
Call the hosted positions endpoint from Python without claiming a native Python engine.
Engine 1.0.0: On npm. Archive identity and release status.
Use the HTTP boundary
This uses Python's standard HTTP and JSON libraries to call the hosted service. It does not import a native Python port of the engine. The request dates and bodies are the service's committed synthetic example.
Calling the service sends the request to Zodiacs infrastructure. Use the local TypeScript engine when an application needs calculation without that transfer.
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
body = {
"instants": ["2026-09-29T12:00:00Z", "2026-12-31T00:00:00-05:00"],
"bodies": ["Sun", "Moon", "Mercury"],
}
origin = os.environ.get("ZODIACS_COMPUTE_ORIGIN", "https://zodiacs.org")
request = Request(
origin.rstrip("/") + "/api/v1/positions",
data=json.dumps(body).encode("utf-8"),
headers={"Content-Type": "application/json"},
method="POST",
)
try:
with urlopen(request, timeout=15) as response:
result = json.load(response)
print(json.dumps(result))
except HTTPError as error:
failure = {
"status": error.code,
"retryAfter": error.headers.get("Retry-After"),
"response": json.loads(error.read().decode("utf-8")),
}
print(json.dumps(failure), file=sys.stderr)
sys.exit(1)
except URLError:
print("Request failed; check connectivity before retrying.", file=sys.stderr)
sys.exit(1)Failures and receipts
The example preserves the HTTP error status, response envelope and Retry-After, and exits with status 1 on failure. It uses a finite 15-second socket timeout. Never log private chart inputs. ZODIACS_COMPUTE_ORIGIN can point to a local mock during development.
No credentials are required by this example. Current service availability and limits are documented on the Compute API page.











