WordPress XML-RPC API Overview

WordPress provides XML-RPC functionality for remote publishing and content management. This API allows external applications to interact with WordPress for creating, editing, and managing content.

Architecture

Core Components

Source File: wp-includes/class-wp-xmlrpc-server.php

The XML-RPC system consists of:

  1. wp_xmlrpc_server – Main server class extending IXR_Server
  2. Endpoint: xmlrpc.php in the WordPress root directory
  3. IXR Library: Internal XML-RPC handling library

Class Hierarchy

IXR_Server
    └── wp_xmlrpc_server

Properties

PropertyTypeDescription
$methodsarrayRegistered XML-RPC methods
$blog_optionsarrayAvailable blog options for retrieval/modification
$errorIXR_ErrorCurrent error instance
$auth_failedboolAuthentication failure flag
$is_enabledboolWhether XML-RPC is enabled

API Categories

WordPress API (wp.*)

Modern WordPress-specific methods for comprehensive content management:

MethodDescriptionSince
wp.getUsersBlogsGet user’s blogs2.6.0
wp.newPostCreate new post (any type)3.4.0
wp.editPostEdit existing post3.4.0
wp.deletePostDelete a post3.4.0
wp.getPostRetrieve single post3.4.0
wp.getPostsRetrieve multiple posts3.4.0
wp.newTermCreate taxonomy term3.4.0
wp.editTermEdit taxonomy term3.4.0
wp.deleteTermDelete taxonomy term3.4.0
wp.getTermGet single term3.4.0
wp.getTermsGet multiple terms3.4.0
wp.getTaxonomyGet taxonomy info3.4.0
wp.getTaxonomiesGet all taxonomies3.4.0
wp.getUserGet user data3.5.0
wp.getUsersGet multiple users3.5.0
wp.getProfileGet current user profile3.5.0
wp.editProfileEdit user profile3.5.0
wp.getPageGet single page2.2.0
wp.getPagesGet multiple pages2.2.0
wp.newPageCreate new page2.2.0
wp.deletePageDelete a page2.2.0
wp.editPageEdit a page2.2.0
wp.getPageListGet page list2.2.0
wp.getAuthorsGet site authors2.2.0
wp.getTagsGet all tags2.7.0
wp.newCategoryCreate category2.2.0
wp.deleteCategoryDelete category2.5.0
wp.suggestCategoriesSearch categories2.2.0
wp.getCommentGet single comment2.7.0
wp.getCommentsGet multiple comments2.7.0
wp.deleteCommentDelete comment2.7.0
wp.editCommentEdit comment2.7.0
wp.newCommentCreate comment2.7.0
wp.getCommentCountGet comment counts2.5.0
wp.getCommentStatusListGet comment statuses2.7.0
wp.getPostStatusListGet post statuses2.5.0
wp.getPageStatusListGet page statuses2.5.0
wp.getPageTemplatesGet page templates2.6.0
wp.getOptionsGet blog options2.6.0
wp.setOptionsSet blog options2.6.0
wp.getMediaItemGet media item3.1.0
wp.getMediaLibraryGet media library3.1.0
wp.getPostFormatsGet post formats3.1.0
wp.getPostTypeGet post type info3.4.0
wp.getPostTypesGet all post types3.4.0
wp.getRevisionsGet post revisions3.5.0
wp.restoreRevisionRestore a revision3.5.0
wp.uploadFileUpload file (alias)
wp.deleteFileDelete file (alias)
wp.getCategoriesGet categories (alias)

Blogger API (blogger.*)

Legacy Blogger-compatible methods:

MethodDescription
blogger.getUsersBlogsGet user’s blogs
blogger.getUserInfoGet user information
blogger.getPostGet single post
blogger.getRecentPostsGet recent posts
blogger.newPostCreate new post
blogger.editPostEdit a post
blogger.deletePostDelete a post

MetaWeblog API (metaWeblog.*)

MetaWeblog protocol with MovableType extensions:

MethodDescription
metaWeblog.newPostCreate new post
metaWeblog.editPostEdit a post
metaWeblog.getPostGet single post
metaWeblog.getRecentPostsGet recent posts
metaWeblog.getCategoriesGet categories
metaWeblog.newMediaObjectUpload media file
metaWeblog.deletePostDelete post (alias)
metaWeblog.getUsersBlogsGet blogs (alias)

MovableType API (mt.*)

MovableType-compatible methods:

MethodDescription
mt.getCategoryListGet all categories
mt.getRecentPostTitlesGet recent post titles
mt.getPostCategoriesGet post’s categories
mt.setPostCategoriesSet post’s categories
mt.supportedMethodsList supported methods
mt.supportedTextFiltersList text filters
mt.getTrackbackPingsGet trackbacks
mt.publishPostPublish a post

Pingback (pingback.*)

Pingback protocol implementation:

MethodDescription
pingback.pingRegister a pingback
pingback.extensions.getPingbacksGet pingbacks for URL

Demo Methods

Test methods for verifying connectivity:

MethodDescription
demo.sayHelloReturns "Hello!"
demo.addTwoNumbersAdds two numbers

Authentication

Login Process

  1. Client sends username/password with each request
  2. login() method authenticates via wp_authenticate()
  3. On success, sets current user via wp_set_current_user()
  4. On failure, returns IXR_Error(403)

Security Features

  • Rate Limiting: Failed auth flags $auth_failed to prevent brute force
  • Capability Checks: Each method verifies user capabilities
  • Sensitive Parameter Handling: Uses #[SensitiveParameter] attribute
