Dara provides a RESTful API for document processing, summary generation, and question creation. All endpoints are prefixed with /api.
http://localhost:3000/api
For production environments, replace localhost:3000 with your deployed server URL.
Currently, Dara does not require authentication for API access. However, it implements rate limiting to prevent abuse.
- Window: 15 minutes
- Limit: 100 requests per IP
- Headers: Rate limit information included in response headers
Dara supports the following document formats:
- PDF (
.pdf) - Portable Document Format - DOCX (
.docx) - Microsoft Word documents - PPTX (
.pptx) - Microsoft PowerPoint presentations - TXT (
.txt) - Plain text files
Generate an AI-powered summary from uploaded documents.
POST /api/sumContent-Type: multipart/form-data
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
File | Yes | Document file to summarize |
Example Request:
curl -X POST \
http://localhost:3000/api/sum \
-H 'Content-Type: multipart/form-data' \
-F 'file=@/path/to/document.pdf'Success Response (200 OK):
{
"success": true,
"data": {
"summary": "This document discusses the implementation of artificial intelligence in modern business processes...",
"filename": "document.pdf",
"fileSize": 2048576,
"processedAt": "2024-01-15T10:30:00Z"
}
}Error Response (400 Bad Request):
{
"success": false,
"error": {
"message": "No file uploaded",
"code": "FILE_REQUIRED"
}
}Error Response (415 Unsupported Media Type):
{
"success": false,
"error": {
"message": "Unsupported file type: .xlsx",
"code": "UNSUPPORTED_FILE_TYPE"
}
}Generate questions based on the content of uploaded documents.
POST /api/qsContent-Type: multipart/form-data
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
file |
File | Yes | Document file to generate questions from |
Example Request:
curl -X POST \
http://localhost:3000/api/qs \
-H 'Content-Type: multipart/form-data' \
-F 'file=@/path/to/presentation.pptx'Success Response (200 OK):
{
"success": true,
"data": {
"questions": [
{
"id": 1,
"question": "What are the main benefits of implementing AI in business processes?",
"type": "open-ended",
"difficulty": "medium"
},
{
"id": 2,
"question": "Which industry sectors are mentioned as early adopters of AI technology?",
"type": "factual",
"difficulty": "easy"
},
{
"id": 3,
"question": "How might AI implementation affect employment in traditional industries?",
"type": "analytical",
"difficulty": "hard"
}
],
"filename": "presentation.pptx",
"fileSize": 1024000,
"questionCount": 3,
"processedAt": "2024-01-15T10:35:00Z"
}
}Engage in conversational AI with persistent session memory using Cohere AI.
POST /api/chatContent-Type: application/json
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
question |
String | Yes | User's question or message |
session |
String | Yes | Unique session identifier for conversation continuity |
Example Request:
curl -X POST \
http://localhost:3000/api/chat \
-H 'Content-Type: application/json' \
-d '{
"question": "What is artificial intelligence?",
"session": "user-session-123"
}'Success Response (200 OK):
{
"answer": "Artificial intelligence (AI) is a field of computer science that aims to create systems capable of performing tasks that typically require human intelligence..."
}Error Response (400 Bad Request):
{
"success": false,
"error": {
"message": "Bad Request",
"code": 400
}
}Note: Session memory is now handled in-memory only. Redis is not required or used.
| Status Code | Description |
|---|---|
200 |
Success |
400 |
Bad Request - Invalid input or missing required fields |
413 |
Payload Too Large - File size exceeds limit |
415 |
Unsupported Media Type - Invalid file format |
429 |
Too Many Requests - Rate limit exceeded |
500 |
Internal Server Error - Server processing error |
All error responses follow this structure:
{
"success": false,
"error": {
"message": "Human-readable error message",
"code": "ERROR_CODE",
"details": "Additional error details (optional)"
}
}| Error Code | Description |
|---|---|
FILE_REQUIRED |
No file was uploaded |
UNSUPPORTED_FILE_TYPE |
File format not supported |
FILE_TOO_LARGE |
File exceeds size limit |
PROCESSING_ERROR |
Error during AI processing |
RATE_LIMIT_EXCEEDED |
Too many requests |
INVALID_INPUT |
Invalid request parameters |
- Maximum file size: 10 MB
- Recommended size: Under 5 MB for optimal performance
- Requests per IP: 100 requests per 15-minute window
- Concurrent requests: 10 per IP
- Text extraction: Up to 50,000 characters per document
- Question generation: Up to 10 questions per request
- Summary length: Typically 150-500 words
- Validate file type before uploading
- Check file size to avoid upload errors
- Use descriptive filenames for better organization
- Handle upload progress for large files
- Check HTTP status codes for all responses
- Parse error messages for user feedback
- Implement retry logic for transient errors
- Log errors for debugging
- Compress files when possible
- Cache results to reduce API calls
- Process files asynchronously for better UX
- Monitor rate limits to avoid blocking
Test file upload:
curl -X POST \
http://localhost:3000/api/sum \
-F 'file=@test.pdf' \
-vTest with invalid file:
curl -X POST \
http://localhost:3000/api/sum \
-F 'file=@test.jpg' \
-vTest rate limiting:
for i in {1..101}; do
curl -X POST http://localhost:3000/api/sum \
-F 'file=@test.pdf' \
--silent --output /dev/null \
--write-out "%{http_code}\n"
doneMonitor these headers for API health:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1642248600
Content-Type: application/json
Content-Length: 256