Phaxio Python Client
The `phaxio` library provides a Python client for interacting with the Phaxio v2 API. As of version 0.3, it offers methods for sending faxes, managing webhooks, and more. Development appears to be in maintenance mode, with the last major commit in 2018.
Common errors
-
phaxio.exceptions.PhaxioException: (401) Unauthorized
cause Incorrect Phaxio API Key or Secret, or using v1 credentials with this v2 client.fixDouble-check your `PHAXIO_API_KEY` and `PHAXIO_API_SECRET` environment variables or hardcoded values. Ensure they are valid Phaxio v2 API credentials. -
AttributeError: module 'phaxio' has no attribute 'faxes'
cause The `phaxio` module attributes for API keys/secrets were not set, or the module was not properly imported before attempting to use its sub-modules.fixEnsure `import phaxio` is present and that `phaxio.api_key` and `phaxio.api_secret` are assigned values before calling methods like `phaxio.faxes.list()`. -
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))cause Network connectivity issue, firewall blocking access, or temporary unavailability of the Phaxio API server.fixCheck your internet connection and local firewall settings. Verify Phaxio's service status page for any outages. Try the request again after a short delay.
Warnings
- gotcha This library is designed for Phaxio API v2. Using Phaxio API v1 keys or endpoints will result in authentication failures or unexpected behavior.
- gotcha The library sets API keys and secrets as global module-level attributes (`phaxio.api_key`, `phaxio.api_secret`). This can cause issues in multi-threaded applications or when managing multiple Phaxio accounts within a single process.
- gotcha The library has not been actively developed since 2018 (version 0.3). While it targets Phaxio API v2 and may still function, it might not support the latest API features or bug fixes from Phaxio's service updates.
Install
-
pip install phaxio
Imports
- phaxio
from phaxio import PhaxioClient
import phaxio
Quickstart
import os
import phaxio
# Authenticate using environment variables
phaxio.api_key = os.environ.get("PHAXIO_API_KEY", "YOUR_API_KEY")
phaxio.api_secret = os.environ.get("PHAXIO_API_SECRET", "YOUR_API_SECRET")
# Example: List existing faxes (requires authentication and API access)
try:
# Fetch one fax to verify connection and credentials
faxes = phaxio.faxes.list(per_page=1)
print(f"Successfully connected to Phaxio API. Found {len(faxes)} fax entries.")
# Uncomment to see the first fax details if available
# if faxes: print(f"First fax: {faxes[0]}")
except phaxio.exceptions.PhaxioException as e:
print(f"Error connecting to Phaxio API or listing faxes: {e}")
print("Please ensure PHAXIO_API_KEY and PHAXIO_API_SECRET environment variables are set correctly and have necessary permissions.")
except Exception as e:
print(f"An unexpected error occurred: {e}")