# Determinism: same input, same output

> If you cache results, store them, or test against them, you need to know when the API can give a different answer to the same question. The short version: only when you let it pick the time, or the randomness.

Source: https://astronode.dev/guides/deterministic-astrology-calculations · Updated: 2026-11-26

## The guarantee

The calculation engine has no randomness: the same input produces the same `data`, byte for byte. The engine's own test suite pins this, and you can check it yourself - two identical [`/v1/charts/birth`](https://astronode.dev/capabilities/vedic/charts-birth) calls return identical `data`. That makes responses safe to cache by request body.

Two things in a response do change between calls and should be left out of any cache key or comparison: the envelope's `request_id`, and `meta.computed_at` (the wall-clock time of the call).

## Endpoints that default to "now"

Some endpoints answer a question about a moment, and use the current time if you do not give one. Those return different results tomorrow - by design. Pass the moment explicitly whenever you cache, store or test:

*Time-dependent defaults*

| Endpoint | Defaults to now |
| --- | --- |
| [`/v1/western/lunar-metrics`](https://astronode.dev/capabilities/western/western-lunar-metrics) | the moment (`at`) |
| [`/v1/western/transit/*`](https://astronode.dev/capabilities/western/western-transit-chart) | the transit moment |
| [`/v1/kp/horary`](https://astronode.dev/capabilities/kp/kp-horary), [`/v1/kp/transit`](https://astronode.dev/capabilities/kp/kp-transit) | the question / transit moment |
| [`/v1/dosha/sade-sati`](https://astronode.dev/capabilities/vedic/dosha-sade-sati) | the as-of date for the current phase |
| [`/v1/nadi/timing`](https://astronode.dev/capabilities/nadi/nadi-timing) | the reference moment for the running period (`as_of`) |
| [`/v1/horoscope/daily/:sign`](https://astronode.dev/capabilities/western/horoscope-daily-sign) | today (UTC) |

## Engine versions

Responses carry an `engine_version` in `meta`, and it is bumped whenever a change alters output. Store it next to anything you persist: if you ever see a difference between a stored result and a fresh one, the version tells you whether the engine changed or the input did. Additions to the API contract are listed on the [changelog](https://astronode.dev/changelog).

## Reproducible tarot draws

Tarot is the one place randomness is the point. [`POST /v1/tarot/draw`](https://astronode.dev/capabilities/tarot/tarot-draw) shuffles with a fresh random seed by default. Pass your own `seed` (any string, 1-120 characters) and the draw becomes reproducible: the seed is hashed (SHA-256) into a xoshiro256** generator that drives a Fisher-Yates shuffle, so the same seed always gives the same cards. Two calls with `"seed": "guide-demo"` and a three-card spread both drew Eight of Wands, The Sun, Queen of Swords.

- Shareable readings: store the seed, not the cards - the link can re-draw the identical spread.
- Tests: fix the seed and assert on the cards.
- One reading per user per day: derive the seed from the user id and the date.

## Questions

**Is it safe to cache AstroNode API responses?**

Yes for calculations: the same input produces the same `data`, byte for byte, so responses can be cached by request body. Endpoints that default to the current time need the moment passed explicitly.

**How do I make a tarot draw reproducible?**

Pass your own `seed` (a string of 1 to 120 characters) to `POST /v1/tarot/draw`. Without one, the draw is shuffled with a fresh random seed each time.

## Endpoints

- [`POST /v1/charts/birth`](https://astronode.dev/capabilities/vedic/charts-birth) - Birth Chart (Kundli) API
- [`POST /v1/western/lunar-metrics`](https://astronode.dev/capabilities/western/western-lunar-metrics) - Moon Phase and Void-of-Course API
- [`POST /v1/kp/horary`](https://astronode.dev/capabilities/kp/kp-horary) - KP Horary (Prashna 1-249) API
- [`POST /v1/tarot/draw`](https://astronode.dev/capabilities/tarot/tarot-draw) - Tarot Card Draw API
