-
Notifications
You must be signed in to change notification settings - Fork 3
33 api documentation
The Lobster AI API provides a comprehensive bioinformatics analysis system with multi-agent capabilities, real-time streaming, and session-based isolation. This documentation is designed for frontend developers and AI systems to understand backend communication patterns.
Base URL: http://localhost:8000 (development) or your production URL
API Version: v1
All API endpoints are prefixed with: /api/v1
The API uses session-based authentication with UUID identification. No user authentication is required for development.
- Create Session → Get session_id
- Use session_id in all subsequent requests
- Optional: Connect to WebSocket for real-time updates
- Cleanup: Delete session when done
POST /api/v1/sessions
Content-Type: application/json
{
"name": "My Analysis Session",
"description": "Single-cell RNA analysis",
"user_id": "user123",
"timeout_minutes": 60
}Response:
{
"success": true,
"message": "Session created successfully",
"timestamp": "2025-08-18T18:00:00Z",
"session": {
"session_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "My Analysis Session",
"status": "active",
"created_at": "2025-08-18T18:00:00Z",
"workspace_path": "workspaces/123e4567-e89b-12d3-a456-426614174000",
"datasets": [],
"message_count": 0
}
}GET /api/v1/sessions/{session_id}GET /api/v1/sessionsDELETE /api/v1/sessions/{session_id}POST /api/v1/sessions/{session_id}/chat
Content-Type: application/json
{
"message": "Please analyze the GSE123456 dataset",
"stream": true,
"include_history": true,
"max_history": 10
}Response:
{
"success": true,
"message": "Message processed successfully",
"timestamp": "2025-08-18T18:01:00Z",
"chat_message": {
"id": "msg-uuid",
"role": "assistant",
"content": "I'll analyze the GSE123456 dataset for you...",
"timestamp": "2025-08-18T18:01:00Z",
"metadata": {
"duration": 5.2,
"has_data": true,
"session_id": "session-uuid"
},
"plots": ["plot1.png", "plot2.svg"]
},
"conversation_id": "session-uuid",
"data_updated": true
}GET /api/v1/sessions/{session_id}/chat/history?limit=50DELETE /api/v1/sessions/{session_id}/chat/historyPOST /api/v1/sessions/{session_id}/files/upload
Content-Type: multipart/form-data
form-data:
- file: [binary file data]
- description: "Single-cell expression matrix"Response:
{
"success": true,
"message": "File uploaded and loaded successfully",
"file_path": "workspaces/session-uuid/data/expression_matrix.csv",
"file_size": 1048576,
"dataset": {
"name": "expression_matrix.csv",
"file_type": "csv",
"status": "ready",
"rows": 1000,
"columns": 50
}
}GET /api/v1/sessions/{session_id}/files?directory=dataGET /api/v1/sessions/{session_id}/files/{file_path}/downloadDELETE /api/v1/sessions/{session_id}/files/{file_path}POST /api/v1/sessions/{session_id}/data/geo-download
Content-Type: application/json
{
"geo_id": "GSE123456",
"destination_path": "data/geo_data"
}GET /api/v1/sessions/{session_id}/data/datasetsGET /api/v1/sessions/{session_id}/data/summaryPOST /api/v1/sessions/{session_id}/data/operations
Content-Type: application/json
{
"dataset_name": "current_dataset",
"operation": "clustering",
"parameters": {
"method": "leiden",
"resolution": 0.5
}
}POST /api/v1/sessions/{session_id}/data/load
Content-Type: application/json
{
"file_path": "data/expression_matrix.csv"
}GET /api/v1/sessions/{session_id}/data/workspaceGET /api/v1/sessions/{session_id}/plots?limit=20Response:
{
"success": true,
"message": "Retrieved 3 plots",
"plots": [
{
"id": "umap_plot.png",
"title": "umap_plot",
"timestamp": "2025-08-18T18:05:00Z",
"source": "agent_generated",
"format": "png",
"path": "plots/umap_plot.png",
"size_bytes": 256000
}
],
"total": 3
}GET /api/v1/sessions/{session_id}/plots/{plot_id}/downloadPOST /api/v1/sessions/{session_id}/plots/generate
Content-Type: application/json
{
"plot_type": "umap",
"description": "UMAP visualization with cell type annotations",
"parameters": {
"color_by": "cell_type",
"size": "800x600"
}
}GET /api/v1/sessions/{session_id}/plots/latest?count=5DELETE /api/v1/sessions/{session_id}/plots/{plot_id}POST /api/v1/sessions/{session_id}/export
Content-Type: application/json
{
"include_data": true,
"include_plots": true,
"include_logs": false,
"format": "zip"
}Response:
{
"success": true,
"message": "Export package created successfully",
"export_id": "export-uuid",
"download_url": "/api/v1/exports/export-uuid/download",
"expires_at": "2025-08-19T18:00:00Z",
"size_bytes": 5242880
}GET /api/v1/exports/{export_id}/downloadGET /api/v1/exports/{export_id}/infoGET /api/v1/healthResponse:
{
"success": true,
"message": "System is healthy",
"system": {
"status": "healthy",
"active_sessions": 5,
"total_sessions": 12,
"uptime_seconds": 3600,
"memory_usage": {
"total_gb": 16.0,
"used_gb": 4.2,
"percent_used": 26.3
}
},
"version": "1.0.0",
"environment": "development"
}const ws = new WebSocket(`ws://localhost:8000/api/v1/ws/${session_id}`);{
"event_type": "connection",
"session_id": "session-uuid",
"data": {
"status": "connected",
"message": "WebSocket connected successfully"
}
}{
"event_type": "chat_stream",
"session_id": "session-uuid",
"data": {
"token": "Hello",
"agent": "transcriptomics_expert",
"type": "token"
}
}{
"event_type": "analysis_progress",
"session_id": "session-uuid",
"data": {
"status": "tool_start",
"agent": "data_expert",
"tool": "clustering_service",
"message": "Using tool: clustering_service"
}
}{
"event_type": "data_updated",
"session_id": "session-uuid",
"data": {
"status": "data_loaded",
"dataset": {
"has_data": true,
"summary": "1000 cells, 2000 genes"
}
}
}{
"event_type": "plot_generated",
"session_id": "session-uuid",
"data": {
"status": "plot_created",
"plot": {
"path": "plots/umap_visualization.png",
"name": "umap_visualization.png"
}
}
}{
"event_type": "error",
"session_id": "session-uuid",
"data": {
"status": "error",
"agent": "data_expert",
"error": "File format not supported",
"message": "Error in data_expert: File format not supported"
}
}{
"type": "ping",
"timestamp": "2025-08-18T18:00:00Z"
}{
"type": "subscribe",
"event_types": ["chat_stream", "analysis_progress", "plot_generated"]
}// Create new session
const sessionResponse = await fetch('/api/v1/sessions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Analysis Session',
timeout_minutes: 60
})
});
const session = await sessionResponse.json();
const sessionId = session.session.session_id;
// Connect WebSocket for real-time updates
const ws = new WebSocket(`ws://localhost:8000/api/v1/ws/${sessionId}`);const formData = new FormData();
formData.append('file', file);
formData.append('description', 'RNA expression data');
const uploadResponse = await fetch(`/api/v1/sessions/${sessionId}/files/upload`, {
method: 'POST',
body: formData
});const chatResponse = await fetch(`/api/v1/sessions/${sessionId}/chat`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: 'Perform quality control analysis',
stream: true
})
});ws.onmessage = (event) => {
const message = JSON.parse(event.data);
switch (message.event_type) {
case 'chat_stream':
// Update chat interface with streaming response
appendToChatStream(message.data.token);
break;
case 'analysis_progress':
// Update progress bar or status indicator
updateProgress(message.data.message, message.data.agent);
break;
case 'plot_generated':
// Refresh plot list or display new plot
refreshPlots();
break;
case 'data_updated':
// Update dataset information
refreshDataStatus();
break;
case 'error':
// Display error notification
showError(message.data.message);
break;
}
};All API responses follow this structure:
Success Response:
{
"success": true,
"message": "Operation completed successfully",
"timestamp": "2025-08-18T18:00:00Z",
// ... additional response data
}Error Response:
{
"success": false,
"message": "Error description",
"timestamp": "2025-08-18T18:00:00Z",
"error_code": "VALIDATION_ERROR",
"details": {}
}HTTP Status Codes:
-
200- Success -
201- Created (for POST operations) -
400- Bad Request (invalid input) -
404- Not Found (session/resource not found) -
413- Payload Too Large (file size exceeded) -
422- Unprocessable Content (validation error) -
500- Internal Server Error
interface SessionInfo {
session_id: string;
name?: string;
description?: string;
user_id?: string;
status: 'active' | 'inactive' | 'error' | 'expired';
created_at: string;
last_activity: string;
timeout_minutes: number;
workspace_path: string;
datasets: string[];
message_count: number;
}interface ChatMessage {
id: string;
role: 'user' | 'assistant' | 'system';
content: string;
timestamp: string;
metadata?: Record<string, any>;
plots?: string[];
}interface FileInfo {
name: string;
path: string;
size_bytes: number;
created_at: string;
modified_at: string;
file_type: string;
}interface PlotInfo {
id: string;
title: string;
timestamp: string;
source: string;
format: 'png' | 'jpg' | 'svg' | 'html' | 'pdf';
path: string;
size_bytes?: number;
}interface WebSocketMessage {
event_type: 'chat_stream' | 'agent_thinking' | 'analysis_progress' |
'data_updated' | 'plot_generated' | 'error';
session_id: string;
data: Record<string, any>;
timestamp: string;
}Upload Formats:
-
.csv- Comma-separated values -
.tsv- Tab-separated values -
.h5- HDF5 format -
.h5ad- AnnData HDF5 format -
.mtx- Matrix Market format
Plot Formats:
-
.png- PNG images -
.jpg/.jpeg- JPEG images -
.svg- Scalable Vector Graphics -
.html- Interactive HTML plots -
.pdf- PDF documents
// 1. Create session
const session = await createSession("RNA Analysis");
const sessionId = session.session.session_id;
// 2. Connect WebSocket
const ws = connectWebSocket(sessionId);
// 3. Upload data
await uploadFile(sessionId, dataFile);
// 4. Start analysis
await sendChatMessage(sessionId, "Perform clustering analysis");
// 5. Monitor progress via WebSocket
// 6. Download results when complete// 1. Create session
const sessionId = await createSession("GEO Analysis");
// 2. Download GEO dataset
await downloadGEODataset(sessionId, "GSE123456");
// 3. Start analysis
await sendChatMessage(sessionId, "Analyze this dataset and create UMAP visualization");
// 4. Get generated plots
const plots = await getPlots(sessionId);ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
// Update UI based on event type
if (msg.event_type === 'analysis_progress') {
setProgress(msg.data.message, msg.data.agent);
} else if (msg.event_type === 'plot_generated') {
refreshPlotsList();
}
};- File Upload: 500MB maximum per file
- Session Timeout: 5-1440 minutes (configurable)
- Export Expiry: 24 hours
- WebSocket: No explicit rate limits
- Concurrent Sessions: No hard limit (resource dependent)
For frontend configuration:
# API Base URL
REACT_APP_API_URL=http://localhost:8000
# WebSocket URL
REACT_APP_WS_URL=ws://localhost:8000
# Upload limits
REACT_APP_MAX_FILE_SIZE=524288000 # 500MB in bytes// Check if session still exists
const sessionCheck = await fetch(`/api/v1/sessions/${sessionId}`);
if (!sessionCheck.ok) {
// Session expired, create new one
const newSession = await createSession();
sessionId = newSession.session.session_id;
}ws.onclose = () => {
// Attempt reconnection after delay
setTimeout(() => {
connectWebSocket(sessionId);
}, 1000);
};try {
const result = await uploadFile(sessionId, file);
if (!result.success) {
showError(`Upload failed: ${result.message}`);
}
} catch (error) {
if (error.status === 413) {
showError('File too large. Maximum size is 500MB');
} else if (error.status === 422) {
showError('Invalid file format');
}
}The multi-agent system includes:
- Supervisor Agent - Coordinates other agents and routing
- Data Expert - Data loading, preprocessing, quality control
- Transcriptomics Expert - RNA-seq analysis, single-cell analysis
- Research Agent - Literature mining, dataset discovery, method extraction (Phase 1)
Agent Communication Examples:
- "Load the GSE123456 dataset and perform quality control"
- "Create a UMAP visualization colored by cell types"
- "Perform differential expression analysis between conditions"
- "Generate a clustering analysis with Leiden algorithm"
- "Show me the data summary and basic statistics"
Access full interactive documentation at:
-
Swagger UI:
http://localhost:8000/docs -
ReDoc:
http://localhost:8000/redoc -
OpenAPI JSON:
http://localhost:8000/openapi.json
These provide complete endpoint documentation with example requests/responses and the ability to test endpoints directly in the browser.