Back

Wordpress.com API Essential Guide

Aug 7, 20246 minute read

What type of API does Wordpress.com provide?

REST API

  • The WordPress REST API is the main official API provided by WordPress core.
  • It allows developers to programmatically manage site content and functionality.
  • The REST API has been part of WordPress core since version 4.7.
  • It uses multiple endpoints for different resources.

GraphQL API

  • WordPress supports GraphQL through plugins like WPGraphQL, not natively in core.
  • It provides a single endpoint for all queries.
  • GraphQL allows requesting only needed data, reducing over-fetching compared to REST.
  • It has a strongly typed schema, making it easier to validate data.

Other API Types

  • WordPress does not natively use SOAP APIs.
  • The Block Data API provides data via both REST and GraphQL.

Does the Wordpress.com API have webhooks?

Based on the search results provided, it appears that the official WordPress.com API does not have built-in webhooks. However, there are some key points to consider:

Third-Party Webhook Solutions

  1. While WordPress.com itself doesn't offer native webhook functionality, there are third-party plugins like WP Webhooks that provide webhook capabilities for WordPress sites.

  2. WP Webhooks allows you to create custom webhooks and automate tasks within WordPress.

Available Events with WP Webhooks

WP Webhooks offers various events you can subscribe to, including:

  • User-related events: login, register, update, and deletion
  • Post-related events: new post, update post, and delete post
  • Comment-related events: new, updated, trashed, or deleted comments
  • Email-related events: when an email is sent from the WordPress system
  • Custom WordPress hook calls

Implementation with WP Webhooks

To implement webhooks using WP Webhooks:

  1. Install and activate the WP Webhooks plugin on your WordPress site.
  2. Create webhook action URLs and add triggers for the events you want to monitor.
  3. Configure authentication methods (API Key, Bearer Token, or Basic Auth) for security.
  4. Test your webhooks using the built-in testing functionality.

Best Practices

  1. Use authentication to secure your webhooks.
  2. Test thoroughly before deploying to production.
  3. Monitor webhook performance and adjust as needed.

It's important to note that this solution is not native to WordPress.com but rather a third-party plugin that adds webhook functionality to WordPress sites. If you're specifically looking for official WordPress.com API webhooks, they do not appear to be available based on the provided search results.

Rate Limits and other limitations

Based on the search results provided, here are the key points regarding the API Rate Limits of the WordPress.com API:

Default Rate Limit

The default rate limit for the WordPress.com API is not explicitly stated in the search results. However, for the WP REST Cop plugin, which can be used to manage access to the WP REST API, the default rate limit is 500 requests per hour [2].

Configurable Limits

Rate limits can be configured using plugins or custom code. For example, using the WP REST Cop plugin, you can set custom limits:

add_action( 'wprestcop_plugin_loaded', function( $wprestcop ) { $wprestcop ->set_limit( 10 ) ->set_interval( 5 * MINUTE_IN_SECONDS ); } );

This example sets a limit of 10 requests every 5 minutes [2].

Headers

When using rate limiting, the following headers are typically sent with each request:

  • X-RateLimit-Limit: Requests allowed per interval
  • X-RateLimit-Remaining: Remaining requests allowed in the current interval
  • X-RateLimit-Reset: Seconds until the limit is reset

If a client has reached their limit, an additional "Retry-After" header is sent, indicating the seconds until the limit is reset [2].

Key Considerations

  1. Rate limits may vary depending on the specific WordPress installation and any custom configurations or plugins in use.

  2. The WordPress.com hosted service may have different rate limits compared to self-hosted WordPress installations.

  3. It's recommended to always check the API documentation or contact the site administrator for the most up-to-date and accurate rate limit information for a specific WordPress site.

Best Practices

  1. Use pagination and limit parameters to retrieve large datasets in smaller chunks rather than trying to get thousands of items in a single request.

  2. Implement caching on the client side to reduce the number of API calls needed.

  3. Consider using authentication for API requests to potentially get higher rate limits for authorized users.

Hard Limit

There appears to be a hard upper limit of 100 items that can be returned in a single API request, even if a higher limit is specified.

It's important to note that the specific rate limits for WordPress.com API were not provided in the search results. The information above is based on general WordPress API practices and plugins like WP REST Cop. For the most accurate and up-to-date information on WordPress.com API rate limits, it's best to consult the official WordPress.com API documentation or contact their support directly.

Latest API Version

Based on the search results provided, here are the key points regarding the most recent version of the WordPress.com API:

Current Version

The search results do not provide a specific version number for the most recent WordPress.com API. However, they do mention some details about the REST API:

  1. The WordPress.com REST API is available and documented for developers to use.

  2. The API endpoints are automatically documented in the Developer Console as they are added.

Key Points

  • The WordPress.com REST API provides access to various resources such as posts, users, sites, and more.

  • The API uses JSON for data exchange.

  • Authentication is required for certain endpoints and operations.

  • The API supports various HTTP methods like GET, POST, PUT, etc., depending on the operation.

Additional Information

  • For self-hosted WordPress sites, the WordPress REST API was shipped as part of WordPress core in version 4.7.

  • The WordPress.com API structure is slightly different from the self-hosted WordPress REST API.

  • The API documentation includes information on endpoints, parameters, response objects, and example queries.

It's important to note that the search results do not provide a specific version number for the most recent WordPress.com API. To get the most up-to-date information, it would be best to check the official WordPress.com developer documentation or contact their support directly.

How to get a Wordpress.com developer account and API Keys?

  1. Create a WordPress.com account if you don't already have one.

  2. Go to the WordPress.com Developer Portal at https://developer.wordpress.com/.

  3. Click on "Create New Application" to register your application.

  4. Fill out the required information about your application, including:

    • Name
    • Description
    • Website URL
    • Redirect URL(s)
    • Type of application (web, native, etc.)
  5. Agree to the WordPress.com API Terms of Service.

  6. Submit your application for review. WordPress.com will review it and provide you with API credentials if approved.

  7. Once approved, you'll receive a client ID and client secret to use for authentication.

  8. You can then use these credentials to authenticate and make API requests on behalf of WordPress.com users.

What can you do with the Wordpress.com API?

Based on the search results provided, here are the key data models you can interact with using the WordPress.com API, along with what is possible for each:

Posts

  • Read, create, update, and delete posts
  • Query and filter posts based on various parameters
  • Retrieve post metadata
  • Manage post categories and tags

Pages

  • Read, create, update, and delete pages
  • Query and filter pages
  • Retrieve page metadata

Comments

  • Read, create, update, and delete comments
  • Moderate comments
  • Query and filter comments

Users

  • Retrieve user information
  • Update user profiles
  • Manage user roles and capabilities

Media

  • Upload, retrieve, and delete media files
  • Update media metadata

Taxonomies

  • Retrieve and manage categories, tags, and custom taxonomies
  • Create, update, and delete taxonomy terms

Settings

  • Retrieve and update site settings

Themes

  • Retrieve information about installed themes
  • Activate and customize themes

Plugins

  • Retrieve information about installed plugins
  • Activate, deactivate, and update plugins
  • Retrieve and manage navigation menus

Revisions

  • Retrieve and manage post and page revisions

Custom Post Types

  • Interact with custom post types if they are configured to be accessible via the API
  • Perform site-wide searches

Authentication

  • Authenticate users and manage access tokens

It's important to note that the specific capabilities for each data model may vary depending on the user's authentication level and the site's configuration. Additionally, the WordPress REST API is extensible, allowing developers to add custom endpoints for additional functionality.