Shruti API

Scripture-grounded AI answers for your applications.

v1 — Livehttps://shruti-production.up.railway.app/api/v1

Available Books

Currently indexed scriptures. Use the slug when making requests.

NameSlugTraditionVerses
Bhagavad Gitabhagavad-gitaHinduism701
QuranquranIslam6,236
Bible (KJV)bible-kjvChristianity31,100
Valmiki Ramayanavalmiki-ramayanaHinduism23,402
Book of Mormonbook-of-mormonChristianity (LDS)6,604
Hanuman Chalisahanuman-chalisaHinduism42
Guru Granth Sahibguru-granth-sahibSikhism60,403
DhammapadadhammapadaBuddhism423
Tao Te Chingtao-te-chingTaoism253
More scriptures are being added. Use GET /api/v1/ask for the live, up-to-date list.

List Books

GET/api/v1/ask

Returns all available books with their IDs and slugs.

Example Request

curl https://shruti-production.up.railway.app/api/v1/ask

Response

{
  "success": true,
  "books": [
    {
      "id": "4dec3f68-...",
      "name": "Bhagavad Gita",
      "slug": "bhagavad-gita",
      "tradition": "Hinduism",
      "language": "Sanskrit/English",
      "description": null
    },
    ...
  ]
}

Ask a Question

POST/api/v1/ask

Ask a question grounded in one or more scriptures. Returns a short answer, detailed explanation, and verse citations.

Request Body

FieldTypeRequiredDescription
questionstringYesThe question to ask (max 2000 chars)
booksstring[]Yes*Array of book slugs, e.g. ["bhagavad-gita", "quran"]
book_idsstring[]Yes*Alternative: array of book UUIDs. Use books or book_ids.
languagestringNoOutput language code (default: en). Supports: hi, ar, sa, pa, ur, bn, ta, te, es, fr, de, pt, id, ms, tr

* Provide either books (slugs) or book_ids (UUIDs). At least one is required.

Single Book — Example

curl -X POST https://shruti-production.up.railway.app/api/v1/ask \
  -H "Content-Type: application/json" \
  -d '{
    "question": "What does Krishna say about duty?",
    "books": ["bhagavad-gita"]
  }'

Multiple Books — Example

curl -X POST https://shruti-production.up.railway.app/api/v1/ask \
  -H "Content-Type: application/json" \
  -d '{
    "question": "What is the meaning of life?",
    "books": ["bhagavad-gita", "quran", "bible-kjv"],
    "language": "en"
  }'

Hindi Output — Example

curl -X POST https://shruti-production.up.railway.app/api/v1/ask \
  -H "Content-Type: application/json" \
  -d '{
    "question": "कर्म क्या है?",
    "books": ["bhagavad-gita"],
    "language": "hi"
  }'

Response

{
  "success": true,
  "short_answer": "Krishna teaches that duty (dharma) must be performed without attachment to results. Focus on the action itself, not its fruits.",
  "detailed_answer": "In the Bhagavad Gita, Lord Krishna extensively discusses the concept of duty...[Source: Bhagavad Gita 2:47]...[Source: Bhagavad Gita 3:19]...",
  "full_answer": "**Short Answer:** Krishna teaches that...

**Detailed Explanation:** In the Bhagavad Gita...",
  "citations": [
    {
      "book": "Bhagavad Gita",
      "chapter": "2",
      "verse": "47",
      "text": "You have a right to perform your prescribed duty, but you are not entitled to the fruits of action..."
    },
    {
      "book": "Bhagavad Gita",
      "chapter": "3",
      "verse": "19",
      "text": "Therefore, without being attached to the fruits of activities..."
    }
  ],
  "query_id": "a1b2c3d4-...",
  "language": "en"
}

Response Fields

FieldTypeDescription
successbooleanWhether the request succeeded
short_answerstring1-3 sentence concise answer — ideal for chat UIs, WhatsApp, notifications
detailed_answerstringFuller explanation with verse references — use for "Read more" or detail views
full_answerstringRaw complete answer (includes both short + detailed with markdown formatting)
citationsarrayVerse references with book, chapter, verse, and excerpt text
query_idstringUnique ID for this query (for tracking)
languagestringOutput language used

Errors

StatusMeaning
400Missing or invalid fields (question, books)
404Book slug not found — check available slugs via GET
500Internal server error

Error Response

{
  "success": false,
  "error": "Books not found: ramayan",
  "available_books": "Use GET /api/v1/ask to list available books"
}

Integration Examples

JavaScript / Node.js

const response = await fetch(
  "https://shruti-production.up.railway.app/api/v1/ask",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      question: "How should I deal with anger?",
      books: ["bhagavad-gita", "quran"],
      language: "en",
    }),
  }
);

const data = await response.json();

console.log(data.short_answer);   // Quick answer
console.log(data.citations);      // Verse references

Python

import requests

response = requests.post(
    "https://shruti-production.up.railway.app/api/v1/ask",
    json={
        "question": "How should I deal with anger?",
        "books": ["bhagavad-gita", "quran"],
        "language": "en",
    },
)

data = response.json()
print(data["short_answer"])
print(data["citations"])

Limits

  • Question length: max 2,000 characters
  • Books per request: 1 to all available
  • Response time: typically 3-8 seconds
  • Cost per query: ~$0.001

Shruti provides AI-generated responses grounded in selected texts. Interpretations may vary by tradition, translation, and commentary.