Cognee API Reference

Welcome to the Cognee API documentation. This comprehensive reference covers all endpoints for building, managing, and querying your memory using Cognee’s powerful platform.

Getting Started

Before using the API, you need to choose how to run Cognee. You have two main options:

Cogwit (Cloud)

Managed Cloud PlatformProduction-ready, fully managed service with automatic scaling and enterprise features.

Local Docker Setup

Self-Hosted DevelopmentRun Cognee locally using Docker for development, testing, and custom deployments.

Setup Options

Managed Service - Recommended for Production
  1. Sign up at platform.cognee.ai
  2. Create API Key in your dashboard
  3. Start using the API immediately
# Base URL for Cogwit
BASE_URL="https://api.cognee.ai"

# Authentication
curl -H "X-Api-Key: YOUR-API-KEY" \
     -H "Content-Type: application/json" \
     $BASE_URL/api/health
Cogwit provides enterprise-grade infrastructure with automatic scaling, managed databases, and 24/7 monitoring.

API Base URLs

Production (Cogwit)

Authentication

API Key AuthenticationAll requests require an API key in the header:
X-Api-Key: YOUR-API-KEY
Content-Type: application/json
Get your API key from the Cogwit dashboard.

Core API Endpoints

The Cognee API provides endpoints for the complete knowledge graph lifecycle:

Data Ingestion

POST /api/addAdd text, documents, or structured data to your knowledge base.

Knowledge Processing

POST /api/cognifyTransform raw data into structured knowledge graphs with entities and relationships.

Semantic Search

POST /api/searchQuery your knowledge graph using natural language or structured queries.

Data Management

DELETE /api/deleteRemove specific data items or entire datasets from your knowledge base.

API Features

Quick Example

Here’s a complete example using the API:
import requests

# Configuration
BASE_URL = "http://localhost:8000"  # or https://api.cognee.ai for Cogwit
API_KEY = "your-api-key"  # only for Cogwit

headers = {
    "Content-Type": "application/json",
    "X-Api-Key": API_KEY  # only for Cogwit
}

# 1. Add data
add_response = requests.post(
    f"{BASE_URL}/api/add",
    json={"data": "AI is transforming how we work and live."},
    headers=headers
)

# 2. Process into knowledge graph
cognify_response = requests.post(
    f"{BASE_URL}/api/cognify",
    json={"datasets": ["main_dataset"]},
    headers=headers
)

# 3. Search the knowledge graph
search_response = requests.post(
    f"{BASE_URL}/api/search",
    json={
        "query": "What is AI?",
        "search_type": "GRAPH_COMPLETION"
    },
    headers=headers
)

print(search_response.json())

Interactive API Explorer

OpenAPI Specification

Try the API interactivelyAll endpoints below are automatically generated from our OpenAPI specification, providing interactive examples and real-time testing capabilities.

Error Handling

All API endpoints return standard HTTP status codes:
  • 200: Success
  • 400: Bad Request - Invalid parameters
  • 401: Unauthorized - Invalid or missing API key
  • 404: Not Found - Resource doesn’t exist
  • 429: Too Many Requests - Rate limit exceeded
  • 500: Internal Server Error - Server-side error
Always implement proper error handling in your applications to gracefully handle API failures and rate limits.

Next Steps