← Recipes

Build a synastry report: aspects, composite chart, fallback

A synastry screen needs two things from the API: the aspects between two natal charts, and the composite (midpoint) chart of the pair. Both are Pro endpoints, so the page also needs a sensible answer for keys on a lower plan. This recipe builds all three paths.

You build
A couple report: tightest inter-chart aspects, composite angles, and a Free-plan fallback.
Code
Node.js, Python - no SDK, runnable as shown

Updated

What you call, and which plan it needs

Endpoints in this recipe
StepEndpointPlanReturns
1POST /v1/western/synastry/aspectsProEvery aspect from a planet in chart A to a planet in chart B, with orb, plus counts per aspect type
1POST /v1/western/composite/chartProMidpoint composite: ascendant, MC, 13 points, and the composite's own aspects
2POST /v1/western/reports/romanticFreeA short templated summary of the same synastry run (aspect count, strongest aspect)

All three take the same body: person_a and person_b, each a full birth (date, time, tz_offset_minutes, lat, lng). The two Pro calls are independent, so fire them together. Everything is tropical with Placidus houses, and both natal charts come back inside /v1/western/synastry/chart if you also want to draw the bi-wheel.

Node: two calls, then a fallback

javascript
// synastry.mjs - Node 18+, run on your server (the key never reaches a browser).
const API = "https://api.astronode.dev";
const KEY = process.env.ASTRONODE_API_KEY;

const couple = {
  person_a: { date: "1973-04-24", time: "17:25:00", tz_offset_minutes: 330, lat: 19.076, lng: 72.8777 },
  person_b: { date: "1976-09-12", time: "06:40:00", tz_offset_minutes: 330, lat: 28.6139, lng: 77.209 },
};

const post = async (path) => {
  const res = await fetch(API + path, {
    method: "POST",
    headers: { authorization: `Bearer ${KEY}`, "content-type": "application/json" },
    body: JSON.stringify(couple),
  });
  const body = await res.json();
  return { status: res.status, body };
};

// 1. Inter-chart aspects and the composite chart (both Pro).
const [syn, comp] = await Promise.all([
  post("/v1/western/synastry/aspects"),
  post("/v1/western/composite/chart"),
]);

if (syn.status === 403 && syn.body.error.code === "PLAN_REQUIRED") {
  // 2. Below Pro: fall back to the templated romantic summary (Free).
  const romantic = await post("/v1/western/reports/romantic");
  console.log("fallback:", romantic.body.data.summary, romantic.body.data.sections.map((s) => s.body));
} else {
  const { aspects, counts } = syn.body.data;
  const tightest = [...aspects]
    .sort((a, b) => a.orb - b.orb)
    .slice(0, 4)
    .map((a) => `${a.from} ${a.aspect} ${a.to} (${a.orb.toFixed(2)}°)`);
  console.log(counts);
  console.log(tightest);

  // The composite always contains its own node axis as an exact opposition.
  const NODES = new Set(["TrueNode", "SouthNode"]);
  const compAspects = comp.body.data.aspects.filter((a) => !(NODES.has(a.from) && NODES.has(a.to)));
  const sun = comp.body.data.planets.find((p) => p.planet === "Sun");
  console.log(`composite Asc ${comp.body.data.ascendant.sign}, Sun ${sun.sign}, ${compAspects.length} aspects`);
}

Output with a Pro key, then with a Starter key (the fallback branch):

text
$ node synastry.mjs   # Pro key
{
  conjunction: 13,
  sextile: 5,
  square: 18,
  trine: 19,
  opposition: 15,
  quincunx: 0,
  semisextile: 0,
  semisquare: 0,
  sesquiquadrate: 0
}
[
  'A_Sun opposition B_TrueNode (0.06°)',
  'A_Sun conjunction B_SouthNode (0.06°)',
  'A_MC square B_Venus (0.22°)',
  'A_Mercury opposition B_Pluto (0.24°)'
]
composite Asc Libra, Sun Cancer, 41 aspects

