API

This API reference is automatically generated from the catch-all route file /api/[...name]/route.ts using the new Nextra <TSDoc /> component.

Auto-Generated API Documentation

The following API endpoints are automatically documented from our TypeScript route handlers:

GET Endpoints

GET /api/status

Returns the current status of the Cognee API service. Parameters:
  • request: NextRequest - The incoming HTTP request
  • params: { name: string[] } - Route parameters containing the API endpoint name
Returns: Promise<NextResponse>
  • Success: { status: 'ok', service: 'cognee-api' }

GET /api/health

Returns health check information including timestamp and version. Parameters:
  • request: NextRequest - The incoming HTTP request
  • params: { name: string[] } - Route parameters containing the API endpoint name
Returns: Promise<NextResponse>
  • Success: { status: 'healthy', timestamp: string, version: string }

POST Endpoints

POST /api/add

Add content to the Cognee knowledge graph. Parameters:
  • request: NextRequest - The incoming HTTP request with JSON body
  • params: { name: string[] } - Route parameters containing the API endpoint name
Request Body:
{
  "content": "string - Text content to add to the knowledge graph"
}
Returns: Promise<NextResponse>
  • Success: { message: 'Content added successfully', data: object }

POST /api/cognify

Process and build the knowledge graph from added content. Parameters:
  • request: NextRequest - The incoming HTTP request with JSON body
  • params: { name: string[] } - Route parameters containing the API endpoint name
Returns: Promise<NextResponse>
  • Success: { message: 'Cognify operation completed', status: 'processed' }

POST /api/search

Search the knowledge graph with a given query. Parameters:
  • request: NextRequest - The incoming HTTP request with JSON body
  • params: { name: string[] } - Route parameters containing the API endpoint name
Request Body:
{
  "query": "string - Search query text"
}
Returns: Promise<NextResponse>
  • Success: { message: 'Search completed', query: string, results: array }

DELETE Endpoints

DELETE /api/prune

Clean up and reset data in the knowledge graph. Parameters:
  • request: NextRequest - The incoming HTTP request
  • params: { name: string[] } - Route parameters containing the API endpoint name
Returns: Promise<NextResponse>
  • Success: { message: 'Prune operation completed', deleted: true }

Implementation Details

All endpoints are implemented in the catch-all route file located at:
src/app/api/[...name]/route.ts
This route handler automatically processes API calls and routes them to the appropriate functions based on the HTTP method and path.

Available Endpoints

The catch-all route supports the following endpoints:

GET Endpoints

  • /api/status - Returns the API status
  • /api/health - Returns health check information

POST Endpoints

  • /api/add - Add content to the knowledge graph
  • /api/cognify - Process and build the knowledge graph
  • /api/search - Search the knowledge graph

DELETE Endpoints

  • /api/prune - Clean up and reset data

Usage Examples

Status Check

curl https://docs.cognee.ai/api/status

Add Content

curl -X POST https://docs.cognee.ai/api/add \
  -H "Content-Type: application/json" \
  -d '{"content": "Your content here"}'
curl -X POST https://docs.cognee.ai/api/search \
  -H "Content-Type: application/json" \
  -d '{"query": "search term"}'

Integration Benefits

Using the <TSDoc /> component provides several advantages:
  1. Automatic Updates - Documentation stays in sync with code changes
  2. Type Safety - TypeScript definitions are automatically extracted
  3. Rich Formatting - JSDoc comments are rendered as formatted documentation
  4. Interactive - Users can see exact parameter types and return values
  5. Maintainable - Single source of truth for API specifications
This approach ensures that our API documentation is always accurate and up-to-date with the actual implementation.