ವಿಷಯಕ್ಕೆ ನೇರವಾಗಿ ಹೋಗಿ
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 ಕೋಟಾ

ಪ್ರತಿ ಸಂಗ್ರಹ ಪುಟ, ಪುಸ್ತಕ ಸೂಚಿ ಮತ್ತು ಅಧ್ಯಾಯ ಪುಟ ಒಂದು ವಿನಂತಿಯನ್ನು ಬಳಸುತ್ತದೆ. ಹನ್ನೆರಡು ಪುಸ್ತಕಗಳ ಸಂಗ್ರಹದಲ್ಲಿ ಒಮ್ಮೆಗೆ ಮೂರು ಪುಸ್ತಕಗಳಂತೆ ಪುಟ ಸರಿಸಿದರೆ ನಾಲ್ಕು ವಿನಂತಿಗಳು ಬಳಕೆಯಾಗುತ್ತವೆ.

ವಿನಂತಿಗಳು base URL ಅನ್ನು MANTRILO_API_URL ನಿಂದ ಓದುತ್ತವೆ. ಸರ್ವರ್ ಉದಾಹರಣೆಯು https://api.mantrilo.com ಅನ್ನು ಪರ್ಯಾಯವಾಗಿ ಬಳಸುತ್ತದೆ.