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:
|
password |
Password for authentication. If not provided, reads from NOTEDX_PASSWORD env var.
TYPE:
|
api_key |
API key for authentication. If not provided, reads from NOTEDX_API_KEY env var.
TYPE:
|
auto_login |
If True, automatically logs in when credentials are provided. Defaults to True.
TYPE:
|
session |
Custom requests.Session for advanced configuration.
TYPE:
|
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:
- Email and password for account access (using Firebase Auth)
- API key for note generation only
- Both email/password and API key for full account access and note generation
- No credentials (will read from environment variables)
PARAMETER | DESCRIPTION |
---|---|
email |
Email for authentication. If not provided, reads from NOTEDX_EMAIL env var
TYPE:
|
password |
Password for authentication. If not provided, reads from NOTEDX_PASSWORD env var
TYPE:
|
api_key |
API key for authentication. If not provided, reads from NOTEDX_API_KEY env var
TYPE:
|
auto_login |
If True, automatically logs in when credentials are provided
TYPE:
|
session |
Optional custom requests.Session for advanced configuration
TYPE:
|
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:
|
handler |
Custom logging handler. If None, logs to console.
TYPE:
|
format_string |
Custom format string for log messages. Defaults to '%(asctime)s - %(name)s - %(levelname)s - %(message)s'.
TYPE:
|
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 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:
|
login ¶
Authenticate with the NoteDx API using Firebase email/password authentication.
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:
TYPE:
|
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 the Firebase authentication token using the current refresh token.
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:
TYPE:
|
RAISES | DESCRIPTION |
---|---|
AuthenticationError
|
If refresh token is invalid, expired, or missing |
NetworkError
|
If connection fails |
NoteDxError
|
For other API errors |
set_token ¶
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:
|
refresh_token |
Firebase refresh token for token renewal
TYPE:
|
Example
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 ¶
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:
|
Example
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 the password for the currently logged in user.
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:
|
new_password |
New password to set
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict
|
Response data containing:
TYPE:
|
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 |
Authentication¶
The client supports two authentication methods:
API Key Authentication¶
API keys provide access to the core features around transcription and note generation.
Firebase Authentication¶
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"