SDK Overview
On this page, you can learn about:
- SDK Overview - Understand the SDK's functionality and purpose
- Installation - Quick setup of the SDK package
- Basic Usage - Learn how to create clients and basic configuration
- API Methods Directory - View all available organization and cluster management methods
- Detailed Documentation Links - Jump to complete API reference documentation
About SDK for EloqCloud
The Eloq SDK provides client libraries for managing Eloq cloud cluster services. We support both Python and TypeScript implementations, allowing you to programmatically control your cluster infrastructure with type-safe APIs.
You can use the Eloq SDK to manage your Eloq Organization and Cluster. The SDK abstracts the underlying API requests, authentication, and error handling, allowing you to focus on building applications that interact with Eloq resources.
Our SDK allows you to manage:
-
Organization Access organization details, user roles, and permissions
-
Cluster Create clusters,Get real-time cluster status and performance metrics
Eloq API:
Features
- Python
- TypeScript
- Type-safe API: Uses Pydantic dataclasses for structured input/output
- Enum-based parameters: No need to guess parameter values - use enums for type safety
- Automatic error handling: Comprehensive exception handling with clear error messages
- Simple result objects: Operations return clear success/failure results
- Auto-detection: Automatically retrieves organization and project IDs from user context
- Type-Safe: Full TypeScript support with comprehensive type definitions
- IntelliSense: Excellent IDE support with autocomplete and inline documentation
- Error Handling: Comprehensive error handling with detailed error messages
- Retry Logic: Built-in retry mechanism with exponential backoff
- Modern API: Promise-based async/await API design
- Zero Dependencies: Minimal dependencies for better performance
Installation
- Python
- TypeScript
Quick Start
- Python
- TypeScript
from eloq_sdk import EloqAPI
# Initialize client from environment variable
client = EloqAPI.from_environ()
# Get organization information
org_info = client.info()
print(f"Organization: {org_info.org_info.org_name}")
# List clusters
clusters = client.clusters()
print(f"Found {clusters.total} clusters")
Environment Setup
Set the ELOQ_API_KEY environment variable:
export ELOQ_API_KEY="your-api-key-here"
import { createEloqClient } from 'eloq-sdk-typescript';
// Create client with API key
const client = createEloqClient('your_api_token');
// Get organization information
const orgInfo = await client.info();
console.log('Organization:', orgInfo.org_info.org_name);
console.log('Projects:', orgInfo.org_info.projects.length);
Getting Your API Key
- Log in to your EloqCloud Dashboard
- Navigate to Settings → API Keys
- Generate a new API key
- Copy the key for use in your application
Using Environment Variables
For better security, store your API token in environment variables:
import { createEloqClient } from 'eloq-sdk-typescript';
const client = createEloqClient(process.env.ELOQ_API_TOKEN || '');
Authentication & Client Initialization
The SDK provides multiple ways to initialize the client:
- Python
- TypeScript
1. From Environment Variable
from eloq_sdk import EloqAPI
client = EloqAPI.from_environ()
This reads the API key from the ELOQ_API_KEY environment variable.
2. From API Key
from eloq_sdk import EloqAPI
client = EloqAPI.from_key("your-api-key-here")
3. From API Key and Custom URL
from eloq_sdk import EloqAPI
client = EloqAPI.from_key_and_url(
"your-api-key-here",
"https://api-prod.eloqdata.com/api/v1/"
)
1. Simple Configuration
import { createEloqClient } from 'eloq-sdk-typescript';
// Simple configuration with just API key
const client = createEloqClient('your_api_token');
2. Full Configuration
import { createEloqClient } from 'eloq-sdk-typescript';
// Full configuration with all options
const client = createEloqClient({
apiKey: 'your_api_token',
baseURL: 'https://api-prod.eloqdata.com',
timeout: 30000,
maxRetries: 3,
retryDelay: 1000,
});
3. From Environment Variables
import { createEloqClient } from 'eloq-sdk-typescript';
const client = createEloqClient({
apiKey: process.env.ELOQ_API_TOKEN!,
baseURL: process.env.ELOQ_API_URL || 'https://api-prod.eloqdata.com',
timeout: parseInt(process.env.ELOQ_TIMEOUT || '30000'),
});
Documentation
- Python
- TypeScript
Documentation for EloqAPI, including quick start
For detailed function documentation with input/output specifications, see Python SDK Documentation.
Documentation for TypeScript SDK, including quick start
For detailed function documentation with input/output specifications, see TypeScript SDK Documentation.
Error Handling
The SDK provides comprehensive error handling with specific exception types:
- Python
- TypeScript
Exception Types
EloqAPIError: Base exception for all API errorsEloqAuthenticationError: Authentication failed (401)EloqPermissionError: Permission denied (403)EloqNotFoundError: Resource not found (404)EloqRateLimitError: Rate limit exceeded (429)EloqValidationError: Invalid request (400)EloqServerError: Server error (500+)
Handling Errors
from eloq_sdk import EloqAPI
from eloq_sdk.exceptions import EloqAPIError, EloqNotFoundError
try:
cluster = client.cluster("non-existent-cluster")
except EloqNotFoundError:
print("Cluster not found")
except EloqAPIError as e:
print(f"API error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
Operation Results
For create and delete operations, errors are automatically handled and returned as OperationResult objects:
result = client.cluster_create(
cluster_name="my-cluster",
region="us-west-1",
sku_id=123
)
if not result.success:
print(f"Operation failed: {result.message}")
Error Handling
The SDK provides comprehensive error handling with detailed error messages for different scenarios:
Error Types
- Authentication Errors (401): Invalid, expired, or missing API key
- Authorization Errors (403): Insufficient permissions
- Not Found Errors (404): Requested resource doesn't exist
- Bad Request Errors (400): Invalid request parameters
- Server Errors (500): Internal server error
- Network Errors: Connectivity issues
Handling Errors
import { createEloqClient } from 'eloq-sdk-typescript';
async function handleErrors() {
const client = createEloqClient('your_api_token');
try {
const orgInfo = await client.info();
console.log('Success:', orgInfo.org_info.org_name);
} catch (error) {
if (error instanceof Error) {
if (error.message.includes('401') || error.message.includes('Unauthorized')) {
console.error('Authentication failed. Please check your API key.');
} else if (error.message.includes('403') || error.message.includes('Forbidden')) {
console.error('Access denied. Check your API key permissions.');
} else if (error.message.includes('404') || error.message.includes('Not Found')) {
console.error('Resource not found. Verify the resource exists.');
} else if (error.message.includes('Network error')) {
console.error('Network error. Check your internet connection.');
} else {
console.error('Unexpected error:', error.message);
}
}
}
}
Core API Methods
- Python
- TypeScript
Basic:
org()- Get simplified organization informationinfo()- Get detailed organization and project informationget_skus()- Get available SKUs filtered by type, module, and cloud provider
Cluster Management:
clusters()- List all clusters in the current projectcluster()- Get detailed information about a specific clustercluster_create()- Create a new clustercluster_delete()- Delete a clustercluster_credentials()- Get cluster credentials for database connection
Basic:
info()- Get organization information including user details, organization details, and projectsget_skus()- Get available SKUs filtered by type, module, and cloud provider
Cluster Management:
clusters()- List clusters for a specific organization and project with pagination supportcluster()- Get detailed information about a specific clustercluster_create()- Create a new cluster in your organizationcluster_delete()- Delete a clustercluster_credentials()- Get cluster connection credentials including address, port, username, and password
Complete Examples
Full Workflow: Get SKUs → Create Cluster → Check Status → Delete Cluster
- Python
- TypeScript
from eloq_sdk import EloqAPI
from eloq_sdk import schema
# Initialize client
client = EloqAPI.from_environ()
# Step 1: Get available SKUs
skus = client.get_skus(
sku_type=schema.SKUType.SERVERLESS,
eloq_module=schema.EloqModule.ELOQKV,
cloud_provider=schema.CloudProvider.AWS
)
if not skus:
print("No SKUs available")
exit(1)
# Step 2: Create cluster
result = client.cluster_create(
cluster_name="my-cluster",
region="us-west-1",
sku_id=skus[0].sku_id
)
if not result.success:
print(f"Failed to create cluster: {result.message}")
exit(1)
print(f"✅ {result.message}")
# Step 3: Check cluster status
cluster_info = client.cluster("my-cluster")
print(f"Cluster status: {cluster_info.status}")
# Step 4: Get credentials
credentials = client.cluster_credentials("my-cluster")
print(f"Connection: {credentials.host}:{credentials.port}")
# Step 5: Delete cluster (when done)
result = client.cluster_delete("my-cluster")
if result.success:
print(f"✅ {result.message}")
import { createEloqClient } from 'eloq-sdk-typescript';
async function completeWorkflow() {
const client = createEloqClient(process.env.ELOQ_API_TOKEN!);
try {
// Step 1: Get organization info
const orgInfo = await client.info();
console.log(`Organization: ${orgInfo.org_info.org_name}`);
// Step 2: Get available SKUs
const skus = await client.get_skus({
type: 'serverless',
eloqModule: 'eloqkv',
cloudProvider: 'aws'
});
console.log(`Found ${skus.length} available SKUs`);
if (skus.length === 0) {
throw new Error('No available SKUs found');
}
// Step 3: Create cluster
const newCluster = await client.cluster_create({
clusterName: 'my-cluster',
region: 'us-east-1',
RequiredZone: 'us-east-1a',
skuId: skus[0].sku_id
});
console.log(`Created cluster: ${newCluster.display_cluster_name}`);
// Step 4: Check cluster status
const cluster = await client.cluster('my-cluster');
console.log(`Cluster status: ${cluster.status}`);
// Step 5: Get credentials
if (cluster.status === 'active') {
const credentials = await client.cluster_credentials('my-cluster');
console.log(`Connection: ${credentials.address}:${credentials.port}`);
}
// Step 6: List clusters
const clusters = await client.clusters(1, 20);
console.log(`Total clusters: ${clusters.total}`);
// Step 7: Delete cluster (when done)
if (cluster.status === 'available') {
await client.cluster_delete('my-cluster');
console.log('Cluster deleted successfully');
}
} catch (error) {
console.error('Error:', error);
}
}
completeWorkflow();
View the Eloq API for more information on the available endpoints and their parameters.