Skip to main content

Overview

The GitaChat API provides programmatic access to the Bhagavad Gita with semantic search, verse retrieval, bookmarks, notes, and daily verse features. The API uses REST principles with JSON request and response bodies.

Base URLs

GitaChat operates with two API layers:

Backend API

Production: https://api.gitachat.orgLocal: http://localhost:8000Direct access to vector search and verse data

Frontend API

Production: https://gitachat.org/apiLocal: http://localhost:3000/apiUser features with Clerk authentication

Rate Limiting

GitaChat implements rate limiting to ensure fair usage and system stability. Limits are applied per IP address or authenticated user.

Backend Rate Limits (SlowAPI)

The backend uses SlowAPI with IP-based rate limiting:
  • Query Endpoint: 30 requests per minute
  • Verse Endpoint: 30 requests per minute
  • All Verses: 10 requests per minute

Frontend Rate Limits

Frontend endpoints have additional per-user rate limiting:

Query Search

20 requests per minute

Verse Retrieval

60 requests per minute

Bookmarks

30 requests per minute

Notes

No explicit limit (Clerk auth required)

History

30 requests per minute (GET)5 requests per minute (DELETE)

Daily Verse

10 requests per minute

Email Subscription

10 requests per minute

Image Generation

5 requests per hour (most restrictive)

Rate Limit Response

When rate limited, you’ll receive a 429 Too Many Requests response:
{
  "error": "Too many requests. Please try again later."
}
For image generation, the error includes time remaining:
{
  "error": "Rate limit reached. Try again in 45 minutes."
}

Response Format

All API responses follow a consistent structure:

Success Response

{
  "status": "success",
  "data": {
    // Response data here
  }
}

Error Response

{
  "error": "Error message description"
}
Common HTTP status codes:
  • 200 - Success
  • 400 - Bad Request (invalid parameters)
  • 401 - Unauthorized (authentication required)
  • 404 - Not Found
  • 429 - Too Many Requests (rate limited)
  • 500 - Internal Server Error
  • 503 - Service Unavailable (database not configured)
  • 504 - Gateway Timeout

Available Endpoints

Query Search

Semantic search using natural language queries

Get Specific Verse

Retrieve verse by chapter and verse number

Get All Verses

Fetch all 703 verses for client-side search

Bookmarks

Save and manage favorite verses

Notes

Create personal notes on verses

Query History

Access your search history

Daily Verse

Get personalized daily verse

Email Subscription

Manage daily email preferences

Generate Image

Create AI images for verses

Health Check

Backend service status
Search for relevant verses using natural language queries with semantic matching. Endpoint: POST /api/query Rate Limit: 30/minute (backend), 20/minute (frontend) Request Body:
query
string
required
Natural language query (1-500 characters)
Example Request:
curl -X POST https://api.gitachat.org/api/query \
  -H "Content-Type: application/json" \
  -d '{"query": "How do I overcome fear and anxiety?"}'
Response:
status
string
Always “success” for successful requests
data
object
chapter
integer
Chapter number (1-18)
verse
integer
Verse number within chapter
translation
string
English translation of the verse
summarized_commentary
string
Contextual commentary tailored to the query
full_commentary
string
Complete traditional commentary (optional)
Example Response:
{
  "status": "success",
  "data": {
    "chapter": 2,
    "verse": 47,
    "translation": "You have a right to perform your prescribed duty, but you are not entitled to the fruits of action...",
    "summarized_commentary": "This verse addresses anxiety by teaching detachment from outcomes...",
    "full_commentary": "Traditional commentary explaining the verse in detail..."
  }
}

Get Verse

Retrieve a specific verse by chapter and verse number. Endpoint: POST /api/verse Rate Limit: 30/minute (backend), 60/minute (frontend) Request Body:
chapter
integer
required
Chapter number (1-18)
verse
integer
required
Verse number (1-78, varies by chapter)
Example Request:
curl -X POST https://api.gitachat.org/api/verse \
  -H "Content-Type: application/json" \
  -d '{"chapter": 2, "verse": 47}'
Response: Same format as Query Search endpoint.

All Verses

Retrieve all 703 verses with chapter, verse, translation, and summary data. Endpoint: GET /api/all-verses Rate Limit: 10/minute Cache: Responses cached for 1 hour Example Request:
curl https://api.gitachat.org/api/all-verses
Response:
{
  "status": "success",
  "data": [
    {
      "chapter": 1,
      "verse": 1,
      "translation": "Dhritarashtra said: O Sanjaya...",
      "summary": "Brief summary (max 500 chars)"
    },
    // ... 702 more verses
  ]
}

Bookmarks

Manage saved verses (requires authentication). Base Endpoint: /api/bookmarks

GET - List Bookmarks

