గైడ్లు · ఆడియో
పవిత్ర రికార్డింగ్ను ప్లే చేయండి
రికార్డింగ్ ఉన్న ఎంట్రీ కోసం తాత్కాలిక ప్లేబ్యాక్ URL ను రిక్వెస్ట్ చేయండి.
ఈ రిక్వెస్ట్ను శాండ్బాక్స్లో ప్రయత్నించండి1 పనిచేసే రిక్వెస్ట్ చేయండి
curl "$MANTRILO_API_URL/v1/mantras/annapurna-aham-vaishvanaro-bhuthva/audio?format=json" \
-H "Authorization: Bearer $MANTRILO_API_KEY"{
"data": {
"url": "https://storage.example.com/signed-recording",
"expiresAt": "2026-11-12T17:51:28.392Z",
"bytes": 123077,
"contentType": "audio/x-m4a"
}
}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/audio?format=json");
}
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');document.querySelector("audio").src = data.url; // Web player; on mobile use data.url as the audio source.3 ఇన్పుట్లు, పేజినేషన్
మంత్రం రికార్డ్లోని audio.href ను ఉపయోగించి, చివర ?format=json జోడించండి. audio null అయితే, ప్లేయర్ను దాచండి. సాధారణ endpoint నేరుగా రికార్డింగ్కు రీడైరెక్ట్ చేస్తుంది. JSON మోడ్ మీ బ్యాకెండ్కు signed URL ను ఇస్తుంది.
data.url ను మీ ప్లేయర్కు పంపండి, data.expiresAt తర్వాత కొత్త లింక్ను రిక్వెస్ట్ చేయండి. ఉదాహరణ రెస్పాన్స్లో గడువు ముగిసిన signed URL స్థానంలో ఒక ప్లేస్హోల్డర్ ఉంది.
4 కోటా
ప్రతి విజయవంతమైన లింక్ జారీ ఒక రిక్వెస్ట్ను ఉపయోగిస్తుంది, పూర్తి ఫైల్ పరిమాణాన్ని బైట్లలో ఆడియో కోటా నుంచి తగ్గిస్తుంది. ఇప్పటికే జారీ చేసిన URL ను ప్లేయర్లో చదవడం వల్ల కొత్త Mantrilo API రిక్వెస్ట్ ఏదీ జరగదు.
రిక్వెస్ట్లు బేస్ URL ను MANTRILO_API_URL నుంచి చదువుతాయి. సర్వర్ ఉదాహరణ ప్రత్యామ్నాయంగా https://api.mantrilo.com ను ఉపయోగిస్తుంది.
