Cosmic Ephemeris Python SDK
The official synchronous Python client for the Cosmic Ephemeris calculation API.
- 78 calculation methods
- Python 3.10 or newer
- Typed inputs and route-specific response envelopes
- No required runtime dependencies
- Bounded transport concurrency, responses, and deadlines
- Sanitized errors and no automatic retries
Install
python -m pip install cosmicephemeris-client
Optional signed-receipt verification uses cryptography:
python -m pip install "cosmicephemeris-client[receipts]>=0.4.0"
Compatibility
Version 0.4.0 adds explicit historical requests for all 77 date-bearing operations and BCE-safe date/time helpers. Use 0.4.0 or newer for the historical examples below; earlier packages do not include these helpers.
Version 0.3.3 accepts the current status returned by all 78 calculation contracts. Upgrade before deploying the matching server contract; 0.3.2 strictly expects the former status value on promoted routes and can reject otherwise valid responses.
Quick start
from cosmicephemeris_client import (
CosmicEphemerisClient,
HTTPError,
RequestTimeoutError,
)
client = CosmicEphemerisClient() # Reads COSMICEPHEMERIS_KEY.
try:
result = client.birth_chart({
"date": "1990-01-01",
"time": "12:00",
"timezone": "America/New_York",
"lat": 40.7128,
"lon": -74.006,
})
print(result["chart"]["planets"]["Sun"])
except HTTPError as error:
print(error.status, error.retry_after)
except RequestTimeoutError:
print("The deadline expired; admitted work may still consume quota.")
You may pass api_key= explicitly. An explicit key takes precedence over
COSMICEPHEMERIS_KEY.
API keys are server credentials. Never put them in browser code, mobile applications, URLs, public environment variables, analytics, notebooks intended for sharing, or source control.
Methods and typing
Methods use Python snake case and map directly to the documented REST operations. They return the complete response dictionary without changing its envelope.
The package is marked with py.typed. Every public method has a documented input
TypedDict and a route-specific response type derived from the maintained OpenAPI
contract. Selected complex responses have additional hand-maintained nested types.
Common groups include:
- Natal charts, houses, aspects, transits, synastry, composite, and Davison charts
- Vedic Vargas, Vimshottari, Panchang, Ashtakoota, and Ashtakavarga
- Moon phases, planetary events, aspect windows, eclipses, and event calendars
- SVG, PNG, reports, and structured export formats
- Place search, timezone resolution, relocation, and astrocartography
- Convention, uncertainty, robustness, and electional audit operations
Use the full calculation reference, copy-paste API examples, and OpenAPI document for every operation's exact request and response contract. The developer platform guide owns shared authentication, quota, job, and integration rules.
Transport and deadlines
The client:
- Validates the API key and documented input boundaries before transport.
- Uses verified HTTPS and sends credentials only to the configured origin.
- Ignores proxy environment variables, cookies, and redirects.
- Allows HTTP only through explicit loopback-only test configuration.
- Bounds request size, response size, and outstanding transport workers.
- Rejects compressed, malformed, truncated, duplicate-key, and non-finite JSON.
- Does not retry automatically.
Default deadlines vary by operation. They can be bounded with timeout=,
planetary_events_timeout=, aspect_windows_timeout=, and timeline_timeout= when constructing the
client. A timeout may still consume quota if the gateway already accepted the work.
Methods outside the longer route groups use a 20-second default deadline.
Version 0.3.3 gives event_calendar the 35-second planetary-event deadline for
its 30-second engine budget. planetary_events_timeout= configures that route
group. The client deadline is a safety bound, not a response-time promise.
Errors
Errors expose only safe structured information. They do not include API keys, request payloads, response bodies, raw headers, URLs, or underlying transport exception details.
The primary classes are:
ValidationErrorHTTPErrorRequestTimeoutErrorClientBusyErrorTransportErrorResponseError
Signed calculation receipts
from cosmicephemeris_client import verify_calculation_receipt
valid = verify_calculation_receipt(response, public_jwk)
Receipt verification requires the optional receipts dependency. It checks the
Ed25519 signature and canonical hashes. It proves response integrity and service
provenance; it does not independently validate the meaning or correctness of a
calculation.
Local verification
From clients/python:
python scripts/generate_response_types.py --check
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src python -m unittest discover -s tests -v
python -m build
Tests use synthetic credentials and local HTTP/TLS servers. They do not call the production API unless an example is deliberately run with a real key.
Support and license
- Calculation reference: https://cosmicephemeris.com/docs.html
- API examples: https://cosmicephemeris.com/docs-api-examples.html
- OpenAPI: https://cosmicephemeris.com/openapi.json
- Developer platform: https://cosmicephemeris.com/docs-developer-platform.html
- Support: support@cosmicephemeris.com
- License: ISC
Explicit historical calculations — 0.4.0
These examples require version 0.4.0 or newer, not PyPI 0.3.3. The package keeps standard methods, response envelopes, deadlines and no-retry behavior.
All 77 date-bearing operations accept 1000 BCE (BC)–2500 CE (AD) through the historical method; place-search has no date input. See the public OpenAPI historical schemas; repository maintainers also use contracts/historical-integration.json. Modern string dates retain their existing 1800–2200 contract. Birth-chart responses retain chart; other historical responses retain their original input and put the adapter output in result.
Every historical date specifies year, era, month, day, and calendar; timed inputs also require UT1 or a fixed UT1 offset. Never convert BCE through a native JavaScript Date or Python datetime. Numerology requires year_convention set explicitly to displayed_year_digits or astronomical_year_digits, and an optional personal year is {year, era}. Its metadata uses time_standard: "not_applicable". Ancient city timezones are not inferred. Search windows, undefined polar geometry, model uncertainty and export limitations remain explicit.
from cosmicephemeris_client import CosmicEphemerisClient, normalize_historical_datetime
api = CosmicEphemerisClient() # Server-side COSMICEPHEMERIS_KEY.
at = normalize_historical_datetime({
"date": {"year": 1000, "era": "BCE", "month": 1, "day": 1, "calendar": "proleptic_julian"},
"time": "12:00", "timezone": "UT1",
})
birth = {**at, "lat": 28.6, "lon": 77.2}
chart = api.historical("birth-chart", birth)
print(chart["chart"]["planets"]["Sun"])
phases = api.historical("moon-phases", {
"mode": "calendar", "start": at,
"end": {**at, "date": {**at["date"], "day": 2}}, "include_ical": False,
})
print(phases["result"]) # Historical UT1 records, not fabricated UTC strings.
Each call can consume quota; examples are not run by installation. Historical UT1 calendars do not support iCalendar; use supported JSON/CSV outputs. SDK transport does not certify astronomical accuracy: retain response warnings and read the accuracy evidence. Account-session readings/Tarot are separate products, not extra API-key SDK methods.
Metadata
Release files for cosmicephemeris-client 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cosmicephemeris_client-0.4.0.tar.gz | 84.3 kB | With provenance | Details for cosmicephemeris_client-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cosmicephemeris_client-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for cosmicephemeris_client-0.4.0-py3-none-any.whl |
Total release size: 139.0 kB
Release files / cosmicephemeris_client-0.4.0.tar.gz
| Download URL | cosmicephemeris_client-0.4.0.tar.gz |
|---|---|
| Size | 84.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75be2e3d157516da93b3854dfeb5249b42bbf9438f70138a2536af0d014acbcc
|
|
BLAKE2b-256 checksum How to use checksums |
832b9bdfd3a1a0236bdc1aea6fafa70d58b976d040b62ae82f0b37f2ebf592d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / cosmicephemeris_client-0.4.0-py3-none-any.whl
| Download URL | cosmicephemeris_client-0.4.0-py3-none-any.whl |
|---|---|
| Size | 54.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
856827cb3167eeb42d540822de7f7dfef3eca7cff45dbe7f627d485a7413cbb7
|
|
BLAKE2b-256 checksum How to use checksums |
2c869f2fb824de7d440184542090982588079d4c824ad919d43d391aaa98ed66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logSecurity for cosmicephemeris-client 0.4.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cosmicephemeris_client-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logA 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.