Skip to content

Client Reference

The NoteDxClient is the main entry point for interacting with the NoteDx API.

Client Class

notedx_sdk.client.NoteDxClient

NoteDxClient(
    email: Optional[str] = None,
    password: Optional[str] = None,
    api_key: Optional[str] = None,
    auto_login: bool = True,
    session: Optional[requests.Session] = None,
)

A Pythonic client for the NoteDx API that provides a robust interface for medical note generation.

This client wraps the NoteDx API endpoints, providing comprehensive functionality for medical note generation and account management. It handles authentication, environment configuration, and resource management with robust error handling.

Features
  • Account creation and management
  • Authentication handling (Firebase email/password and API key)
  • Environment configuration
  • Type-safe interfaces
  • Comprehensive error handling
  • Resource management
PARAMETER DESCRIPTION
email

Email for authentication. If not provided, reads from NOTEDX_EMAIL env var.

TYPE: str DEFAULT: None

password

Password for authentication. If not provided, reads from NOTEDX_PASSWORD env var.

TYPE: str DEFAULT: None

api_key

API key for authentication. If not provided, reads from NOTEDX_API_KEY env var.

TYPE: str DEFAULT: None

auto_login

If True, automatically logs in when credentials are provided. Defaults to True.

TYPE: bool DEFAULT: True

session

Custom requests.Session for advanced configuration.

TYPE: Session DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the base_url is invalid

AuthenticationError

If credentials are invalid or missing

NetworkError

If unable to connect to the API

InternalServerError

If server error occurs during initialization

Example
# Using email/password authentication
client = NoteDxClient(
    email="user@example.com",
    password="password123"
)
# Client automatically logs in
print(client.account.get_account())

# Using API key authentication
client = NoteDxClient(api_key="your-api-key")
# Process an audio file
response = client.notes.process_audio(
    file_path="recording.mp3",
    template="primaryCare"
)
Notes
  • The session parameter allows for custom SSL, proxy, and timeout configuration
  • Auto-login can be disabled if you want to handle authentication manually
  • Each account starts with 100 free jobs (live API key)
  • Sandbox API keys have unlimited usage for testing

Initialize the NoteDx API client.

The client can be initialized with:

  1. Email and password for account access (using Firebase Auth)
  2. API key for note generation only
  3. Both email/password and API key for full account access and note generation
  4. No credentials (will read from environment variables)
PARAMETER DESCRIPTION
email

Email for authentication. If not provided, reads from NOTEDX_EMAIL env var

TYPE: Optional[str] DEFAULT: None

password

Password for authentication. If not provided, reads from NOTEDX_PASSWORD env var

TYPE: Optional[str] DEFAULT: None

api_key

API key for authentication. If not provided, reads from NOTEDX_API_KEY env var

TYPE: Optional[str] DEFAULT: None

auto_login

If True, automatically logs in when credentials are provided

TYPE: bool DEFAULT: True

session

Optional custom requests.Session for advanced configuration

TYPE: Optional[Session] DEFAULT: None

RAISES DESCRIPTION
ValidationError

If the base_url is invalid

AuthenticationError

If credentials are invalid or missing

NetworkError

If unable to connect to the API

InternalServerError

If server error occurs during initialization

Note
  • The session parameter allows for custom SSL, proxy, and timeout configuration
  • Auto-login can be disabled if you want to handle authentication manually

Functions

configure_logging classmethod

configure_logging(
    level: int = logging.INFO,
    handler: Optional[logging.Handler] = None,
    format_string: Optional[str] = None,
) -> None

Configure logging for the NoteDx SDK.

This method allows customization of logging behavior, including log level, custom handlers, and format strings.

PARAMETER DESCRIPTION
level

The logging level (e.g., logging.DEBUG, logging.INFO). Defaults to logging.INFO.

TYPE: int DEFAULT: INFO

handler

Custom logging handler. If None, logs to console.

TYPE: Handler DEFAULT: None

format_string

Custom format string for log messages. Defaults to '%(asctime)s - %(name)s - %(levelname)s - %(message)s'.

TYPE: str DEFAULT: None

Example
Enable debug logging to console:
>>> NoteDxClient.configure_logging(logging.DEBUG)

Log to a file with custom format:
>>> file_handler = logging.FileHandler('notedx.log')
>>> NoteDxClient.configure_logging(
...     level=logging.INFO,
...     handler=file_handler,
...     format_string='%(asctime)s - %(message)s'
... )

set_log_level classmethod

set_log_level(level: int) -> None

Set the logging level for the NoteDx SDK.

A convenience method to quickly change just the log level without reconfiguring the entire logging setup.

PARAMETER DESCRIPTION
level

The logging level to set (e.g., logging.DEBUG, logging.INFO).

TYPE: int

Example
>>> NoteDxClient.set_log_level(logging.DEBUG)  # Enable debug logging
>>> NoteDxClient.set_log_level(logging.WARNING)  # Only log warnings and errors

login

login() -> Dict[str, Any]

Authenticate with the NoteDx API using Firebase email/password authentication.

POST /auth/login

This method wraps the /auth/login endpoint, handling Firebase authentication and token management. On successful login, it stores the authentication tokens for subsequent requests.

RETURNS DESCRIPTION
dict

Authentication response containing:

  • user_id (str): Firebase user ID
  • email (str): User's email address
  • id_token (str): Firebase ID token for API requests
  • refresh_token (str): Token for refreshing authentication

