Skip to main content

Authentication

The SDK supports multiple authentication methods. Service keys are recommended for production use as they provide better security and don't expire, while access tokens are useful for development but have limited lifespans.

Set your credentials using environment variables:

Using Service Key (recommended)
export NEXLA_SERVICE_KEY="your_service_key_here"
Using Access Token
export NEXLA_ACCESS_TOKEN="your_access_token_here"
Optional: Set custom API endpoint
export NEXLA_API_URL="https://your-instance.nexla.io/nexla-api"

Direct Configuration

Using Service Key
from nexla_sdk import NexlaClient

client = NexlaClient(service_key="your_service_key_here")
Using Access Token
client = NexlaClient(access_token="your_access_token_here")
With custom API URL
client = NexlaClient(
service_key="your_service_key_here",
api_url="https://your-instance.nexla.io/nexla-api"
)

Configuration File

Create a .env file in your project root:

.env file
NEXLA_SERVICE_KEY=your_service_key_here
NEXLA_API_URL=https://your-instance.nexla.io/nexla-api

Then load it in your Python code:

Load from .env file
from dotenv import load_dotenv
from nexla_sdk import NexlaClient

load_dotenv() # Load environment variables from .env
client = NexlaClient() # Automatically picks up credentials

Service Key vs Access Token

The Nexla SDK supports two authentication methods, each with different characteristics and use cases:

Service Key vs Access Token

Service keys are recommended for production use as they provide better security and don't expire. Access tokens are useful for development but have limited lifespans.

Next Steps

Need Help?

If you encounter authentication issues, check our FAQ or review the Troubleshooting section.