# A Lal Kitab report that degrades by plan

> Lal Kitab uses its own fixed-house kundli, its own list of planetary debts (rins) and its own remedies. The API serves all three, split across two plans: the kundli on Hobby, debts and remedies on Pro. The recipe builds a report that shows whatever the key is entitled to.

Source: https://astronode.dev/recipes/lal-kitab-report · Updated: 2026-12-01

**What you build:** A Lal Kitab report: fixed-house placements, sleeping planets, present debts with reasons, and remedies. (Node.js, Python)

## Which call for which part

| Part of the report | Endpoint | Plan |
| --- | --- | --- |
| Placements, houses, awake/asleep, blind houses | [`POST /v1/lal-kitab/horoscope`](https://astronode.dev/capabilities/lal-kitab/lal-kitab-horoscope) | Hobby |
| The seven rins, present or not, with reasons | [`POST /v1/lal-kitab/debts`](https://astronode.dev/capabilities/lal-kitab/lal-kitab-debts) | Pro |
| Triggered remedies (optionally for one planet) | [`POST /v1/lal-kitab/remedies`](https://astronode.dev/capabilities/lal-kitab/lal-kitab-remedies) | Pro |

`/v1/lal-kitab/planets` and `/v1/lal-kitab/houses` return subsets of the horoscope response. Calling them as well costs two more billable calls for data you already have.

## Node: one code path for Hobby and Pro

```javascript
// lal-kitab.mjs - Node 18+, server-side.
// Kundli: Hobby. Debts and remedies: Pro. Build the page to degrade by plan.
const API = "https://api.astronode.dev";
const birth = { date: "1973-04-24", time: "17:25:00", tz_offset_minutes: 330, lat: 19.076, lng: 72.8777 };

const post = async (path, extra = {}) => {
  const res = await fetch(API + path, {
    method: "POST",
    headers: { authorization: `Bearer ${process.env.ASTRONODE_API_KEY}`, "content-type": "application/json" },
    body: JSON.stringify({ ...birth, ...extra }),
  });
  const body = await res.json();
  if (res.status === 403 && body.error.code === "PLAN_REQUIRED") return null; // not billed
  if (!res.ok) throw new Error(`${path}: ${res.status} ${body.error.code}`);
  return body.data;
};

// One call returns planets AND houses - no need for /planets and /houses too.
const kundli = await post("/v1/lal-kitab/horoscope");
const debts = await post("/v1/lal-kitab/debts");

const report = {
  ascendant: kundli.ascendant_sign, // context only: Lal Kitab houses are fixed (Aries = 1)
  placements: kundli.planets.map((p) => `${p.planet} H${p.lal_kitab_house}${p.state === "asleep" ? " (asleep)" : ""}`),
  debts: debts ? debts.rins.filter((r) => r.present).map((r) => ({ name: r.display_name, why: r.reasons })) : "upgrade to Pro",
};

if (debts) {
  // Remedies for one planet at a time keep the payload small.
  const firstDebt = debts.rins.find((r) => r.present);
  const remedies = await post("/v1/lal-kitab/remedies", { planet: firstDebt.primary_planet });
  report.remedies = remedies.triggered.map((r) => `${r.id}: ${r.remedy}`);
}
console.log(JSON.stringify(report, null, 2));
```

Pro key, then Hobby key:

```text
$ node lal-kitab.mjs   # Pro key
{
  "ascendant": "Virgo",
  "placements": [
    "Sun H1",
    "Moon H9",
    "Mars H10",
    "Mercury H12 (asleep)",
    "Jupiter H10 (asleep)",
    "Venus H1",
    "Saturn H2",
    "Rahu H9 (asleep)",
    "Ketu H3"
  ],
  "debts": [
    {
      "name": "Matri Rin (debt to mother)",
      "why": [
        "Moon conjunct Rahu in house 9."
      ]
    },
    {
      "name": "Atma Rin (debt to self)",
      "why": [
        "Mercury in blind house 12."
      ]
    },
    {
      "name": "Bandhu Rin (debt to relatives)",
      "why": [
        "Jupiter asleep in house 10."
      ]
    }
  ],
  "remedies": [
    "moon-01: Serve and respect mother and elderly women in the family.",
    "moon-02: Keep a silver glass of water at the bedside overnight; offer it to a tree at dawn.",
    "moon-04: Offer milk to a peepal or banyan tree on Mondays; keep a clean pot of water at home."
  ]
}

$ node lal-kitab.mjs   # Hobby key
{
  "ascendant": "Virgo",
  "placements": [
    "Sun H1",
    "Moon H9",
    "Mars H10",
    "Mercury H12 (asleep)",
    "Jupiter H10 (asleep)",
    "Venus H1",
    "Saturn H2",
    "Rahu H9 (asleep)",
    "Ketu H3"
  ],
  "debts": "upgrade to Pro"
}
```

- **Houses are fixed by sign.** In Lal Kitab, Aries is always house 1, whatever rises. The ascendant (Virgo here) is returned for context, which is why the Sun in Aries sits in H1. Do not re-number houses from the ascendant on the client.
- **`state` and `in_blind_house`** are the two flags a Lal Kitab reader looks for first; surface them next to each planet.
- **Debts carry their own reasons.** `rins[].reasons` ("Moon conjunct Rahu in house 9.") is the chart-specific explanation. Use it as the "why" line.

## Python: the remedies catalog, unfiltered

Without `planet`, the remedies endpoint returns every triggered remedy plus the full 54-entry catalog - useful once, for building your own index, but heavy for a page view:

```python
# lal_kitab_remedies.py - Python 3.9+, standard library only. Pro plan.
import collections, json, os, urllib.request

API = "https://api.astronode.dev"
KEY = os.environ["ASTRONODE_API_KEY"]
birth = {"date": "1973-04-24", "time": "17:25:00", "tz_offset_minutes": 330, "lat": 19.076, "lng": 72.8777}

req = urllib.request.Request(
    API + "/v1/lal-kitab/remedies",
    data=json.dumps(birth).encode(),  # no "planet": every triggered remedy
    headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"},
)
data = json.load(urllib.request.urlopen(req))["data"]

print(len(data["triggered"]), "of", len(data["full_catalog"]), "catalog remedies triggered")
print(dict(collections.Counter(r["planet"] for r in data["triggered"])))
# `trigger` is the catalog rule's wording, not this chart's placement:
first = data["triggered"][0]
print(first["id"], "|", first["trigger"], "| debt:", first["related_rin"])
```

```text
$ python3 lal_kitab_remedies.py
22 of 54 catalog remedies triggered
{'Moon': 3, 'Mercury': 6, 'Jupiter': 6, 'Rahu': 6, 'Mars': 1}
moon-01 | Moon afflicted in the 4th house (Matri Rin). | debt: matri_rin
```

Note the last line: `trigger` is the catalog rule's general wording ("Moon afflicted in the 4th house"), not a statement about this chart, whose Moon is in house 9. Pair each remedy with the debt it belongs to (`related_rin`) and show that debt's `reasons` instead.

## Plan handling

- A Hobby key gets `403 PLAN_REQUIRED` from debts and remedies. It is not billed and does not use a per-minute slot, so the try-then-hide pattern above is free. Cache the plan answer per key for the session instead of probing on every view.
- Show the locked sections as locked rather than hiding them; `error.details.upgrade_url` gives the dashboard path.
- Lal Kitab text in the responses is traditional content attributed to Pandit Joshi's editions; keep the response's `disclaimer` on screen.

## Questions

**What do I end up with?**

A Lal Kitab report: fixed-house placements, sleeping planets, present debts with reasons, and remedies. The code is in Node.js and Python.

**Which endpoints does this recipe call, and in what order?**

3 endpoints, in this order: Lal Kitab Kundli (`POST /v1/lal-kitab/horoscope`), then Lal Kitab Rins (Ancestral Debts) (`POST /v1/lal-kitab/debts`), then Lal Kitab Remedies (`POST /v1/lal-kitab/remedies`).

## Endpoints, in call order

- [`POST /v1/lal-kitab/horoscope`](https://astronode.dev/capabilities/lal-kitab/lal-kitab-horoscope) - Lal Kitab Kundli API
- [`POST /v1/lal-kitab/debts`](https://astronode.dev/capabilities/lal-kitab/lal-kitab-debts) - Lal Kitab Rins (Ancestral Debts) API
- [`POST /v1/lal-kitab/remedies`](https://astronode.dev/capabilities/lal-kitab/lal-kitab-remedies) - Lal Kitab Remedies API
