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 dataFrontend API
Production:
https://gitachat.org/apiLocal: http://localhost:3000/apiUser features with Clerk authenticationRate 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 a429 Too Many Requests response:
Response Format
All API responses follow a consistent structure:Success Response
Error Response
200- Success400- Bad Request (invalid parameters)401- Unauthorized (authentication required)404- Not Found429- Too Many Requests (rate limited)500- Internal Server Error503- 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
Query Search
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:
Natural language query (1-500 characters)
Always “success” for successful requests
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 number (1-18)
Verse number (1-78, varies by chapter)
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:
Bookmarks
Manage saved verses (requires authentication). Base Endpoint:/api/bookmarks
GET - List Bookmarks
Rate Limit: 30/minute Authentication: Required (Clerk token) Example Request:POST - Add Bookmark
Request Body:Chapter number
Verse number
Verse translation text
Commentary text
DELETE - Remove Bookmark
Query Parameters:Chapter number
Verse number
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 number (with verse for specific note)
Verse number (with chapter for specific note)
POST - Save Note
Request Body:Chapter number
Verse number
Note content (max 5000 characters)
DELETE - Remove Note
Query Parameters:Chapter number
Verse number
History
Access query search history (requires authentication). Base Endpoint:/api/history
GET - Fetch History
Rate Limit: 30/minute Response: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:
Timezone (e.g., “America/New_York”, defaults to “UTC”)
Email Subscription
Manage daily email verse subscriptions. Base Endpoint:/api/email-subscription
Rate Limit: 10/minute
GET - Check Status
Response:POST - Subscribe
Request Body: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 number
Verse number
Verse translation text
GET - Check Existing Image
Query Parameters:Chapter number
Verse number
Health
Check backend service status. Endpoint:GET /health
No Rate Limit
Response:
CORS Policy
The backend accepts requests from:http://localhost:3000(development)https://gitachat.org(production)https://www.gitachat.org(production)
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
- Respect Rate Limits: Implement exponential backoff for 429 responses
- Cache Responses: The
/api/all-versesendpoint is cached for 1 hour - Handle Timeouts: Backend requests timeout after 30 seconds (15s for verse)
- Validate Input: Chapters range 1-18, verses vary (max 78 in chapter 18)
- Use HTTPS: Always use HTTPS in production
- Store Tokens Securely: Never expose API tokens in client-side code