โ† Recipes

Generate a daily horoscope newsletter with the API

The cost of a horoscope newsletter should not grow with your subscriber list. Readings are keyed by sign and date, so an issue is twelve calls whether you send four emails or four hundred thousand.

You build
A daily issue built from 12 calls, plus a nakshatra digest that calls once per distinct nakshatra
Code
Node.js, Python - no SDK, runnable as shown

Updated

What the endpoint returns

GET /v1/horoscope/daily/:sign returns written content for a sign and a date: a summary, focus_areas, cautions and a disclaimer. It computes nothing about the reader, so the same request returns the same text for every subscriber of that sign. It is on the Free plan.

GET /v1/horoscope/daily/Leo?date=2026-12-01 (data):

json
{
  "type": "daily_horoscope",
  "version": "1.6.0",
  "language": "en",
  "verbosity": "standard",
  "sign": "Leo",
  "date": "2026-12-01",
  "weekday": "Tuesday",
  "summary": "You're more visible today than usual. Use it for the work that actually matters to you.",
  "focus_areas": [
    "Public-facing work",
    "Generous gestures",
    "Creative expression"
  ],
  "cautions": [
    "Confusing attention for outcome",
    "Resenting shared credit"
  ],
  "disclaimer": "Vedic astrology is offered here for cultural and informational purposes only. It is not a substitute for medical, legal, financial, or psychological advice. Take what resonates and leave the rest."
}

Which sign a subscriber has is your decision, made once at signup. The catalog lists this endpoint under Western sun signs (tropical). If your audience expects Vedic signs, /v1/birth-details returns the sidereal sun_sign and moon_sign - for the sample birth on 24 April that is Aries, where a tropical sun sign would be Taurus. Store one, label it in your UI, and do not mix them.

Build the issue once

Fetch all twelve signs before the send window, render per subscriber from memory, hand the outbox to your email provider. Always pass date - without it the endpoint uses today in UTC, which is already tomorrow for an evening job in Asia-Pacific:

newsletter.mjs

Node.js
// newsletter.mjs - build tomorrow's issue once, before the send window
const API = process.env.ASTRONODE_API_URL ?? "https://api.astronode.dev";
const KEY = process.env.ASTRONODE_API_KEY;

const SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo",
  "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"];

// Your subscriber table: the sign was stored once, at signup.
const subscribers = [
  { email: "a@example.com", sign: "Leo" },
  { email: "b@example.com", sign: "Leo" },
  { email: "c@example.com", sign: "Pisces" },
  { email: "d@example.com", sign: "Aries" },
];

const issueDate = "2026-12-01"; // always explicit: the endpoint defaults to today (UTC)

// 12 calls per issue, whether you have 4 subscribers or 400,000.
const bySign = {};
for (const sign of SIGNS) {
  const res = await fetch(`${API}/v1/horoscope/daily/${sign}?date=${issueDate}`, {
    headers: { authorization: `Bearer ${KEY}` },
  });
  if (!res.ok) throw new Error(`${sign}: ${res.status}`);
  bySign[sign] = (await res.json()).data;
}

const render = (h) => [
  `${h.sign} - ${h.weekday} ${h.date}`,
  h.summary,
  `Focus: ${h.focus_areas.join(", ")}`,
  `Watch for: ${h.cautions.join(", ")}`,
  "",
  h.disclaimer,
].join("\n");

const outbox = subscribers.map((s) => ({ to: s.email, body: render(bySign[s.sign]) }));
console.log(`${Object.keys(bySign).length} API calls, ${outbox.length} emails queued\n`);
console.log(outbox[0].body);

Output:

text
12 API calls, 4 emails queued

Leo - Tuesday 2026-12-01
You're more visible today than usual. Use it for the work that actually matters to you.
Focus: Public-facing work, Generous gestures, Creative expression
Watch for: Confusing attention for outcome, Resenting shared credit

Vedic astrology is offered here for cultural and informational purposes only. It is not a substitute for medical, legal, financial, or psychological advice. Take what resonates and leave the rest.

Keep the disclaimer in the email footer. It is part of the content, and it is the wording the content was written against.

Nakshatra edition: call per distinct key

POST /v1/horoscope/nakshatra gives a reading keyed by birth nakshatra (27, optionally with pada). That is up to 108 keys, so fetch only the ones your subscribers actually have:

nakshatra_digest.py

Python 3.9+
# nakshatra_digest.py - one call per DISTINCT nakshatra your subscribers have, not per subscriber
import json, os, urllib.request

API = os.environ.get("ASTRONODE_API_URL", "https://api.astronode.dev")
KEY = os.environ["ASTRONODE_API_KEY"]

# nakshatra + pada were stored at signup from /v1/birth-details
subscribers = [("a@example.com", "Uttara Ashadha", 1), ("b@example.com", "Magha", 3),
               ("c@example.com", "Uttara Ashadha", 1), ("d@example.com", "Magha", 3),
               ("e@example.com", "Revati", 2)]

readings = {}
for _, nakshatra, pada in subscribers:
    if (nakshatra, pada) in readings:
        continue
    body = {"nakshatra": nakshatra, "pada": pada, "date": "2026-12-01"}
    req = urllib.request.Request(API + "/v1/horoscope/nakshatra", data=json.dumps(body).encode(),
                                 method="POST",
                                 headers={"Authorization": "Bearer " + KEY,
                                          "Content-Type": "application/json"})
    with urllib.request.urlopen(req) as r:
        readings[(nakshatra, pada)] = json.load(r)["data"]["summary"]

print(len(subscribers), "subscribers,", len(readings), "calls")
for (nakshatra, pada), summary in readings.items():
    print(f"{nakshatra} pada {pada}: {summary}")

Output:

text
5 subscribers, 3 calls
Uttara Ashadha pada 1: Lasting victories. Patient effort outperforms quick wins today.
Magha pada 3: Authority comes with responsibility. Honor lineage; lead with honor.
Revati pada 2: Compassion expansive today. Care widely; rest deeply.

Store the subscriber's nakshatra and pada from /v1/birth-details at signup, so the daily job never touches birth data. The nakshatra endpoint needs the Hobby plan.

Operating it

  • Retries cost calls. A job that crashes after fetching six signs and restarts from zero spends six calls again; even an Idempotency-Key replay is counted as a call. Persist each sign's response as you go and resume from what is stored.
  • Cache by `(sign, date)` in your database; the content for a date does not change once fetched.
  • Send in the subscriber's morning, which means one issue date may go out over 26 hours of time zones. Build it once, send it in waves.
  • Write your own subject line. The API is the body; the newsletter brand, unsubscribe link and send-time logic are yours.

Questions

What do I end up with?
A daily issue built from 12 calls, plus a nakshatra digest that calls once per distinct nakshatra. The code is in Node.js and Python.
Which endpoints does this recipe call, and in what order?
3 endpoints, in this order: Daily Sun Sign Horoscope (GET /v1/horoscope/daily/:sign), then Nakshatra Daily Horoscope (POST /v1/horoscope/nakshatra), then Birth Details (Rashi, Nakshatra, Lagna) (POST /v1/birth-details).