Query API
Query API
Query the BrainUs knowledge base with RAG-powered search
The Query API is the core endpoint for retrieving educational content from the BrainUs knowledge base. It uses Retrieval-Augmented Generation (RAG) to provide accurate answers with verifiable citations.
Endpoint
POST /api/v1/dev/queryBase URL: https://api.brainus.lk
Authentication
All requests require authentication using your API key. See Authentication for details.
X-API-Key: $BRAINUS_API_KEYQuick Example
Get started with our official SDKs or use direct HTTP requests:
import asyncio
from brainus_ai import BrainusAI
async def main():
client = BrainusAI(api_key="your_api_key")
response = await client.query(
query="What is photosynthesis?"
)
print(response.answer)
for citation in response.citations:
print(f"Source: {citation.document_name}")
asyncio.run(main())import { BrainusAI } from '@brainus/ai';
const client = new BrainusAI({ apiKey: 'your_api_key' });
const response = await client.query({
query: 'What is photosynthesis?'
});
console.log(response.answer);
response.citations.forEach(citation => {
console.log(`Source: ${citation.documentName}`);
});curl -X POST https://api.brainus.lk/api/v1/dev/query \
-H "X-API-Key: $BRAINUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "What is photosynthesis?",
"store_id": "default"
}'Request Parameters
Prop
Type
Response Format
Response Body
Prop
Type
Citation Object
Prop
Type
Example Response:
{
"answer": "Great question! Python is a high-level, interpreted programming language...",
"citations": [
{
"document_id": "",
"document_name": "al-ict-lesson09-ictfromabc.pdf",
"pages": [1, 2, 3],
"metadata": null,
"chunk_text": "--- PAGE 1 ---\n\nPython is a high-level, interpreted programming language..."
}
],
"has_citations": true
}All responses include citations from official Sri Lankan curriculum documents, ensuring verifiable answers.
Next Steps
- Basic Usage - Learn how to make basic queries
- Filters & Options - Advanced filtering and options
- Best Practices - Optimization tips and patterns
Rate Limits
Query API requests count against your rate limits:
| Plan | Requests/min | Requests/day | Requests/month |
|---|---|---|---|
| Free | 10 | 300 | 300 |
| Starter | 20 | 2,000 | 2,000 |
| Pro | 60 | 10,000 | 10,000 |
| Enterprise | 200 | 50,000 | 50,000 |