ഉള്ളടക്കത്തിലേക്ക് പോകുക
API key നേടുക

ഗൈഡുകൾ · മന്ത്രങ്ങൾ

ദിവസേനയുള്ള മന്ത്രമോ തിരഞ്ഞെടുത്ത ശ്ലോകമോ ചേർക്കുക

തിരഞ്ഞെടുത്ത ഒരു മന്ത്രം ഫെച്ച് ചെയ്ത് അതിന്റെ മൂല സംസ്കൃതവും ലിപ്യന്തരണവും അവതരിപ്പിക്കുക.

ഈ റിക്വസ്റ്റ് സാൻഡ്‌ബോക്സിൽ പരീക്ഷിക്കുക

1 പ്രവർത്തിക്കുന്ന ഒരു റിക്വസ്റ്റ് നടത്തുക

GET /v1/mantras/annapurna-aham-vaishvanaro-bhuthva
curl "$MANTRILO_API_URL/v1/mantras/annapurna-aham-vaishvanaro-bhuthva" \
  -H "Authorization: Bearer $MANTRILO_API_KEY"
സാൻഡ്‌ബോക്സ് മന്ത്ര ഉദാഹരണം200 OK
{
  "data": {
    "id": "annapurna-aham-vaishvanaro-bhuthva",
    "title": "Aham Vaishvanaro Bhuthva",
    "deity": {
      "id": "annapurna",
      "name": "Lord Annapurna"
    },
    "category": "Annapurna Stotras",
    "source": "Sanatana Shastras",
    "description": "Aham Vaishvanaro Bhutva means \"I, having become the universal fire,\" and in Bhagavad Gita 15.14 Krishna says he lives in every body and digests its food. United with the prana and apana breaths, this inner fire cooks the four kinds of food: chewed, swallowed, licked and sucked. Families often say it before a meal to treat eating as an offering.",
    "verseCount": 1,
    "audio": {
      "href": "/v1/mantras/annapurna-aham-vaishvanaro-bhuthva/audio"
    },
    "verses": [
      {
        "number": 1,
        "title": "Aham Vaishvanaro Bhuthva – Verse 1",
        "sanskrit": "अहं वैश्वानरो भूत्वा प्राणिनां देहमाश्रितः\nप्राणापान समायुक्तः पचाम्यन्नं चतुर्विधम्",
        "transliteration": "ahaṃ vaiśvānaro bhūtvā prāṇināṃ dehamāśritaḥ\nprāṇāpāna samāyuktaḥ pacāmyannaṃ caturvidham",
        "translation": null,
        "wordMeanings": []
      }
    ]
  },
  "sandbox": true
}

2 നിങ്ങളുടെ സെർവറിൽ നിന്ന് വിളിക്കുക

കീ നിങ്ങളുടെ ബാക്കെൻഡിൽ സൂക്ഷിച്ച് ഉള്ളടക്കം മാത്രം ആപ്പിലേക്ക് തിരികെ നൽകുക. ഈ Node.js സെർവർ നിങ്ങളുടെ ആപ്പിന് വിളിക്കാവുന്ന ഒരു റൂട്ട് ലഭ്യമാക്കുന്നു.

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) {
  return mantrilo("/v1/mantras/annapurna-aham-vaishvanaro-bhuthva");
}

createServer(async (req, res) => {
  const incoming = new URL(req.url, 'http://localhost');
  res.setHeader('Content-Type', 'application/json');
  if (req.method !== 'GET' || incoming.pathname !== '/api/mantrilo-guide') {
    res.writeHead(404).end(JSON.stringify({ error: 'Not found' }));
    return;
  }
  try {
    const result = await load(incoming);
    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');
നിങ്ങളുടെ കാഴ്ചയിൽ
const featured = { title: data.title, verse: data.verses?.[0] };

3 ഇൻപുട്ടുകളും പേജിനേഷനും

കാറ്റലോഗിലെ സ്ഥിരമായ id ഉപയോഗിക്കുക. ഫീച്ചർ ചെയ്യേണ്ട ID നിങ്ങളുടെ ആപ്പിൽ തിരഞ്ഞെടുക്കുകയോ ഷെഡ്യൂൾ ചെയ്യുകയോ ചെയ്യുക. തിരഞ്ഞെടുത്ത എൻട്രി API നൽകും.

data.title-ഉം verses അറേയും റെൻഡർ ചെയ്യുക. ലഭ്യമാകുമ്പോൾ sanskrit, transliteration എന്നിവ പ്രദർശിപ്പിക്കുക. translation ഫീൽഡ് നിലവിൽ null ആണ്.

4 ക്വോട്ട

വിജയകരമായ ഓരോ വിശദാംശ ഫെച്ചും ഒരു റിക്വസ്റ്റ് ഉപയോഗിക്കുന്നു. നിങ്ങളുടെ ബാക്കെൻഡ് കാഷെയിൽ ഇതിനകമുള്ള എൻട്രി വീണ്ടും ഉപയോഗിക്കാൻ അധിക റിക്വസ്റ്റ് വേണ്ട.

റിക്വസ്റ്റുകൾ ബേസ് URL MANTRILO_API_URL-ൽ നിന്ന് വായിക്കുന്നു. സെർവർ ഉദാഹരണം ബദലായി https://api.mantrilo.com ഉപയോഗിക്കുന്നു.