Rate Limit: 30/minute Authentication: Required (Clerk token) Example Request:
curl https://gitachat.org/api/bookmarks \
  -H "Authorization: Bearer YOUR_CLERK_TOKEN"
Response:
[
  {
    "id": "uuid",
    "user_id": "user_xxx",
    "chapter": 2,
    "verse": 47,
    "translation": "You have a right to perform...",
    "summarized_commentary": "This verse teaches...",
    "created_at": "2024-01-15T10:30:00Z"
  }
]

POST - Add Bookmark

Request Body:
chapter
integer
required
Chapter number
verse
integer
required
Verse number
translation
string
required
Verse translation text
summarized_commentary
string
required
Commentary text

DELETE - Remove Bookmark

Query Parameters:
chapter
integer
required
Chapter number
verse
integer
required
Verse number
Example:
curl -X DELETE "https://gitachat.org/api/bookmarks?chapter=2&verse=47" \
  -H "Authorization: Bearer YOUR_CLERK_TOKEN"

Notes

Create personal notes on verses (requires authentication). Base Endpoint: /api/notes

GET - Fetch Notes

Fetch a specific note or all user notes. Query Parameters (optional):
chapter
integer
Chapter number (with verse for specific note)
verse
integer
Verse number (with chapter for specific note)

POST - Save Note

Request Body:
chapter
integer
required
Chapter number
verse
integer
required
Verse number
note_text
string
required
Note content (max 5000 characters)

DELETE - Remove Note

Query Parameters:
chapter
integer
required
Chapter number
verse
integer
required
Verse number

History

Access query search history (requires authentication). Base Endpoint: /api/history

GET - Fetch History

Rate Limit: 30/minute Response:
[
  {
    "id": "uuid",
    "user_id": "user_xxx",
    "query": "How to overcome fear?",
    "chapter": 2,
    "verse": 47,
    "translation": "...",
    "summarized_commentary": "...",
    "created_at": "2024-01-15T10:30:00Z"
  }
]

DELETE - Clear History

Rate Limit: 5/minute Deletes all query history for the authenticated user.

Daily Verse

Get personalized daily verse (prioritizes unseen verses). Endpoint: GET /api/daily Rate Limit: 10/minute Authentication: Required Query Parameters:
tz
string
Timezone (e.g., “America/New_York”, defaults to “UTC”)
Response:
{
  "chapter": 3,
  "verse": 21,
  "translation": "Whatever action a great man performs...",
  "summarized_commentary": "...",
  "cached": false
}

Email Subscription

Manage daily email verse subscriptions. Base Endpoint: /api/email-subscription Rate Limit: 10/minute

GET - Check Status

Response:
{
  "subscribed": true,
  "timezone": "America/New_York"
}

POST - Subscribe

Request Body:
timezone
string
User’s timezone (defaults to “UTC”)

DELETE - Unsubscribe

Sets subscription to inactive.

Generate Image

Generate AI-powered images for verses using Replicate. Endpoint: POST /api/generate-image Rate Limit: 5 per hour (strictest limit) Authentication: Required Request Body:
chapter
integer
required
Chapter number
verse
integer
required
Verse number
translation
string
required
Verse translation text
Response:
{
  "imageUrl": "https://storage.example.com/verse-images/2-47-hash.webp",
  "shareUrl": "https://gitachat.org/image/uuid",
  "cached": false
}

GET - Check Existing Image

Query Parameters:
chapter
integer
required
Chapter number
verse
integer
required
Verse number
Response:
{
  "exists": true,
  "imageUrl": "...",
  "shareUrl": "..."
}

Health

Check backend service status. Endpoint: GET /health No Rate Limit Response:
{
  "status": "ok"
}

CORS Policy

The backend accepts requests from:
  • http://localhost:3000 (development)
  • https://gitachat.org (production)
  • https://www.gitachat.org (production)
Allowed Methods: GET, POST, OPTIONS Allowed Headers: Content-Type, Authorization Credentials: Enabled

Technical Implementation

Vector Search

Uses Pinecone with BGE-base embeddings (768-dim)

Model

BAAI/bge-base-en-v1.5 for semantic search

Database

Supabase (PostgreSQL) for user data

Authentication

Clerk for user management

Best Practices

  1. Respect Rate Limits: Implement exponential backoff for 429 responses
  2. Cache Responses: The /api/all-verses endpoint is cached for 1 hour
  3. Handle Timeouts: Backend requests timeout after 30 seconds (15s for verse)
  4. Validate Input: Chapters range 1-18, verses vary (max 78 in chapter 18)
  5. Use HTTPS: Always use HTTPS in production
  6. Store Tokens Securely: Never expose API tokens in client-side code

Need Help?

For support with the GitaChat API, visit gitachat.org or check the authentication documentation.

Build docs developers (and LLMs) love