API Reference¶
Complete API documentation for Nexus.
Quick Navigation¶
API Overview¶
Nexus provides three main interfaces:
Python SDK¶
import nexus
# Connect to Nexus
nx = nexus.connect(config={"data_dir": "./nexus-data"})
# Use the API
nx.write("/file.txt", b"content")
content = nx.read("/file.txt")
CLI¶
# File operations
nexus write /file.txt "content"
nexus read /file.txt
# Memory operations
nexus memory store "user_id" '{"preferences": "dark_mode"}'
nexus memory retrieve "user_id"
RPC Server¶
# Start server
nexus.serve(host="0.0.0.0", port=2026)
# Connect remotely
nx = nexus.connect(remote_url="http://localhost:2026")
Plugins¶
from nexus.plugins import NexusPlugin, PluginMetadata
class MyPlugin(NexusPlugin):
def metadata(self) -> PluginMetadata:
return PluginMetadata(
name="my-plugin",
version="1.0.0",
description="Custom plugin"
)
def commands(self) -> dict[str, Callable]:
return {"hello": self.hello_command}
async def hello_command(self):
print("Hello from plugin!")
Skills¶
from nexus.skills import SkillRegistry, SkillManager
# Discover skills
registry = SkillRegistry(nx)
await registry.discover()
# Get a skill
skill = await registry.get_skill("analyze-code")
# Create new skill
manager = SkillManager(nx, registry)
await manager.create_skill(
name="my-skill",
description="Custom skill",
template="basic"
)
Common Patterns¶
Context Management¶
# Automatic cleanup with context manager
with nexus.connect(config={"data_dir": "./data"}) as nx:
nx.write("/file.txt", b"content")
content = nx.read("/file.txt")
# Connection automatically closed
Error Handling¶
from nexus.core.exceptions import FileNotFoundError, PermissionDeniedError
try:
content = nx.read("/nonexistent.txt")
except FileNotFoundError:
print("File not found")
except PermissionDeniedError:
print("Access denied")
Multi-Tenant Operations¶
# Create tenant workspace
nx.workspace.create("/tenant/acme-corp", tenant_id="acme-123")
# All operations within workspace are isolated
nx.write(
"/tenant/acme-corp/data.json",
data,
context={"tenant_id": "acme-123"}
)
API Principles¶
Design Philosophy
Nexus APIs follow these principles:
- Simple by default, powerful when needed
- Consistent across SDK, CLI, and RPC
- Type-safe with full IDE support
- Defensive with clear error messages
- Performance-optimized for production
Next Steps¶
For Beginners¶
Start with the Core API to learn the basics, then explore File Operations.
For AI Developers¶
Check out Memory Management, Semantic Search, and Skills API for AI-specific features.
For Enterprise¶
Review Permissions and Multi-Tenancy for production deployments.