Client
WPClient
WordPress REST API Client Core client implementation for making requests to the WordPress REST API
- class wp_api.client.WPClient(base_url, auth=None, timeout=30, user_agent='Python WordPress REST API Client', verify_ssl=True, retry_count=0, retry_backoff_factor=0.1)[source]
Bases:
objectWordPress REST API Client
The main client class for interacting with the WordPress REST API.
- Parameters:
- __init__(base_url, auth=None, timeout=30, user_agent='Python WordPress REST API Client', verify_ssl=True, retry_count=0, retry_backoff_factor=0.1)[source]
Initialize the WordPress REST API client
- Parameters:
base_url (str) – The base URL of the WordPress site (e.g., https://example.com)
auth – Authentication method (BasicAuth, OAuth1, or ApplicationPasswordAuth)
timeout (int) – Request timeout in seconds
user_agent (str) – User agent string for the requests
verify_ssl (bool) – Whether to verify SSL certificates
retry_count (int) – Number of retries for failed requests
retry_backoff_factor (float) – Backoff factor for retries
- discover_endpoints()[source]
Discover available endpoints from the WordPress REST API
- Return type:
- Returns:
Dictionary of available routes/endpoints
- get_custom_taxonomy(taxonomy)[source]
Get a custom taxonomy endpoint handler
- Parameters:
taxonomy (
str) – Taxonomy slug (e.g., ‘category’, ‘post_tag’, or custom taxonomy)- Returns:
Terms endpoint handler for the specified taxonomy
- get_custom_fields(post_type='posts')[source]
Get a custom fields endpoint handler for a specific post type
- Parameters:
post_type (
str) – Post type (posts, pages, or custom post type)- Returns:
CustomFields endpoint handler for the specified post type
- get_custom_post_type(post_type)[source]
Get a custom post type endpoint handler
- Parameters:
post_type (
str) – Custom post type slug (e.g., ‘product’, ‘portfolio’, etc.)- Returns:
CustomPostType endpoint handler for the specified post type
- property posts
Access Posts API endpoints
- property pages
Access Pages API endpoints
- property users
Access Users API endpoints
- property media
Access Media API endpoints
- property categories
Access Categories API endpoints
- property tags
Access Tags API endpoints
- property comments
Access Comments API endpoints
- property taxonomies
Access Taxonomies API endpoints
- property settings
Access Settings API endpoints
- property block_patterns
Access Block Patterns API endpoints (WordPress 5.8+)