সমললৈ যাওক
API key লওক

গাইড · পুথি

আপোনাৰ এপত উপনিষদ ল'ড কৰক

এটা সংকলন পোনপটীয়াকৈ কল কৰক, তাৰ পৃষ্ঠাবোৰ চাওক, তাৰ পিছত এখন পুথি, অধ্যায় বা শ্লোক খোলক।

এই ৰিকুৱেষ্টটো ছেণ্ডবক্সত চেষ্টা কৰক

1 চলি থকা এটা ৰিকুৱেষ্ট কৰক

GET /v1/books?collection=upanishads&limit=3
curl "$MANTRILO_API_URL/v1/books?collection=upanishads&limit=3" \
  -H "Authorization: Bearer $MANTRILO_API_KEY"
ছেণ্ডবক্স সংকলনৰ ৰেস্পন্স200 OK
{
  "data": [
    {
      "id": "ishaUpanishad",
      "title": "Īśāvāsya Upaniṣad",
      "author": "Vedic Rishis",
      "category": null,
      "subcategory": null,
      "collection": {
        "id": "upanishads",
        "name": "Upanishads"
      },
      "description": "One of the shortest and most profound Upanishads, revealing the nature of the Supreme Lord who pervades all.",
      "verseCount": 18
    }
  ],
  "nextCursor": null,
  "sandbox": true,
  "requestId": "request-id"
}
  • পুথি আৰু অধ্যায়ৰ সূচীGET /v1/books/ishaUpanishad
  • প্ৰথম অধ্যায়GET /v1/books/ishaUpanishad/chapters/1

2 আপোনাৰ ছাৰ্ভাৰৰ পৰা কল কৰক

keyটো আপোনাৰ বেকএণ্ডত ৰাখক আৰু আপোনাৰ এপলৈ কেৱল সমলখিনিহে ঘূৰাই পঠিয়াওক। এই 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) {
  const params = new URLSearchParams({ collection: 'upanishads', limit: '3' });
  const cursor = incoming.searchParams.get('cursor');
  if (cursor) params.set('cursor', cursor);
  return mantrilo('/v1/books?' + params);
}

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 books = data.map(book => ({ id: book.id, title: book.title, description: book.description }));

3 ইনপুট আৰু পেজিনেচন

collection হৈছে এটা সংকলনৰ id: upanishads, bhagavad-gita, advaita-vedanta-prakarana-granthas, vedanta বা yoga। limit 1–100 (ডিফল্ট 24)। পৰৱৰ্তী পৃষ্ঠাৰ বাবে nextCursorক cursor হিচাপে পঠিয়াওক; শেষ পৃষ্ঠাত ই null হয়। ৰেস্পন্সৰ প্ৰতিখন পুথিত collection.id থাকে, গতিকে সংকলনলৈ উভতি যোৱা লিংকৰ বাবেও একেটা id চলে। এই সংকলনৰ বাবে ছেণ্ডবক্স keyয়ে nextCursor null কৰি ঈশ উপনিষদ ঘূৰাই দিয়ে। পেইড keyয়ে উপলব্ধ সংকলনৰ সকলো পৃষ্ঠা চাব পাৰে। নিৰ্দিষ্ট নমুনা নথকা সংকলনে খালী ছেণ্ডবক্স পৃষ্ঠা ঘূৰাই দিয়ে।

data[].title আৰু description তালিকাভুক্ত কৰক, তাৰ পিছত GET /v1/books/{id}ৰে পুথি এখন খোলক। ইয়াৰ chapters[]য়ে GET /v1/books/{id}/chapters/{chapter}ৰ বাবে অধ্যায়ৰ নম্বৰ দিয়ে, যাৰ verses[]ত প্ৰতিটো শ্লোকৰ নম্বৰ থাকে।

4 কোটা

সংকলনৰ প্ৰতিটো পৃষ্ঠা, পুথিৰ সূচী আৰু অধ্যায়ৰ পৃষ্ঠাত এটাকৈ ৰিকুৱেষ্ট খৰচ হয়। বাৰখন পুথিৰ সংকলন এটাত এবাৰত তিনিখনকৈ পুথি চালে চাৰিটা ৰিকুৱেষ্ট খৰচ হয়।

ৰিকুৱেষ্টবোৰে MANTRILO_API_URLৰ পৰা base URL পঢ়ে। ছাৰ্ভাৰৰ উদাহৰণটোৱে বিকল্প হিচাপে https://api.mantrilo.com ব্যৱহাৰ কৰে।