Skip to content

Python Integration

Sven Andreas edited this page Apr 9, 2026 · 1 revision

Python Integration

Engram integrates with Python through plain HTTP. No SDK required.

For the full guide with 17 sections and working code examples, see docs/python-examples.md.

Quick Start

import requests

ENGRAM = "http://127.0.0.1:3030"

# Setup auth (first run)
requests.post(f"{ENGRAM}/auth/setup", json={
    "username": "admin", "password": "your-password"
})

# Login
token = requests.post(f"{ENGRAM}/auth/login", json={
    "username": "admin", "password": "your-password"
}).json()["token"]

headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}

# Store
requests.post(f"{ENGRAM}/store", headers=headers, json={
    "entity": "Berlin", "type": "city"
})

# Relate
requests.post(f"{ENGRAM}/relate", headers=headers, json={
    "from": "Berlin", "relationship": "capital_of", "to": "Germany"
})

# Query
result = requests.post(f"{ENGRAM}/query", headers=headers, json={
    "start": "Berlin", "depth": 2
}).json()

Topics Covered

  1. Server startup and health checks
  2. EngramClient wrapper class
  3. Storing nodes with types, properties, confidence
  4. Relationships between entities
  5. Graph traversal queries
  6. BM25 search with boolean filters
  7. Natural language /ask and /tell
  8. Learning -- reinforce, correct, decay, derive
  9. Bulk import from CSV and JSON
  10. LangChain tool integration
  11. CLI wrapper via subprocess
  12. Error handling and retries
  13. Authentication and API keys
  14. Debate sessions -- launch and synthesize
  15. Assessments -- Bayesian evidence
  16. Document ingestion -- PDF, text, fact review
  17. Chat tools -- compare, what-if, network analysis

Clone this wiki locally