POST /query, it doesn’t just get semantically similar chunks. It gets the most useful context for that exact query - weighted by recency, relevance, relationships, and historical usage patterns.
All code in this cookbook is real. Base URL is https://api.hydradb.com. Get your API key at app.hydradb.com.
Prerequisites
Required knowledge: Python basics, REST APIs, environment variablesRequired tools:
- HydraDB API key
- Python 3.11 or 3.12 (
python --version) pip install hydradb-sdk
What You’ll Build
By the end of this cookbook, you’ll be able to:- Ingest Notion pages, Confluence docs, and Slack threads into a unified HydraDB workspace
- Answer “why did we decide X?” by retrieving decision context across linked documents
- Batch-upload documents with verified indexing before any search query
- Build a conversational interface grounded in your team’s actual knowledge
How HydraDB Works
Before writing code, understand the three primitives you’ll use throughout this cookbook:- Database - your workspace. All data is isolated per database. Think of it as your “company” in HydraDB. Create one per application.
- Memory - any unit of context: a Notion page, a Confluence doc, a Slack thread, a user preference. HydraDB automatically chunks, embeds, and connects memories into a context graph.
- Search - the retrieval call your agent makes before acting. HydraDB’s search runs a multi-stage pipeline: metadata filtering → graph traversal → semantic retrieval → personalized ranking.
Comparison: Traditional RAG vs HydraDB Search
Step 01 - Create a Database
Every HydraDB workspace starts with a database. Create one for your knowledge base - it provides complete data isolation and multi-tenant support out of the box. Endpoint:POST /databases - Create your workspace
Bash
Python
Collections for teams: Use collection to isolate data by department. Engineering, Sales, HR each get their own namespace within your database - no configuration needed, just pass the ID on upload.
Step 02 - Upload Knowledge Memories
HydraDB automatically parses, chunks, embeds, and connects your content into a context graph. You don’t manage embeddings or vector indexes. You just upload.Notion Connector
Fetch pages from Notion, format them into HydraDB’s app source structure, and batch upload. HydraDB builds the context graph automatically - no edge creation needed.Batch limit: Max 20 sources per request. Wait 1 second between batches to respect rate limits.
Confluence Connector
Confluence pages follow the same upload format. Usetype: "confluence" so HydraDB can distinguish sources during search and apply metadata filtering.
Verify Indexing
After uploading, always verify that HydraDB has fully processed and indexed your content before running search queries. Endpoint:GET /context/status?ids=ID&database=DATABASE - Check indexing status
Step 03 - Add User Memories
Beyond documents, HydraDB stores user memories - preferences, habits, and patterns that personalize search per user. Setinfer: true to let HydraDB extract implicit signals from text. Set infer: false to store facts verbatim.
Endpoint: POST /context/ingest - Add a user memory
Bash
Python
Step 04 - Search Context
This is the call your agent makes before answering any question.POST /query runs HydraDB’s full multi-stage pipeline and returns ranked, contextually relevant chunks - including graph context showing relationships between entities.
Endpoint: POST /query - Retrieve agent context
Step 05 - Search and Answer Generation
For conversational, AI-generated answers, first retrieve context withPOST /query. Then pass the returned chunks and sources into your application-layer LLM prompt. Key parameters: alpha (0-1, balance semantic vs keyword bm25), recency_bias (0-1, prefer newer content), and graph_context.
Endpoint: POST /query - retrieved context for app-layer answer generation
Maintaining conversation context: Store chat history in your application and include relevant prior turns in your LLM prompt. HydraDB returns retrieval context; your app owns the final answer and conversation state.
Step 06 - Slack Interface
Expose your knowledge base as a Slack bot. When a user mentions@wiki, the bot calls ask_workspace() to retrieve context, then your application can pass that context to an LLM for the final Slack response.
API Reference
All endpoints used in this cookbook. Base URL:https://api.hydradb.com. Header: Authorization: Bearer YOUR_API_KEY
Database management
POST/databases - Create workspace - idempotent
Upload app sources (Notion, Slack, Confluence…)
POST/context/ingest - Max 20/call, 1s between batches
Upload a single file (PDF / DOCX)
POST/context/ingest - Single file with database as form field
Verify processing
GET/context/status?ids=ID&database=YOUR_DATABASE - Poll until status = “completed”
Full search
POST/query - Searches knowledge base - returns chunks + graph_context
Search for answer generation
POST/query - retrieved context for app-layer answer generation
Add user memory
POST/context/ingest - memories[] array wrapper - consistent SDK format
Search user memories
POST/query - user_name key - consistent across all calls
Delete memory
DELETE/context - Remove stale or incorrect memory data with type: "memory" and request.ids
Benchmarks
HydraDB leads LongMemEvals with 90% search accuracy. Compared to a naive RAG pipeline over the same 12,400-document corpus:Benchmark methodology. Figures are based on internal HydraDB testing. For the formal benchmark paper see research.hydradb.com/hydradb.pdf. Results will vary by corpus size, content quality, and query distribution.