Quick Start
This guide walks you through authenticating and making your first request to WP Engine’s Hosting Platform API.
Prerequisites
Section titled “Prerequisites”Before you begin, you’ll need:
- An understanding of what the Hosting Platform API is
- A WP Engine account with API access enabled.
- API credentials (User ID and Password) generated in the WP Engine User Portal on the API Access page.
- A tool to make HTTP requests, such as cURL, Postman, or your preferred programming language.
Authentication
Section titled “Authentication”WP Engine’s Hosting Platform API uses Basic Auth. Credentials are sent as a base64-encoded user_id:password string in the Authorization header.
Example cURL request:
curl -X GET "https://api.wpengineapi.com/v1/installs?limit=5" \ -u YOUR_USER_ID:YOUR_PASSWORDIf successful, the response will look something like this:
{ "count": 1, "results": [ { "id": 12345, "name": "my-wp-site", "account_id": 67890, "created_at": "2024-01-01T12:00:00Z" } ]}Environment Variables (Recommended)
Section titled “Environment Variables (Recommended)”Your API credentials are sensitive. For security, store your credentials in environment variables:
export WPENGINE_USER_ID="YOUR_USER_ID"export WPENGINE_PASSWORD="YOUR_PASSWORD"Now you can reference them in code without hardcoding secrets.
Example Requests
Section titled “Example Requests”Here are simple examples in different languages to fetch your installs.
<?php$user = getenv('WPENGINE_USER_ID');$pass = getenv('WPENGINE_PASSWORD');
$ch = curl_init("https://api.wpengineapi.com/v1/installs?limit=5");curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Basic " . base64_encode("$user:$pass")]);
$response = curl_exec($ch);curl_close($ch);
echo $response;const user = process.env.WPENGINE_USER_ID;const password = process.env.WPENGINE_PASSWORD;const auth = "Basic " + Buffer.from(`${user}:${password}`).toString("base64");
const response = await fetch( "https://api.wpengineapi.com/v1/installs?limit=5", { headers: { Authorization: auth }, },);const data = await response.json();console.log(data);import os, requestsurl = "https://api.wpengineapi.com/v1/installs?limit=5"
response = requests.get(url, auth=( os.environ['WPENGINE_USER_ID'], os.environ['WPENGINE_PASSWORD']))
print(response.json())Next Steps
Section titled “Next Steps”You’ve successfully made your first request! From here, you can:
- Explore the API Reference for available endpoints.
- Follow the Tutorial for a deeper walkthrough, including pagination, error handling, and automation.