$ node synastry.mjs   # Starter key
fallback: Romantic signals from synastry + composite. [
  '70 inter-chart aspects.',
  'Strongest: A_Sun opposition B_TrueNode (orb 0.06°).'
]
  • Sort by orb yourself. aspects arrives in a stable engine order, not tightest-first. The 70 major aspects above shrink to a readable top four once sorted.
  • The node axis shows up twice. TrueNode and SouthNode are always 180° apart, so any planet on one is automatically on the other - A_Sun opposition B_TrueNode and A_Sun conjunction B_SouthNode are one fact. In the composite the pair also produces a permanent, exact opposition. Drop node-to-node pairs before counting (42 composite aspects became 41).
  • The fallback is free to try. A Starter key gets 403 PLAN_REQUIRED from both Pro calls. That refusal happens before the per-minute limiter and is not billed (see PLAN_REQUIRED), so probing and falling back costs one billable call, the romantic report.

Python: minor aspects, personal planets only

include_minor_aspects: true adds quincunx, semi-sextile, semi-square and sesquiquadrate (89 aspects instead of 70 for this couple). Most screens then narrow to the personal planets on both sides; strip the A_ / B_ prefix to compare names.

Python 3.9+
# synastry.py - Python 3.9+, standard library only.
import json, os, urllib.request

API = "https://api.astronode.dev"
KEY = os.environ["ASTRONODE_API_KEY"]

couple = {
    "person_a": {"date": "1973-04-24", "time": "17:25:00", "tz_offset_minutes": 330, "lat": 19.076, "lng": 72.8777},
    "person_b": {"date": "1976-09-12", "time": "06:40:00", "tz_offset_minutes": 330, "lat": 28.6139, "lng": 77.209},
    "include_minor_aspects": True,
}
req = urllib.request.Request(
    API + "/v1/western/synastry/aspects",
    data=json.dumps(couple).encode(),
    headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"},
)
aspects = json.load(urllib.request.urlopen(req))["data"]["aspects"]

# Keep the personal planets on both sides; "A_Venus" -> "Venus".
PERSONAL = {"Sun", "Moon", "Mercury", "Venus", "Mars"}
side = lambda name: name.split("_", 1)[1]
personal = [a for a in aspects if side(a["from"]) in PERSONAL and side(a["to"]) in PERSONAL]
for a in sorted(personal, key=lambda a: a["orb"])[:5]:
    print(f'{a["from"]:>10} {a["aspect"]:<14} {a["to"]:<10} orb {a["orb"]:.2f}')
print(len(aspects), "aspects with minor ones;", len(personal), "between personal planets")
text
$ python3 synastry.py
     A_Sun sesquiquadrate B_Sun      orb 0.24
   A_Venus quincunx       B_Mercury  orb 0.64
    A_Moon trine          B_Sun      orb 0.88
    A_Mars quincunx       B_Sun      orb 0.92
 A_Mercury opposition     B_Mars     orb 1.68
89 aspects with minor ones; 8 between personal planets

Rendering notes

  • from and to are prefixed with the side (A_, B_) and include the angles (A_MC, B_ASC) as well as planets. Keep the prefix in your data model; it is what makes the aspect directional.
  • counts covers every aspect type, including zeros, so a stacked bar of aspect types needs no client-side tallying.
  • The romantic report is short by design: two templated lines in sections. Treat it as a teaser for the full report, not as the report.
  • Cache by the pair: the result depends only on the two births. Sort the pair consistently (or key on both orders) so A+B and B+A hit the same entry - but remember the A_/B_ labels flip.

Questions

What do I end up with?
A couple report: tightest inter-chart aspects, composite angles, and a Free-plan fallback. The code is in Node.js and Python.
Which endpoints does this recipe call, and in what order?
4 endpoints, in this order: Synastry Aspects (POST /v1/western/synastry/aspects), then Composite Chart (POST /v1/western/composite/chart), then Romantic Compatibility Report (POST /v1/western/reports/romantic), then Synastry Chart (POST /v1/western/synastry/chart).