RAG API Documentation
The complete developer guide to building with the Yardee Vector Database API. Integrate AI-powered search into your applications in minutes.
Quick Start
Get started with the Vector Database API in minutes.
1. Authentication
All API requests require authentication using your API key in the Authorization header. Get your key from the dashboard.
curl -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
https://app.yardee.ai/api/v1/knowledgebases/
2. Base URL
https://app.yardee.ai/api/v1/
3. Response Format
All responses are in JSON format with consistent error handling.
// Success Response
{
"knowledge_bases": [...],
"count": 5
}
// Error Response
{
"error": "Invalid API key",
"details": "The provided API key is not valid or has expired"
}
Knowledge Base Management
Create and manage your vector knowledge bases.
List Knowledge Bases
GET /api/v1/knowledgebases/
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://app.yardee.ai/api/v1/knowledgebases/
Response:
{
"knowledge_bases": [
{
"id": 1,
"name": "Product Documentation",
"description": "API-accessible product docs",
"api_enabled": true,
"created_at": "2025-01-10T09:00:00Z"
}
],
"count": 1
}
Create Knowledge Base
POST /api/v1/knowledgebases/
curl -X POST https://app.yardee.ai/api/v1/knowledgebases/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type": "application/json" \
-d '{
"name": "Customer Support KB",
"description": "Knowledge base for customer support queries"
}'
Response:
{
"id": 2,
"name": "Customer Support KB",
"description": "Knowledge base for customer support queries",
"api_enabled": true,
"created_at": "2025-01-20T10:30:00Z"
}
Update Knowledge Base
PUT /api/v1/knowledgebases/{id}/
curl -X PUT https://app.yardee.ai/api/v1/knowledgebases/2/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type": "application/json" \
-d '{
"name": "Updated KB Name",
"description": "Updated description"
}'
Vector Search - Core Feature
Perform semantic search across your knowledge bases.
Basic Vector Search
POST /api/v1/knowledgebases/{id}/search/
curl -X POST https://app.yardee.ai/api/v1/knowledgebases/1/search/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "What is your return policy?",
"top_k": 5,
"chat_history": [
{"role": "user", "content": "Do you have a policy for returns?"},
{"role": "assistant", "content": "Yes, we do. What would you like to know?"}
]
}'
Response:
{
"query": "What was the total sales for the North region?",
"knowledge_base_id": 1,
"total_results": 2,
"results": [
{
"chunk": null,
"content": "The total sales for the North region was $150,000.",
"similarity_score": null,
"document_title": "sales_data.csv",
"metadata": {
"type": "agentic_search",
"source": "sales_data.csv"
}
},
{
"chunk": {
"id": 123,
"content": "Our return policy allows returns within 30 days...",
"chunk_index": 0,
"document_id": 45
},
"content": "Our return policy allows returns within 30 days...",
"similarity_score": 0.8945,
"document_title": "Return Policy Guide.pdf",
"metadata": {"page": 1, "section": "returns"}
}
],
"parameters": {
"top_k": 5,
"similarity_threshold": 0.1,
"use_mmr": true
}
}
Advanced Search Parameters
{
"query": "customer support escalation process",
"top_k": 10, // Number of results (default: 5)
"similarity_threshold": 0.3, // Minimum similarity score (default: 0.1)
"use_mmr": true, // Use MMR for diversity (default: true)
"metadata_filters": { // Filter by document metadata
"department": "support",
"status": "active"
},
"chat_history": [ // Optional: For structured data queries only
{"role": "user", "content": "Show me sales data"},
{"role": "assistant", "content": "Here's the sales information..."},
{"role": "user", "content": "What about the top performers?"}
]
}
Agentic Search for Structured Data
When you upload structured files like CSV or Excel, the API automatically uses an "Agentic Search" mode. Instead of returning text chunks, the API analyzes the file and provides a direct answer to your query. This is ideal for querying data tables.
💡 Chat History Support: The chat_history
parameter is only supported for structured data queries (CSV/Excel files). It enables conversational context for data analysis, allowing follow-up questions like "show me the top 5" followed by "what about the bottom 5?"
// Querying a CSV for specific data
{
"query": "How many users signed up in May?",
"top_k": 1
}
// Agentic Search Response
{
"query": "How many users signed up in May?",
"total_results": 1,
"results": [
{
"chunk": null,
"content": "There were 1,234 users who signed up in May.",
"document_title": "user_signups.csv",
"metadata": { "type": "agentic_search", "source": "user_signups.csv" }
}
]
}
Live Database Connections
Connect PostgreSQL, MySQL, and SQL Server databases for real-time AI-powered querying.
FREEQuery your live databases with natural language - included in all plans!
Quick Start
Connect your database and start asking questions in natural language. The API analyzes your query, generates SQL, and returns results as natural language answers.
# 1. Add your database connection
curl -X POST https://app.yardee.ai/api/v1/knowledgebases/123/connections/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"connection_type": "database",
"database_type": "postgresql",
"host": "your-db.example.com",
"port": 5432,
"database_name": "your_database",
"username": "readonly_user",
"password": "secure_password"
}'
# 2. Query with natural language using the same search endpoint
curl -X POST https://app.yardee.ai/api/v1/knowledgebases/123/search/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "How many customers do we have?",
"top_k": 1
}'
# Response includes database results
{
"results": [
{
"content": "You currently have 15,847 customers in your database.",
"document_title": "live_database_connection",
"metadata": {
"type": "live_database_query",
"source": "Production Database"
}
}
]
}
Supported Database Types
Key Features
- Real-time query execution
- Natural language to SQL conversion
- SSH tunnel support for secure connections
- Mixed results with document search
- Read-only access for data security
Document Management
Upload and manage documents in your knowledge bases.
Upload Document
POST /api/v1/knowledgebases/{id}/documents/upload/
curl -X POST https://app.yardee.ai/api/v1/knowledgebases/1/documents/upload/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@support_guide.pdf"
Response:
{
"id": 67,
"filename": "support_guide.pdf",
"file_size_display": "2.5 MB",
"uploaded_at": "2025-01-20T15:45:00Z",
"processing_status": "processing",
"chunk_count": 0,
"uploaded_by_email": "user@company.com"
}
List Documents
GET /api/v1/knowledgebases/{id}/documents/
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://app.yardee.ai/api/v1/knowledgebases/1/documents/
Response:
{
"documents": [
{
"id": 67,
"filename": "support_guide.pdf",
"file_size_display": "2.5 MB",
"uploaded_at": "2025-01-20T15:45:00Z",
"processing_status": "completed",
"chunk_count": 45,
"uploaded_by_email": "user@company.com",
"folder_path": "/documents/"
}
],
"count": 1
}
Delete Document
DELETE /api/v1/documents/{id}/
curl -X DELETE https://app.yardee.ai/api/v1/documents/67/ \
-H "Authorization: Bearer YOUR_API_KEY"
Response: 204 No Content
Code Examples
Integration examples in popular programming languages.
Python
import requests
class YardeeVectorAPI:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = "https://app.yardee.ai/api/v1"
self.headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
def search(self, kb_id, query, top_k=5, chat_history=None):
url = f"{self.base_url}/knowledgebases/{kb_id}/search/"
payload = {"query": query, "top_k": top_k}
if chat_history:
payload["chat_history"] = chat_history
response = requests.post(url, json=payload, headers=self.headers)
response.raise_for_status()
return response.json()
def upload_document(self, kb_id, file_path):
url = f"{self.base_url}/knowledgebases/{kb_id}/documents/upload/"
with open(file_path, 'rb') as f:
files = {'file': f}
response = requests.post(url, files=files,
headers={"Authorization": f"Bearer {self.api_key}"})
response.raise_for_status()
return response.json()
# Usage
api = YardeeVectorAPI("sk-your-api-key-here")
# Basic search
results = api.search(kb_id=1, query="How do I reset my password?")
print(f"Found {len(results['results'])} relevant chunks")
# Search with conversation history (structured data only)
chat_history = [
{"role": "user", "content": "Show me Q1 sales data"},
{"role": "assistant", "content": "Here's the Q1 sales from your CSV..."}
]
results = api.search(kb_id=1, query="Q2 comparison", chat_history=chat_history)
print(f"Found {results['total_results']} contextual results")
JavaScript/Node.js
class YardeeVectorAPI {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://app.yardee.ai/api/v1';
}
async search(kbId, query, topK = 5, chatHistory = null) {
const url = `${this.baseUrl}/knowledgebases/${kbId}/search/`;
const payload = { query, top_k: topK };
if (chatHistory) {
payload.chat_history = chatHistory;
}
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(`API Error: ${response.status}`);
}
return response.json();
}
async uploadDocument(kbId, file) {
const formData = new FormData();
formData.append("file", file);
const response = await fetch(`${this.baseUrl}/knowledgebases/${kbId}/documents/upload/`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.apiKey}`,
},
body: formData,
});
return response.json();
}
}
// Usage
const api = new YardeeVectorAPI("sk-your-api-key-here");
// Basic search
const results = await api.search(1, "What are your business hours?");
console.log(`Found ${results.total_results} results`);
// Search with conversation context (structured data only)
const chatHistory = [
{ role: "user", content: "Show me revenue data" },
{ role: "assistant", content: "Here's the revenue from your data..." }
];
const contextualResults = await api.search(1, "profit margins", 5, chatHistory);
console.log(`Found ${contextualResults.total_results} contextual results`);
Error Handling
Common error codes and how to handle them.
Ready to Build with the Yardee RAG API?
Get your free API key and start building powerful, AI-driven search applications today.
Get Your API Key