ମୂଳ ବିଷୟବସ୍ତୁକୁ ଯାଆନ୍ତୁ
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 ରୁ ବେସ୍ URL ପଢ଼େ। ସର୍ଭର ଉଦାହରଣଟି ଡିଫଲ୍ଟ ଭାବେ https://api.mantrilo.com ବ୍ୟବହାର କରେ।