ಮಾರ್ಗದರ್ಶಿಗಳು · ಮಂತ್ರಗಳು
ಹುಡುಕಬಹುದಾದ ಮಂತ್ರ ಸಂಗ್ರಹವನ್ನು ನಿರ್ಮಿಸಿ
ಮಂತ್ರಗಳು ಮತ್ತು ಶ್ಲೋಕಗಳನ್ನು ಪಟ್ಟಿ ಮಾಡಿ, ದೇವತೆಯ ಪ್ರಕಾರ ಫಿಲ್ಟರ್ ಮಾಡಿ ಮತ್ತು ನೀವು ಲೋಡ್ ಮಾಡಿದ ಶೀರ್ಷಿಕೆಗಳಲ್ಲಿ ಹುಡುಕಿ.
ಈ ವಿನಂತಿಯನ್ನು ಸ್ಯಾಂಡ್ಬಾಕ್ಸ್ನಲ್ಲಿ ಪ್ರಯತ್ನಿಸಿ1 ಕೆಲಸ ಮಾಡುವ ವಿನಂತಿಯನ್ನು ಮಾಡಿ
curl "$MANTRILO_API_URL/v1/mantras?limit=1" \
-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"
}
}
],
"nextCursor": "YW5uYXB1cm5hLWFoYW0tdmFpc2h2YW5hcm8tYmh1dGh2YQ",
"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) {
const params = new URLSearchParams({ limit: '1' });
for (const field of ['cursor', 'deity']) {
const value = incoming.searchParams.get(field);
if (value) params.set(field, value);
}
const page = await mantrilo('/v1/mantras?' + params);
const query = (incoming.searchParams.get('q') ?? '').trim().toLowerCase();
const audio = incoming.searchParams.get('audio'); // 'with' or 'without'
return {
...page,
data: page.data.filter(item =>
(item.title ?? '').toLowerCase().includes(query) &&
(audio === 'with' ? !!item.audio : audio === 'without' ? !item.audio : true)
),
};
}
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 titles = data.map(item => item.title);3 ಇನ್ಪುಟ್ಗಳು ಮತ್ತು ಪೇಜಿನೇಷನ್
limit (1–100, ಡೀಫಾಲ್ಟ್ 20), cursor (ಹಿಂದಿನ nextCursor) ಮತ್ತು ಐಚ್ಛಿಕ deity (annapurna ನಂತಹ ದೇವತೆಯ ID) ಬಳಸಿ. Mantras ಮಾರ್ಗವು ಶ್ಲೋಕಗಳನ್ನೂ ನೀಡುತ್ತದೆ. API ನಲ್ಲಿ ಪೂರ್ಣ-ಪಠ್ಯ ಹುಡುಕಾಟದ ಪ್ಯಾರಾಮೀಟರ್ ಇಲ್ಲ. ಈ ಉದಾಹರಣೆಯು ಲೋಡ್ ಮಾಡಿದ ಒಂದು ಪುಟವನ್ನು ಶೀರ್ಷಿಕೆಯ ಪ್ರಕಾರ ಮತ್ತು ಬೇಕಿದ್ದರೆ ಆಡಿಯೋ ಲಭ್ಯತೆಯ ಪ್ರಕಾರ ಫಿಲ್ಟರ್ ಮಾಡುತ್ತದೆ. ಇಡೀ ಕ್ಯಾಟಲಾಗ್ನಲ್ಲಿ ಹುಡುಕಲು, ಅನುಮತಿ ಇರುವ ವಿಷಯವನ್ನು ನಿಮ್ಮ ಬ್ಯಾಕೆಂಡ್ನಲ್ಲಿ ಇಂಡೆಕ್ಸ್ ಮಾಡಿ.
data[].title, deity.name ಮತ್ತು verseCount ಅನ್ನು ತೋರಿಸಿ. ಮುಂದಿನ ಪುಟಕ್ಕಾಗಿ nextCursor ಬಳಸಿ. ಒಂದು ಸಾಲನ್ನು ತೆರೆಯಲು ಅದರ id ಅನ್ನು GET /v1/mantras/{id} ಗೆ ಕಳುಹಿಸಿ.
4 ಕೋಟಾ
ಪ್ರತಿ ಯಶಸ್ವಿ ಪುಟ, ದೇವತೆ-ಫಿಲ್ಟರ್ ವಿನಂತಿ ಮತ್ತು ವಿವರ ಪಡೆಯುವಿಕೆ ಒಂದು ವಿನಂತಿಯನ್ನು ಬಳಸುತ್ತದೆ. ಈಗಾಗಲೇ ಲೋಡ್ ಆದ ಫಲಿತಾಂಶಗಳಲ್ಲಿ ಹುಡುಕುವುದು ಅಥವಾ ಆಡಿಯೋ ಫಿಲ್ಟರ್ ಮಾಡುವುದು, ಅಥವಾ Mantrilo ಅನ್ನು ಕರೆಯದೆ ನಿಮ್ಮ ಸ್ವಂತ ಕ್ಯಾಶ್ನಿಂದ ಸಂಪೂರ್ಣ ಪ್ರತಿಕ್ರಿಯೆಯನ್ನು ನೀಡುವುದು ಶೂನ್ಯ Mantrilo ವಿನಂತಿಗಳನ್ನು ಬಳಸುತ್ತದೆ.
ವಿನಂತಿಗಳು base URL ಅನ್ನು MANTRILO_API_URL ನಿಂದ ಓದುತ್ತವೆ. ಸರ್ವರ್ ಉದಾಹರಣೆಯು https://api.mantrilo.com ಅನ್ನು ಪರ್ಯಾಯವಾಗಿ ಬಳಸುತ್ತದೆ.
