Skip to content
WP Engine |Hosting Platform API

Tutorial

This tutorial provides a step-by-step walkthrough of WP Engine’s Hosting Platform API. You’ll learn how to authenticate, query resources, handle pagination, and respond to errors.


  • The cURL pagination loop later uses jq for JSON parsing. Install via Homebrew: brew install jq.
  • JavaScript examples rely on top-level await (Node 18+ or any modern runtime supporting ESM).
  • Python examples require the requests library. Install with pip install requests.

The API uses Basic Auth with your User ID and Password from the API Access page of the WP Engine User Portal.

Store your credentials in environment variables (we’ll use WPE_API_USER_ID and WPE_API_PASSWORD consistently across all language examples):

# Exact method for storing env vars may vary by OS/shell/developer preference/etc
WPE_API_USER_ID="YOUR_API_USER_ID"
WPE_API_PASSWORD="YOUR_API_PASSWORD"

Then construct the Authorization header:

Authenticate
curl -u "$WPE_API_USER_ID:$WPE_API_PASSWORD" \
"https://api.wpengineapi.com/v1/installs?limit=3"

The /installs endpoint returns all WordPress installs accessible to your account.

Example request:

List Installs
curl -u "$WPE_API_USER_ID:$WPE_API_PASSWORD" \
"https://api.wpengineapi.com/v1/installs?limit=3"

Example response:

{
"count": 232,
"results": [
{
"id": 12345,
"name": "marketing-site",
"account_id": 67890,
"created_at": "2024-01-01T12:00:00Z"
},
{
"id": 12346,
"name": "blog-site",
"account_id": 67890,
"created_at": "2024-01-02T15:00:00Z"
}
],
"next": "https://api.wpengineapi.com/v1/installs?limit=3&offset=3"
}

Many list endpoints return large result sets. The API uses offset-based pagination.

  • limit: number of results per page (max 100).
  • offset: number of results to skip.

Example:

Paginated Request
curl -u "$WPE_API_USER_ID:$WPE_API_PASSWORD" \
"https://api.wpengineapi.com/v1/installs?limit=5&offset=5"

The response will include next and previous URLs for easy navigation:

{
"previous": "https://api.wpengineapi.com/v1/installs?limit=5&offset=0",
"next": "https://api.wpengineapi.com/v1/installs?limit=5&offset=10",
"count": 232,
"results": [...]
}

When no previous or next page exists, the value of next/previous will be null.

You can fetch a single install by ID:

Get Single Install
# Placeholder ID 12345 used for illustration; replace with a real install ID.
# A 404 response means the placeholder doesn't exist in your account.
curl -u "$WPE_API_USER_ID:$WPE_API_PASSWORD" \
"https://api.wpengineapi.com/v1/installs/12345"

Response:

{
"id": 12345,
"name": "marketing-site",
"account_id": 67890,
"created_at": "2024-01-01T12:00:00Z",
"domains": [{ "hostname": "marketing.example.com", "primary": true }]
}

The API uses standard HTTP status codes.

  • 2xx — success.

  • 4xx — validation or request error.

  • 5xx — server error.

Example of a 400 Bad Request:

Bad Request
curl -u "$WPE_API_USER_ID:$WPE_API_PASSWORD" \
"https://api.wpengineapi.com/v1/installs?limit=5000"

Response:

{
"type": "invalid_value",
"code": "too_large",
"message": "Limit cannot exceed 100."
}

Always check the response body for structured error details.

With the basics in place, you can script automation:

  • Sync site data into dashboards.

  • Trigger cache purges or deploys from CI/CD pipelines.

  • Run scheduled tasks against installs or domains.

Below are examples that iterate through every page of installs until no further next link is provided.

These loops may output many lines if you have numerous installs.

Pagination Loop
# Requires: WPE_API_USER_ID / WPE_API_PASSWORD env vars
# Iterate through all pages using the 'next' link. Requires jq.
NEXT="https://api.wpengineapi.com/v1/installs?limit=100"
AUTH="${WPE_API_USER_ID}:${WPE_API_PASSWORD}"
while [ -n "$NEXT" ] && [ "$NEXT" != "null" ]; do
RESP=$(curl -u "$AUTH" "$NEXT")
echo "$RESP" | jq -r '.results[]?.name'
NEXT=$(echo "$RESP" | jq -r '.next')
done

Now that you’ve seen authentication, pagination, and error handling, you can: