Coordinator API
The Datafi coordinator is the central control plane that manages catalog operations, query execution, AI agents, and tenant administration. It exposes 81 RPCs organized into four categories, accessible over gRPC (port 50051), gRPC-Web (port 8001), and HTTP (port 8000).
API Categories
Catalog Operations
Catalog operations manage metadata about your data sources, schemas, tables, and assets.
Schema Operations
| RPC | Description | Request | Response |
|---|---|---|---|
GetSchema | Retrieve the full schema for a data source | GetSchemaRequest | SchemaResponse |
ListTables | List all tables in a data source | ListTablesRequest | ListTablesResponse |
GetTable | Get metadata for a specific table | GetTableRequest | TableResponse |
ListColumns | List columns for a specific table | ListColumnsRequest | ListColumnsResponse |
RefreshSchema | Force a schema refresh from the data source | RefreshSchemaRequest | RefreshSchemaResponse |
Example -- Get Schema:
// Request
message GetSchemaRequest {
string connection_id = 1;
}
// Response
message SchemaResponse {
string connection_id = 1;
repeated TableSchema tables = 2;
}
message TableSchema {
string name = 1;
repeated ColumnSchema columns = 2;
int64 row_count = 3;
}
message ColumnSchema {
string name = 1;
string data_type = 2;
bool nullable = 3;
repeated string tags = 4;
}
# HTTP equivalent
curl https://api.datafi.io/v1/catalog/schemas/conn_abc123 \
-H "Authorization: Bearer $TOKEN"
Record Operations
| RPC | Description |
|---|---|
GetRecords | Retrieve records from a table with pagination |
GetRecordById | Retrieve a single record by primary key |
InsertRecords | Insert new records into a table |
UpdateRecords | Update existing records |
DeleteRecords | Delete records by filter criteria |
Example -- Get Records:
curl https://api.datafi.io/v1/catalog/records \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"connection_id": "conn_abc123",
"table": "customers",
"columns": ["id", "name", "email"],
"limit": 100,
"offset": 0,
"filters": [
{"column": "region", "operator": "eq", "value": "us-west"}
]
}'
Asset Operations
| RPC | Description |
|---|---|
ListAssets | List all registered assets (datasets, documents) |
GetAsset | Retrieve metadata for a specific asset |
CreateAsset | Register a new asset |
UpdateAsset | Update asset metadata or configuration |
DeleteAsset | Remove an asset |
TagAsset | Add or update tags on an asset |
Query Operations
Query operations handle SQL execution, query building, and validation.
Execute
| RPC | Description |
|---|---|
ExecuteQuery | Execute a SQL query and return results |
ExecuteQueryStream | Execute a query and stream results in batches |
CancelQuery | Cancel a running query by ID |
GetQueryStatus | Check the status of a running or completed query |
Example -- Execute Query:
message ExecuteQueryRequest {
string sql = 1;
map<string, string> parameters = 2;
int32 timeout_seconds = 3;
string connection_id = 4;
}
message ExecuteQueryResponse {
bytes arrow_record_batch = 1;
QueryMetadata metadata = 2;
}
# HTTP
curl -X POST https://api.datafi.io/v1/query/execute \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT name, region, SUM(revenue) as total_revenue FROM sales GROUP BY name, region",
"connection_id": "conn_abc123",
"timeout_seconds": 30
}'
Build
| RPC | Description |
|---|---|
BuildQuery | Generate SQL from a structured query definition |
BuildQueryFromNL | Generate SQL from a natural language question |
Example -- Build Query from Natural Language:
curl -X POST https://api.datafi.io/v1/query/build \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"natural_language": "Show me total revenue by region for the last quarter",
"connection_id": "conn_abc123"
}'
Response:
{
"sql": "SELECT region, SUM(revenue) AS total_revenue FROM sales WHERE sale_date >= '2025-01-01' AND sale_date < '2025-04-01' GROUP BY region ORDER BY total_revenue DESC",
"confidence": 0.94,
"tables_referenced": ["sales"],
"columns_referenced": ["region", "revenue", "sale_date"]
}
Validate
| RPC | Description |
|---|---|
ValidateQuery | Check SQL syntax and permissions without executing |
ExplainQuery | Return the query execution plan |
Use ValidateQuery before ExecuteQuery to catch permission errors without consuming query execution resources.
Agent Operations
Agent operations manage the lifecycle and execution of AI agents.
Lifecycle
| RPC | Description |
|---|---|
CreateAgent | Create a new AI agent with a system prompt and tool configuration |
GetAgent | Retrieve an agent's configuration |
ListAgents | List all agents in the tenant or workspace |
UpdateAgent | Modify an agent's configuration |
DeleteAgent | Remove an agent |
Example -- Create Agent:
curl -X POST https://api.datafi.io/v1/agents \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Sales Analyst",
"description": "Answers questions about sales data",
"system_prompt": "You are a sales data analyst. Use the available tools to query sales data and provide insights.",
"connections": ["conn_abc123"],
"capabilities": ["query", "document_qa"]
}'
Execution
| RPC | Description |
|---|---|
RunAgent | Send a message to an agent and receive a response |
RunAgentStream | Stream an agent's response in real time |
GetAgentHistory | Retrieve conversation history for an agent session |
CancelAgentRun | Cancel a running agent execution |
Example -- Run Agent:
curl -X POST https://api.datafi.io/v1/agents/agent_xyz/run \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": "What were our top 5 customers by revenue last quarter?",
"session_id": "session_001"
}'
Admin Operations
Admin operations manage tenants, users, roles, and platform configuration.
Tenant Management
| RPC | Description |
|---|---|
GetTenant | Retrieve tenant configuration |
UpdateTenant | Update tenant settings |
GetTenantUsage | Retrieve usage metrics for the tenant |
User Management
| RPC | Description |
|---|---|
ListUsers | List all users in the tenant |
GetUser | Retrieve a user's profile and roles |
UpdateUser | Update a user's roles or attributes |
DeactivateUser | Deactivate a user account |
ListRoles | List available roles |
AssignRole | Assign a role to a user |
RevokeRole | Remove a role from a user |
Admin operations require the admin or super_admin role. Attempting to call admin RPCs with insufficient permissions results in a 403 Forbidden response.
Pagination
List operations support cursor-based pagination.
{
"page_size": 50,
"page_token": "eyJsYXN0X2lkIjogMTAwfQ=="
}
The response includes a next_page_token if more results are available:
{
"items": [...],
"next_page_token": "eyJsYXN0X2lkIjogMTUwfQ==",
"total_count": 342
}
What to Read Next
- Edge API -- the minimal edge server surface area.
- MCP Integration -- connect AI assistants to Datafi via MCP.
- Integration Tokens -- create tokens for programmatic API access.