Skip to main content

Overview

The Config class manages authentication credentials for connecting to the AveniECA API server. It supports both token-based and username/password authentication.

Class Reference

Config

Dataclass for API authentication configuration. Import:
from avenieca.api.model import Config

Fields

api_token
str
default:""
API token for token-based authentication. When provided, this takes precedence over username/password authentication.
username
str
default:""
Username for credential-based authentication. Used in conjunction with password when api_token is not provided.
password
str
default:""
Password for credential-based authentication. Used in conjunction with username when api_token is not provided.
uri
str
default:""
The base URI of the AveniECA API server (e.g., https://api.avenieca.com)

Usage Examples

Token-Based Authentication

from avenieca.api.model import Config
from avenieca import Client

# Configure with API token (recommended)
config = Config(
    api_token="your-api-token-here",
    uri="https://api.avenieca.com"
)

client = Client(config=config)

Username/Password Authentication

from avenieca.api.model import Config
from avenieca import Client

# Configure with username and password
config = Config(
    username="your-username",
    password="your-password",
    uri="https://api.avenieca.com"
)

client = Client(config=config)

Environment-Based Configuration

import os
from avenieca.api.model import Config
from avenieca import Client

# Load credentials from environment variables
config = Config(
    api_token=os.getenv("AVENI_API_TOKEN"),
    uri=os.getenv("AVENI_API_URI", "https://api.avenieca.com")
)

client = Client(config=config)

Local Development Setup

from avenieca.api.model import Config
from avenieca import Client

# Configure for local development server
config = Config(
    username="dev_user",
    password="dev_password",
    uri="http://localhost:8000"
)

client = Client(config=config)

Authentication Priority

The SDK uses the following authentication priority:
  1. API Token - If api_token is provided, it will be used for authentication
  2. Username/Password - If api_token is empty, the SDK falls back to username/password authentication

Security Best Practices

Never hardcode credentials in your source code. Always use environment variables or secure configuration management systems.
# Good - Using environment variables
import os
config = Config(
    api_token=os.getenv("AVENI_API_TOKEN"),
    uri=os.getenv("AVENI_API_URI")
)

# Bad - Hardcoded credentials (DON'T DO THIS)
config = Config(
    api_token="sk_live_abc123...",  # Never hardcode!
    uri="https://api.avenieca.com"
)

Build docs developers (and LLMs) love