सामग्रीमा जानुहोस्
API key लिनुहोस्

गाइडहरू · अडियो

पवित्र रेकर्डिङ बजाउनुहोस्

रेकर्डिङ भएको प्रविष्टिका लागि अस्थायी प्लेब्याक URL माग्नुहोस्।

यो रिक्वेस्ट sandbox मा चलाएर हेर्नुहोस्

1 चल्ने रिक्वेस्ट बनाउनुहोस्

GET /v1/mantras/annapurna-aham-vaishvanaro-bhuthva/audio?format=json
curl "$MANTRILO_API_URL/v1/mantras/annapurna-aham-vaishvanaro-bhuthva/audio?format=json" \
  -H "Authorization: Bearer $MANTRILO_API_KEY"
प्लेसहोल्डर URL सहितको उदाहरणात्मक रेस्पोन्स200 OK
{
  "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 सर्भरले तपाईंको एपले कल गर्न मिल्ने एउटा route खोल्छ।

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/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 ले रेकर्डिङमा redirect गर्छ। JSON मोडले तपाईंको ब्याकइन्डलाई signed URL दिन्छ।

data.url आफ्नो प्लेयरमा पठाउनुहोस्, र data.expiresAt पछि नयाँ लिङ्क माग्नुहोस्। उदाहरण रेस्पोन्समा म्याद सकिएको signed URL को सट्टा प्लेसहोल्डर राखिएको छ।

4 कोटा

हरेक सफल लिङ्क जारीले एक रिक्वेस्ट खर्च गर्छ र फाइलको पूरा साइज bytes मा अडियो कोटाबाट कट्छ। पहिल्यै जारी भएको URL प्लेयरमा पढ्दा Mantrilo API मा नयाँ रिक्वेस्ट जाँदैन।

रिक्वेस्टहरूले base URL MANTRILO_API_URL बाट पढ्छन्। सर्भरको उदाहरणमा त्यो नभए https://api.mantrilo.com प्रयोग हुन्छ।