Skip to content
Get API key

Guides · Astrology

Daily Panchang

Build a local daily Panchang calendar.

Try this request in the sandbox

1 Make a working request

POST /v1/astrology/calculate
curl -X POST "$MANTRILO_API_URL/v1/astrology/calculate" \
  -H "Authorization: Bearer $MANTRILO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"date":"2026-11-15","latitude":28.6139,"longitude":77.209,"timezone":"Asia/Kolkata","operation":"daily-panchang"}'
Verified New Delhi response excerpt200 OK
{
  "data": {
    "operation": "daily-panchang",
    "engineVersion": "mantrilo-vedic-1",
    "date": "2026-11-15",
    "timezone": "Asia/Kolkata",
    "basis": "local_sunrise",
    "sunrise": "06:43:19",
    "sunset": "17:27:50",
    "tithi": {
      "number": 6,
      "name": "Shashti",
      "paksha": "Shukla",
      "endsAt": "2026-11-16T02:01:40.095280+05:30"
    },
    "nakshatra": {
      "number": 21,
      "name": "Uttara Ashadha",
      "pada": 2,
      "lord": "Sun",
      "endsAt": "2026-11-15T23:29:06.472952+05:30"
    },
    "yoga": {
      "number": 10,
      "name": "Ganda",
      "endsAt": "2026-11-16T07:16:28.084160+05:30"
    },
    "karanas": [
      {
        "number": 3,
        "name": "Kolav",
        "endsAt": "2026-11-15T12:44:29.104828+05:30"
      },
      {
        "number": 4,
        "name": "Tetil",
        "endsAt": "2026-11-16T02:01:40.095280+05:30"
      }
    ],
    "rahuKalam": {
      "start": "16:07",
      "end": "17:27"
    }
  },
  "calculated": true
}

2 Call it from your server

Keep the key in your backend and return only the content to your app. This Node.js server exposes one route your app can call.

server.mjs
// server.mjs · Node.js 22+
import { createServer } from 'node:http';

const apiKey = process.env.MANTRILO_API_KEY;
if (!apiKey) throw new Error('Set MANTRILO_API_KEY on your server.');
const base = process.env.MANTRILO_API_URL ?? "https://api.mantrilo.com";

async function mantrilo(path, input) {
  const response = await fetch(base + path, {
    method: input ? 'POST' : 'GET',
    headers: {
      Authorization: 'Bearer ' + apiKey,
      ...(input ? { 'Content-Type': 'application/json' } : {}),
    },
    ...(input ? { body: JSON.stringify(input) } : {}),
    signal: AbortSignal.timeout(20000),
    redirect: 'error',
  });
  const result = await response.json();
  if (!response.ok) throw Object.assign(new Error('Mantrilo request failed'), {
    status: response.status, requestId: result.requestId,
  });
  return result;
}

async function load(incoming, input) {
  return mantrilo("/v1/astrology/calculate", { ...input, operation: "daily-panchang" });
}

createServer(async (req, res) => {
  const incoming = new URL(req.url, 'http://localhost');
  res.setHeader('Content-Type', 'application/json');
  if (req.method !== 'POST' || incoming.pathname !== '/api/mantrilo-guide') {
    res.writeHead(404).end(JSON.stringify({ error: 'Not found' }));
    return;
  }
  try {
    let text = '';
    for await (const chunk of req) {
      text += chunk;
      if (Buffer.byteLength(text) > 16384) {
        res.writeHead(413).end(JSON.stringify({ error: 'Input is too large' }));
        return;
      }
    }
    let input;
    try { input = JSON.parse(text); } catch { input = null; }
    if (!input || typeof input !== 'object' || Array.isArray(input)) {
      res.writeHead(400).end(JSON.stringify({ error: 'Send a JSON object' }));
      return;
    }
    const result = await load(incoming, input);
    res.end(JSON.stringify(result));
  } catch (error) {
    res.writeHead(error.status ?? 502).end(JSON.stringify({
      error: 'Could not load this content',
      requestId: error.requestId,
    }));
  }
}).listen(3000, '127.0.0.1');
In your view
const { sunrise, sunset, tithi } = data;

3 Inputs and pagination

Provide a local date (YYYY-MM-DD), latitude and longitude in decimal degrees, and an IANA timezone.

Show data.date, sunrise, sunset, tithi, nakshatra, yoga, karanas and rahuKalam.

4 Quota

A successful call uses one content request. Sandbox and live requests have separate usage totals. Failed calculations are refunded.

Requests read the base URL from MANTRILO_API_URL. The server example falls back to https://api.mantrilo.com.