मार्गदर्शिका · मंत्र
रोजचा मंत्र किंवा निवडक श्लोक जोडा
निवडलेला मंत्र मिळवा आणि त्याचा मूळ संस्कृत पाठ व लिप्यंतर दाखवा.
ही रिक्वेस्ट सँडबॉक्समध्ये वापरून पाहा1 चालणारी रिक्वेस्ट पाठवा
curl "$MANTRILO_API_URL/v1/mantras/annapurna-aham-vaishvanaro-bhuthva" \
-H "Authorization: Bearer $MANTRILO_API_KEY"{
"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 ती तुमच्या सर्व्हरवरून कॉल करा
key तुमच्या बॅकएंडमध्ये ठेवा आणि तुमच्या ॲपला फक्त कंटेंट परत द्या. हा Node.js सर्व्हर तुमचे ॲप कॉल करू शकेल असा एक रूट उपलब्ध करतो.
// 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 वापरते.
