Skip to main content

API Reference

The Nexla SDK provides a comprehensive, typed interface to all Nexla platform resources. This section covers the main client configuration and resource methods.

Complete Documentation

For the complete API reference with all methods, parameters, and return types, see the API Reference page in our Nexla SDK guides.

Client Configuration

NexlaClient

The main client class for interacting with the Nexla platform.

Client Initialization
from nexla_sdk import NexlaClient

# Using environment variables (recommended)
client = NexlaClient()

# Using service key directly
client = NexlaClient(service_key="your_service_key")

# Using access token
client = NexlaClient(access_token="your_access_token")

# With custom API URL
client = NexlaClient(
service_key="your_service_key",
api_url="https://your-instance.nexla.io/nexla-api"
)

Client Configuration Options

  • service_key (str, optional): Service key for authentication
  • access_token (str, optional): Access token for authentication
  • api_url (str, optional): Custom API endpoint URL
  • timeout (int, optional): Request timeout in seconds
  • retries (int, optional): Number of retry attempts

Resource Methods

Flows

Manage data flows and pipelines:

Flow Operations
# List all flows
flows = client.flows.list()

# Get specific flow
flow = client.flows.get(flow_id="flow-123")

# Create new flow
new_flow = client.flows.create({
"name": "My Flow",
"description": "A new data flow"
})

# Update flow
updated_flow = client.flows.update(flow_id="flow-123", data={
"name": "Updated Flow Name"
})

# Delete flow
client.flows.delete(flow_id="flow-123")

Sources

Manage data sources:

Source Operations
# List all sources
sources = client.sources.list()

# Get specific source
source = client.sources.get(source_id="source-123")

# Create new source
new_source = client.sources.create({
"name": "My Source",
"source_type": "s3",
"data_credentials_id": "cred-123"
})

# Activate source
client.sources.activate(source_id="source-123")

# Deactivate source
client.sources.deactivate(source_id="source-123")

Destinations

Manage data destinations:

Destination Operations
# List all destinations
destinations = client.destinations.list()

# Get specific destination
destination = client.destinations.get(destination_id="dest-123")

# Create new destination
new_destination = client.destinations.create({
"name": "My Destination",
"sink_type": "s3",
"data_set_id": "nexset-123"
})

# Activate destination
client.destinations.activate(destination_id="dest-123")

Nexsets

Manage datasets:

Nexset Operations
# List all nexsets
nexsets = client.nexsets.list()

# Get specific nexset
nexset = client.nexsets.get(nexset_id="nexset-123")

# Create new nexset
new_nexset = client.nexsets.create({
"name": "My Nexset",
"parent_data_set_id": "parent-123"
})

# Update nexset
updated_nexset = client.nexsets.update(nexset_id="nexset-123", data={
"name": "Updated Nexset"
})

Credentials

Manage authentication credentials:

Credential Operations
# List all credentials
credentials = client.credentials.list()

# Get specific credential
credential = client.credentials.get(credential_id="cred-123")

# Create new credential
new_credential = client.credentials.create({
"name": "My Credential",
"credentials_type": "s3",
"credentials": {
"access_key_id": "AKIA...",
"secret_access_key": "***"
}
})

# Probe credential
probe_result = client.credentials.probe(credential_id="cred-123")

Projects

Manage projects:

Project Operations
# List all projects
projects = client.projects.list()

# Get specific project
project = client.projects.get(project_id="project-123")

# Create new project
new_project = client.projects.create({
"name": "My Project",
"description": "A new project"
})

Metrics

Access performance metrics:

Metrics Operations
# Get resource daily metrics
metrics = client.metrics.get_resource_daily_metrics(
resource_type="data_sources",
resource_id="source-123",
from_date="2024-01-01",
to_date="2024-01-31"
)

# Get rate limits
rate_limits = client.metrics.get_rate_limits()

Error Handling

The SDK provides comprehensive error handling with rich exception classes:

Error Handling
from nexla_sdk.exceptions import (
NexlaAPIError,
AuthenticationError,
AuthorizationError,
NotFoundError,
ValidationError,
RateLimitError,
ServerError
)

try:
flow = client.flows.get("non-existent-flow-id")
except AuthenticationError:
print("Authentication failed")
except NotFoundError:
print("Resource not found")
except RateLimitError as e:
print(f"Rate limited. Retry after: {e.retry_after}")
except NexlaAPIError as e:
print(f"API Error: {e.message}")

Pagination

All list methods support pagination:

Pagination
# List with pagination
flows = client.flows.list(
per_page=50,
page=2
)

# Iterate through all pages
for flow in client.flows.list_all():
print(f"Flow: {flow.name}")

Next Steps