What the API accepts
The birth input of every calculation endpoint is strict: date, time, tz_offset_minutes, lat, lng, all required, nothing else. There is no "time unknown" flag on these endpoints - an extra field is a 400 VALIDATION_ERROR. The time_certainty field exists only on the chat API, covered at the end. So the honest approach is to compute with a placeholder time and decide, per field, whether the placeholder could have changed it.
Sweep the day
Call /v1/birth-details at several times across the birth date. A field that has one value at every time is safe to show; one that varies is not:
unknown-time.mjs
// unknown-time.mjs - which fields can you show when nobody knows the birth time?
const API = process.env.ASTRONODE_API_URL ?? "https://api.astronode.dev";
const KEY = process.env.ASTRONODE_API_KEY;
const day = { date: "1973-04-24", tz_offset_minutes: 330, lat: 19.076, lng: 72.8777 };
const times = ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00", "23:59"];
const details = await Promise.all(times.map(async (time) => {
const res = await fetch(`${API}/v1/birth-details`, {
method: "POST",
headers: { authorization: `Bearer ${KEY}`, "content-type": "application/json" },
body: JSON.stringify({ ...day, time }),
});
const { data } = await res.json();
return { time, lagna: data.ascendant.sign, moon_sign: data.moon_sign,
nakshatra: data.nakshatra, sun_sign: data.sun_sign };
}));
for (const d of details) console.log(d.time, d.lagna.padEnd(12), d.moon_sign.padEnd(12), d.nakshatra.padEnd(15), d.sun_sign);
// A field is safe to show only if every possible time agrees on it.
for (const field of ["sun_sign", "moon_sign", "nakshatra", "lagna"]) {
const values = [...new Set(details.map((d) => d[field]))];
console.log(field.padEnd(10), values.length === 1 ? `show: ${values[0]}` : `hide (${values.length} values over the day)`);
}Output (24 Apr 1973, Mumbai):
00:00 Sagittarius Sagittarius Purva Ashadha Aries 04:00 Aquarius Sagittarius Purva Ashadha Aries 08:00 Taurus Sagittarius Purva Ashadha Aries 12:00 Cancer Sagittarius Purva Ashadha Aries 16:00 Leo Sagittarius Purva Ashadha Aries 20:00 Libra Sagittarius Uttara Ashadha Aries 23:59 Sagittarius Capricorn Uttara Ashadha Aries sun_sign show: Aries moon_sign hide (2 values over the day) nakshatra hide (2 values over the day) lagna hide (6 values over the day)
The lagna takes six values - it moves a sign roughly every two hours, so it is never safe without a time, and neither is anything built on houses. The Sun sign is the same all day. The Moon changes nakshatra in the evening and sign just before midnight, so on this date both are unsafe, though on most dates the Moon sign holds. Seven calls answer it for any date; on a different date the answer will differ, so run the sweep per user, not once.
Ask a narrower question
When the Moon sign does change during the day, you do not need the exact birth time - only which side of the change it falls on. Bisecting the day finds the change to the minute in about a dozen calls, and turns the question for the user into "before or after 23:52?":
moon_sign_cutover.py
# moon_sign_cutover.py - find the minute the Moon changes sign on a birth date
import json, os, urllib.request
API = os.environ.get("ASTRONODE_API_URL", "https://api.astronode.dev")
KEY = os.environ["ASTRONODE_API_KEY"]
calls = 0
def moon_sign(minute):
global calls
calls += 1
body = {"date": "1973-04-24", "time": f"{minute // 60:02d}:{minute % 60:02d}",
"tz_offset_minutes": 330, "lat": 19.076, "lng": 72.8777}
req = urllib.request.Request(API + "/v1/birth-details", data=json.dumps(body).encode(),
method="POST", headers={"Authorization": "Bearer " + KEY,
"Content-Type": "application/json"})
with urllib.request.urlopen(req) as r:
return json.load(r)["data"]["moon_sign"]
lo, hi = 0, 23 * 60 + 59
first, last = moon_sign(lo), moon_sign(hi)
if first == last:
print("Moon sign is", first, "all day: safe to show without a birth time")
else:
while hi - lo > 1: # ~11 calls to pin a 1,440-minute day to the minute
mid = (lo + hi) // 2
if moon_sign(mid) == first:
lo = mid
else:
hi = mid
print(f"{first} until {lo // 60:02d}:{lo % 60:02d}, {last} from {hi // 60:02d}:{hi % 60:02d} "
f"({calls} calls). Ask the user: before or after {hi // 60:02d}:{hi % 60:02d}?")Output:
Sagittarius until 23:51, Capricorn from 23:52 (13 calls). Ask the user: before or after 23:52?
The same bisection works for the nakshatra (it changed at some point between 16:00 and 20:00 here) and for the lagna if a user knows "morning" or "after sunset". Name the file anything but bisect.py: Python would import it in place of the standard library's bisect, which urllib.request itself imports.
What to store and what to compute
- Store the time as unknown in your schema (
time: nullplus your own certainty flag). Do not store the placeholder as if it were real, or a later screen will show a confident lagna. - When calling an endpoint, send a fixed placeholder (12:00 local is conventional) and suppress the time-dependent fields you found above: lagna, houses, divisional-chart lagnas, house-based yogas and doshas.
- Dasha periods depend on the Moon's exact degree. A day's uncertainty moves boundaries by months; show mahadasha lords only, with approximate dates, or nothing.
- Cache sweep results per date and place - every user born that day in that city shares them.
Telling the chat API
POST /v1/chat/respond is the one endpoint that accepts the uncertainty directly: its user (and partner) objects take an optional time_certainty of exact, rough or unknown. With unknown you still send a placeholder time, and the answer leans on signs and dasha rather than houses. A request body (checked against the chat OpenAPI spec; the chat service runs on its own host):
{
"conversation_id": "user_42-onboarding",
"user": {
"date": "1973-04-24",
"time": "12:00",
"tz_offset_minutes": 330,
"lat": 19.076,
"lng": 72.8777,
"time_certainty": "unknown"
},
"message": "What does my current dasha period cover?"
}Questions
- What do I end up with?
- A rule for which fields to show without a birth time, and a 13-call bisection for the Moon-sign cut-over. The code is in Node.js and Python.
- Which endpoints does this recipe call, and in what order?
- 2 endpoints, in this order: Birth Details (Rashi, Nakshatra, Lagna) (
POST /v1/birth-details), then AI Astrologer Chat (POST /v1/chat/respond).