Skip to main content

WP Engine API Python SDK

A Python SDK for interacting with the WP Engine API, enabling Python developers to programmatically interact with WP Engine services.

Note: This SDK is maintained by Jeremy Pollock (jeremy.pollock@wpengine.com) and is not affiliated with or supported by WP Engine.

Installation

pip install wp-engine-api

Authentication

The SDK supports two methods of authentication:

1. Direct Username/Password

from wp_engine_api import WPEngineAPI

# Initialize with credentials directly
client = WPEngineAPI(
    username="your-username",
    password="your-password"
)

2. Environment Variables

Create a .env file in your project root:

WP_ENGINE_API_USERNAME=your-username
WP_ENGINE_API_PASSWORD=your-password

Or set environment variables directly:

export WP_ENGINE_API_USERNAME=your-username
export WP_ENGINE_API_PASSWORD=your-password

Then initialize the client:

from wp_engine_api import WPEngineAPI

# Initialize using environment variables
client = WPEngineAPI()

Quick Start

from wp_engine_api import WPEngineAPI

# Initialize the client
client = WPEngineAPI(
    username="your-username",
    password="your-password"
)

# List all sites
sites = client.sites.list()
for site in sites:
    print(f"Site: {site.name} ({site.id})")

# Get a specific site
site = client.sites.get("site_id")

# Create a backup
backup = client.backups.create(
    "site_id",
    {
        "description": "Pre-deployment backup",
        "notification_emails": ["admin@example.com"]
    }
)

Features

  • Full coverage of the WP Engine API
  • Type hints for better IDE support
  • Automatic rate limiting
  • Request validation
  • Comprehensive error handling
  • Environment variable support
  • .env file support

Examples

Site Management

# List all sites
sites = client.sites.list()

# Get a specific site
site = client.sites.get("site_id")

# Update a site
updated_site = client.sites.update(
    "site_id",
    {"name": "New Site Name"}
)

Backup Management

# Create a backup
backup = client.backups.create(
    "site_id",
    {
        "description": "Pre-deployment backup",
        "notification_emails": ["admin@example.com"]
    }
)

# List backups
backups = client.backups.list("site_id")

# Get backup status
backup_status = client.backups.get("site_id", "backup_id")

Error Handling

from wp_engine_api.exceptions import (
    AuthenticationError,
    ValidationError,
    ResourceNotFoundError,
    RateLimitError
)

try:
    sites = client.sites.list()
except AuthenticationError:
    print("Invalid credentials")
except ResourceNotFoundError:
    print("Resource not found")
except RateLimitError as e:
    print(f"Rate limit exceeded. Retry after {e.retry_after} seconds")
except ValidationError as e:
    print(f"Invalid request: {e}")

Rate Limiting

The SDK includes automatic rate limiting to help you stay within the API's limits. You can configure the rate limiting behavior:

client = WPEngineAPI(
    username="your-username",
    password="your-password",
    max_retries=3,
    retry_delay=1.0
)

Development

Setup Development Environment

  1. Clone the repository:
git clone https://github.com/wpengine/wp-engine-api-python.git
cd wp-engine-api-python
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install development dependencies:
pip install -r requirements.txt

Running Tests

pytest

Generating API Client

The SDK uses OpenAPI Generator to generate the base API client code. To regenerate the client:

python scripts/generate_client.py

License

This project is licensed under the MIT License - see the LICENSE file for details.

Maintainer

This SDK is maintained by Jeremy Pollock (jeremy.pollock@wpengine.com). For any questions, issues, or contributions, please reach out directly.

Metadata

Release files for wp-engine-api-python 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wp-engine-api-python 0.0.2
File Size Uploaded Provenance
wp_engine_api_python-0.0.2.tar.gz 53.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for wp-engine-api-python 0.0.2
File Interpreter ABI Platform
wp_engine_api_python-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 180.0 kB

Release files / wp_engine_api_python-0.0.2.tar.gz

Download URL wp_engine_api_python-0.0.2.tar.gz
Size 53.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4541990a166b1cac456be5610460e52ec09a58b6bbe0bbeb80afa274fe86d7cb
BLAKE2b-256 checksum
How to use checksums
b925579e546cc697ae997fc3b2dd70a167893e7353a790aebe6ed03f35695c67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.1

Release files / wp_engine_api_python-0.0.2-py3-none-any.whl

Download URL wp_engine_api_python-0.0.2-py3-none-any.whl
Size 126.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e16938ec0d1ac8546c7d54976f1998ebc58f22022ecbdadf631a902a6822a47f
BLAKE2b-256 checksum
How to use checksums
6e5e774c23a056fec3c23820ac6002c62f5ddc2ef0a859279ede2100ce89dfa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.1

Security for wp-engine-api-python 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page