TYPE: Dict[str, Any]

RAISES DESCRIPTION
AuthenticationError

If credentials are invalid or missing

NetworkError

If connection fails or request times out

NoteDxError

For other API errors

refresh_token

refresh_token() -> Dict[str, Any]

Refresh the Firebase authentication token using the current refresh token.

POST /auth/refresh

This method wraps the /auth/refresh endpoint, handling token refresh and rotation. It automatically updates the stored tokens on successful refresh.

RETURNS DESCRIPTION
dict

Refresh response containing:

  • id_token (str): New Firebase ID token
  • refresh_token (str): New refresh token (if rotated)
  • user_id (str): Firebase user ID
  • email (str): User's email

TYPE: Dict[str, Any]

RAISES DESCRIPTION
AuthenticationError

If refresh token is invalid, expired, or missing

NetworkError

If connection fails

NoteDxError

For other API errors

Example
>>> # Refresh token when needed
>>> try:
...     new_tokens = client.refresh_token()
... except AuthenticationError:
...     # Handle token refresh failure
...     client.login()

set_token

set_token(
    token: str, refresh_token: Optional[str] = None
) -> None

Manually set authentication tokens for the client.

This method allows direct setting of authentication tokens, bypassing the normal login flow. Useful when you already have valid Firebase tokens from another source.

PARAMETER DESCRIPTION
token

Firebase ID token for API authentication

TYPE: str

refresh_token

Firebase refresh token for token renewal

TYPE: str DEFAULT: None

Example
>>> # Using tokens from another source
>>> client = NoteDxClient()
>>> client.set_token(
...     token="firebase_id_token",
...     refresh_token="firebase_refresh_token"
... )
>>> # Now you can make authenticated requests
>>> account_info = client.account.get_account()
Note
  • The tokens must be valid Firebase tokens
  • Without a refresh_token, you won't be able to automatically refresh authentication
  • Invalid tokens will cause AuthenticationError on API requests

set_api_key

set_api_key(api_key: str) -> None

Manually set an API key for the client.

This method allows direct setting of an API key for authentication. API keys provide limited access focused on note generation endpoints.

PARAMETER DESCRIPTION
api_key

NoteDx API key for authentication

TYPE: str

Example
>>> client = NoteDxClient()
>>> client.set_api_key("your_api_key")
>>> # Now you can use note generation endpoints
>>> response = client.notes.process_audio(
...     file_path="recording.mp3",
...     template="primaryCare"
... )
Note
  • API keys only provide access to note generation endpoints
  • For full account access, use email/password authentication
  • Invalid API keys will cause AuthenticationError on API requests

change_password

change_password(
    current_password: str, new_password: str
) -> Dict[str, Any]

Change the password for the currently logged in user.

POST /auth/change-password

This method wraps the /auth/change-password endpoint, handling password updates and token management. On successful password change, it may require re-authentication.

PARAMETER DESCRIPTION
current_password

Current password for verification

TYPE: str

new_password

New password to set

TYPE: str

RETURNS DESCRIPTION
dict

Response data containing:

  • success (bool): Whether password was changed
  • requires_reauth (bool): Whether re-authentication is required

TYPE: Dict[str, Any]

RAISES DESCRIPTION
AuthenticationError

If not logged in or current password is incorrect

BadRequestError

If new password doesn't meet requirements

NetworkError

If connection fails or request times out

NoteDxError

For other API errors

Example
>>> client = NoteDxClient(email="user@example.com", password="old-pass")
>>> result = client.change_password("old-pass", "new-pass")
>>> if result["requires_reauth"]:
...     client.login()  # Re-authenticate with new password

Authentication

The client supports two authentication methods:

API Key Authentication

client = NoteDxClient(api_key="your-api-key")

API keys provide access to the core features around transcription and note generation.

Firebase Authentication

client = NoteDxClient(
    email="user@example.com",
    password="your-password"
)

Firebase authentication provides access to account management and API key operations.

Usage Examples

Basic Setup

from notedx_sdk import NoteDxClient

# Initialize with API key
client = NoteDxClient(api_key="your-api-key")

# Or with Firebase auth - not for production
client = NoteDxClient(
    email="user@example.com",
    password="your-password"
)

# Or both
client = NoteDxClient(
    api_key="your-api-key",
    email="user@example.com",
    password="your-password"
)

Accessing Managers

The client provides access to various managers for different API functionalities:

# Note generation
client.notes.process_audio(...)

# Account management
client.account.get_account()

# API key management
client.keys.list_api_keys()

# Webhook management
client.webhooks.get_webhook_settings()

Error Handling

from notedx_sdk.exceptions import AuthenticationError, NetworkError

try:
    client = NoteDxClient(api_key="invalid-key")
    client.notes.process_audio(...)
except AuthenticationError:
    print("Invalid API key")
except NetworkError as e:
    print(f"Connection error: {e}")

REST API Equivalent

# API Key Authentication
curl -X POST "https://api.notedx.io/v1/process-audio" \
     -H "x-api-key: your-api-key" \
     -H "Content-Type: application/json" \
     -d '{
        "template": "primaryCare", 
        "visit_type": "followUp", 
        "recording_type": "dictation", 
        "lang":"en"
        }'

# Firebase Authentication
curl -X POST "https://api.notedx.io/v1/user/account/info" \
     -H "Authorization: Bearer your-firebase-token" \
     -H "Content-Type: application/json"