API Reference
Complete reference for MTPDB's REST API and SDK methods.
Endpoints
SDK Methods
Authentication
POST
/api/v1/auth/login
Authenticate and receive an access token
Request Body
{
"email": "[email protected]",
"password": "password"
}
Response
{
"token": "eyJhbGciOiJIUzI1NiIs...",
"expires_at": "2026-02-10T10:00:00Z"
}
Database Management
GET
/api/v1/databases
List all databases
[
{
"id": "db_123",
"name": "production",
"size": "250GB",
"connections": 1250
}
]
POST
/api/v1/databases
Create a new database
{
"name": "new_database",
"tenant_id": "tenant_456"
}
Tenant Management
GET
/api/v1/tenants
List all tenants
[
{
"id": "tenant_123",
"name": "Acme Corp",
"database_count": 3,
"quota_used": "75GB",
"quota_limit": "100GB"
}
]
POST
/api/v1/tenants
Create a new tenant
{
"name": "New Company",
"quota_limit": "50GB",
"schema_isolation": true
}
Metrics & Monitoring
GET
/api/v1/metrics
Get system metrics
{
"connections": {
"active": 15420,
"idle": 485580,
"total": 500000
},
"performance": {
"p95_latency_ms": 8.5,
"qps": 45230,
"cache_hit_rate": 0.94
},
"storage": {
"used_gb": 245.8,
"total_gb": 1000,
"compression_ratio": 3.2
}
}
SDK Connection Methods
Connect to MTPDB
const client = new MTPDBClient({
host: 'your-instance.mtpdb.com',
port: 3306,
credentials: {
username: 'your-user',
password: 'your-password'
}
});
await client.connect();
Connection Pooling
const pool = new MTPDBPool({
host: 'your-instance.mtpdb.com',
maxConnections: 100,
minConnections: 10
});
// Get a connection from the pool
const conn = await pool.getConnection();
try {
const result = await conn.query('SELECT * FROM users');
} finally {
conn.release();
}
Query Methods
Basic Queries
// Simple query
const users = await client.query('SELECT * FROM users WHERE active = ?', [true]);
// Prepared statement
const stmt = await client.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
await stmt.execute(['John Doe', '[email protected]']);
Advanced Features
// Real-time subscriptions
const subscription = client.subscribe('users:updates', (change) => {
console.log('User changed:', change);
});
// Batch operations
const batch = client.batch();
batch.insert('users', { name: 'Alice', email: '[email protected]' });
batch.insert('users', { name: 'Bob', email: '[email protected]' });
await batch.execute();