php
public function login(
    $username,
    #[SensitiveParameter]
    $password
) { ... }

Enabling/Disabling XML-RPC

Check Status

// XML-RPC is enabled by default since WordPress 3.5.0

Disable Authenticated Methods

// Disables methods requiring authentication (not pingbacks)
add_filter( 'xmlrpc_enabled', '__return_false' );

Remove Specific Methods

add_filter( 'xmlrpc_methods', function( $methods ) {
    unset( $methods['pingback.ping'] );
    return $methods;
});

Blog Options

Available options accessible via wp.getOptions/wp.setOptions:

Read-Only Options

OptionDescription
software_name"WordPress"
software_versionWordPress version
blog_urlSite URL
home_urlHome URL
login_urlLogin URL
admin_urlAdmin URL
image_default_link_typeDefault image link type
image_default_sizeDefault image size
image_default_alignDefault image alignment
templateCurrent template
stylesheetCurrent stylesheet
post_thumbnailTheme thumbnail support

Writable Options

OptionDescription
time_zoneGMT offset
blog_titleSite title
blog_taglineSite tagline
date_formatDate format
time_formatTime format
users_can_registerRegistration enabled
thumbnail_size_wThumbnail width
thumbnail_size_hThumbnail height
thumbnail_cropCrop thumbnails
medium_size_wMedium width
medium_size_hMedium height
medium_large_size_wMedium-large width
medium_large_size_hMedium-large height
large_size_wLarge width
large_size_hLarge height
default_comment_statusDefault comment status
default_ping_statusDefault ping status

Data Structures

Post Structure (wp.* methods)

php
array(
    'post_id'           => '123',
    'post_title'        => 'Title',
    'post_date'         => IXR_Date,
    'post_date_gmt'     => IXR_Date,
    'post_modified'     => IXR_Date,
    'post_modified_gmt' => IXR_Date,
    'post_status'       => 'publish',
    'post_type'         => 'post',
    'post_name'         => 'slug',
    'post_author'       => '1',
    'post_password'     => '',
    'post_excerpt'      => '',
    'post_content'      => 'Content...',
    'post_parent'       => '0',
    'post_mime_type'    => '',
    'link'              => 'https://...',
    'guid'              => 'https://...',
    'menu_order'        => 0,
    'comment_status'    => 'open',
    'ping_status'       => 'open',
    'sticky'            => false,
    'post_thumbnail'    => array(...),
    'post_format'       => 'standard',
    'terms'             => array(...),
    'custom_fields'     => array(...),
    'enclosure'         => array(...),
)

Term Structure

php
array(
    'term_id'          => '5',
    'name'             => 'Category Name',
    'slug'             => 'category-name',
    'term_group'       => '0',
    'term_taxonomy_id' => '5',
    'taxonomy'         => 'category',
    'description'      => '',
    'parent'           => '0',
    'count'            => 10,
    'custom_fields'    => array(...),
)

User Structure

php
array(
    'user_id'      => '1',
    'username'     => 'admin',
    'first_name'   => 'John',
    'last_name'    => 'Doe',
    'registered'   => IXR_Date,
    'bio'          => '',
    'email'        => '[email protected]',
    'nickname'     => 'John',
    'nicename'     => 'john',
    'url'          => 'https://...',
    'display_name' => 'John Doe',
    'roles'        => array('administrator'),
)

Comment Structure

php
array(
    'date_created_gmt' => IXR_Date,
    'user_id'          => '0',
    'comment_id'       => '1',
    'parent'           => '0',
    'status'           => 'approve',
    'content'          => 'Comment text...',
    'link'             => 'https://...',
    'post_id'          => '123',
    'post_title'       => 'Post Title',
    'author'           => 'Commenter',
    'author_url'       => '',
    'author_email'     => '[email protected]',
    'author_ip'        => '192.168.1.1',
    'type'             => '',
)

Error Codes

CodeDescription
400Insufficient arguments
401Permission denied
403Invalid credentials / Forbidden
404Resource not found
405XML-RPC disabled
409Conflict (modified since)
500Internal server error

Pingback-Specific Errors

CodeDescription
0Generic error
16Source URL doesn’t exist
17Source doesn’t link to target
32Target doesn’t exist
33Target not pingback-enabled
48Pingback already registered

Making XML-RPC Requests

Request Format

<?xml version="1.0"?>
<methodCall>
    <methodName>wp.getPosts</methodName>
    <params>
        <param><value><int>1</int></value></param>
        <param><value><string>username</string></value></param>
        <param><value><string>password</string></value></param>
    </params>
</methodCall>

PHP Example

php
$client = new IXR_Client( 'https://example.com/xmlrpc.php' );
$client->query( 'wp.getPosts', 1, 'username', 'password', array(
    'post_type' => 'post',
    'number'    => 10,
));
$posts = $client->getResponse();

Security Considerations

  1. Always use HTTPS for XML-RPC connections
  2. Consider Application Passwords instead of main credentials
  3. Disable if not needed via xmlrpc_enabled filter
  4. Monitor for abuse – common target for brute force attacks
  5. Use firewall rules to restrict XML-RPC access if needed
  • wp-includes/class-IXR.php – IXR library
  • xmlrpc.php – Entry point
  • wp-includes/functions.php – Helper functions (xmlrpc_getposttitle, etc.)