Skip to main content

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

EndpointMethodDescription
/api/healthGETHealth check
/api/embedPOSTGenerate embeddings
/api/embed/batchPOSTBatch embeddings
/api/searchPOSTSemantic search

Conversations

EndpointMethodDescription
/api/conversationsGETList conversations
/api/conversationsPOSTCreate conversation
/api/conversations/{id}GETGet conversation
/api/conversations/{id}DELETEDelete conversation
/api/conversations/{id}/messagesGETList messages
/api/conversations/{id}/messagesPOSTCreate message
/api/conversations/{id}/chatPOSTStream chat

Context Facts

EndpointMethodDescription
/api/context-factsGETList context facts
/api/context-factsPOSTCreate context fact
/api/context-facts/{id}GETGet context fact
/api/context-facts/{id}PUTUpdate context fact
/api/context-facts/{id}DELETEDelete context fact
/api/context-facts/searchPOSTSearch context facts

Timeline

EndpointMethodDescription
/api/timelineGETList timeline events

Tokens

EndpointMethodDescription
/api/tokens/countPOSTCount tokens
/api/tokens/count/batchPOSTBatch token count
/api/tokens/estimate-costPOSTEstimate API cost
/api/tokens/modelsGETList 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

CodeDescription
200Success
201Created
400Bad Request
401Unauthorized
404Not Found
422Validation Error
500Internal Server Error