REST API Reference
The Engram API provides programmatic access to all features of the semantic search system.
Base URL
http://localhost:8000/api
Authentication
The API uses JWT bearer token authentication. Include the token in the Authorization header:
Authorization: Bearer <your-token>
Interactive API Explorer
tip
You can also download the OpenAPI specification directly for use with API clients like Postman or Insomnia.
API Endpoints Overview
Core Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/health | GET | Health check |
/api/embed | POST | Generate embeddings |
/api/embed/batch | POST | Batch embeddings |
/api/search | POST | Semantic search |
Conversations
| Endpoint | Method | Description |
|---|---|---|
/api/conversations | GET | List conversations |
/api/conversations | POST | Create conversation |
/api/conversations/{id} | GET | Get conversation |
/api/conversations/{id} | DELETE | Delete conversation |
/api/conversations/{id}/messages | GET | List messages |
/api/conversations/{id}/messages | POST | Create message |
/api/conversations/{id}/chat | POST | Stream chat |
Context Facts
| Endpoint | Method | Description |
|---|---|---|
/api/context-facts | GET | List context facts |
/api/context-facts | POST | Create context fact |
/api/context-facts/{id} | GET | Get context fact |
/api/context-facts/{id} | PUT | Update context fact |
/api/context-facts/{id} | DELETE | Delete context fact |
/api/context-facts/search | POST | Search context facts |
Timeline
| Endpoint | Method | Description |
|---|---|---|
/api/timeline | GET | List timeline events |
Tokens
| Endpoint | Method | Description |
|---|---|---|
/api/tokens/count | POST | Count tokens |
/api/tokens/count/batch | POST | Batch token count |
/api/tokens/estimate-cost | POST | Estimate API cost |
/api/tokens/models | GET | List supported models |
Response Format
All responses are JSON formatted:
{
"data": { ... },
"meta": {
"total": 100,
"page": 1,
"per_page": 20
}
}
Error Handling
Errors return appropriate HTTP status codes with a JSON body:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request parameters",
"details": { ... }
}
}
Common Status Codes
| Code | Description |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Bad Request |
| 401 | Unauthorized |
| 404 | Not Found |
| 422 | Validation Error |
| 500 | Internal Server Error |