This article discusses the exciting feature of WordPress core: REST API support, along with various plugins that utilize it in unique ways.
REST API Use Cases
In basic terms, the REST API is a communication protocol for APIs. WordPress began offering built-in support for the REST API starting with version 4.7, which was released in 2016. This version laid the foundation for REST API endpoints, allowing interaction with WordPress data through standard HTTP methods. Since then, the REST API has seen ongoing improvements and expansions in later WordPress versions, introducing new features, endpoints, and enhancements that give developers greater flexibility and capabilities for creating applications on the WordPress platform. Data is transmitted in JSON format.
REST API is a developer-oriented feature of WordPress but can be used for much simpler tasks, such as collecting data from various sources on one website, as described here.
However, here are the examples of more advanced usage of this protocol:
- Headless WordPress websites. Headless structure decouples the front end from the backend, enabling front-end frameworks to consume WordPress content dynamically.
- Mobile App integration. Using REST API, the mobile app connects to the WordPress backend to retrieve content and user data.
- External service integration. REST API enables integration between WordPress and external systems, such as CRMs or eСommerce platforms, for data synchronization and user authentication.
- Custom dashboard and administrative interfaces. Such functionality enables communication between custom front-end interfaces and the WordPress backend, improving the management of content, settings, and user accounts. For instance, the WordPress.com dashboard Calysto communicates with the WordPress core using REST API.
- Data migration and synchronization. REST API functionality is crucial for migrating content between WordPress sites or synchronizing data with external databases.
- Custom applications and web services. REST API allows developers to build custom web applications or services that interact with WordPress programmatically, retrieving content and updating data through REST API endpoints.
The use cases listed above are mostly for developers, and the data manipulation should be done with the help of code. Still, the main topic of this article is plugins that help users deal with REST API endpoints. The main use cases for it are fetching content from remote sources and posting it to the remote sources using front-end inputs (forms) or dealing with endpoints, their visibility, and security.
So, let’s focus on such plugins and what they can offer.
WPGetAPI (Freemium)
🏆 Best for event-driven posting on remote sites.
This plugin enables dealing with REST API endpoints to retrieve and post data as well as other manipulations with remote content. The interface is quite straightforward; however, it requires some coding skills to format the fetched content.
Key features:
- unlimited APIs;
- the output comes as a shortcode;
- settings for query parameters and headers.
Pricing: free; $89/year for one site.
Pros:
- quite powerful functionality;
- a free version is available;
- the Pro version has a list of event triggers.
Cons:
- it requires writing PHP code to format the content;
- to display WooCommerce products, create listings, or use authorization, the extra add-ons are required, with the price of $89-165 for one site;
- no caching;
- not much documentation, and half of the links didn’t work when I tried to read the docs.
JSON Content Importer (Freemium)
🏆 Best for fetching whole pages.
This plugin is better to be called Pro because this is where it has most of the functionality. However, there’s also a free version, and it’s not only limited but also has a different approach and tools to work with it.
The free version is for fetching data from remote sources and uses the Gutenberg block with all the settings directly in the editor or a shortcode with editable parameters. For content formatting, there’s a markup syntax.
The Pro version offers much more flexible settings, POST/PUT methods, Twig formatting (so some PHP can be added to the templates as well), third-party plugin integrations, etc.
Key features:
- a complete functionality for dealing with remote APIs;
- data caching;
- extra free plugins for AJAX reload and Cron plugins to extend the functionality.
Pricing: free (very limited); $59/year for one site.
Pros:
- supports data caching;
- offers a template engine, even in a free version (but it’s quite limited);
- a usage of Twig in Pro gives a lot of advantages;
- integration with custom fields plugins, Elementor, and Gutenberg;
- well-documented.
Cons:
- a bit confusing interface, which is not so easy to use;
- the user of this plugin should definitely have some coding skills.
Custom Endpoints for API (Premium)
🏆 Best for those who need endpoints for SQL queries.
I classify this plugin as Premium, even though there’s a free version, but it’s extremely limited. For the proper functionality, you will need not only the Enterprise plan of the plugin but probably a couple of other plugins from the same developer.
Key features:
- full functionality is on the Enterprise plan;
- SQL queries to endpoints functionality;
- OAuth 2.0 support.
Pricing: $245/year for one site for the Enterprise plan (the one with full functionality), plus the support costs starting at $99 a year.
Pros:
- sandbox to test a plugin;
- SQL queries to endpoints;
- a user-friendly interface;
Cons:
- it can get very expensive;
- the developer slices the functionality to small paid plugins, so you will most likely need and settle for more items, not to mention the paid tech support.
4 Free Add-Ons for WordPress REST API
These plugins are very useful, but they do more of a service job; that’s why I put them on a separate list.
WP REST API Controller
This plugin does exactly what its name suggests: it controls the visibility of endpoints the website has, supporting all the existing custom post types and meta keys. In addition, you can edit meta keys’ names to be used in the API requests. The plugin also supports taxonomies.
Pros and Cons: a very easy-to-use interface, and the name editor is a cool feature.
WP REST Cache
Communication using REST API means HTTP requests, so it can become an issue for the website’s performance. Luckily, there’s a way to cache endpoints to improve this situation. And this plugin is made exactly for this.
It has quite a comprehensive functionality, supports not only default but custom endpoints for posts and taxonomies, and you can specify the cache time-outs, flash it manually, and even see the number of times the cache has been retrieved.
Pros and Cons: a great plugin for what it is made for; no cons detected.
JWT Authentication for WP REST API
JWT tokens not only improve security but are also good for performance and scalability, passing users’ credentials and roles and using HTTP Authorization headers for this sake.
Pros and Cons: a great plugin for developers.
WP-REST-API V2 Menus
The plugin adds new routes for menus, as simple as that. It can be very useful for certain projects.
Pros and Cons: the only issue is that this plugin is not being frequently updated.
FAQ
What are REST API calls?
API calls in a RESTful API refer to the interactions between a client (such as a web browser, mobile app, or other software) and a server that hosts the API.
What is endpoint caching?
Endpoint caching is a technique used to improve the performance of REST API endpoints by storing the responses of these endpoints temporarily. When a client makes a request to a cached endpoint, the server checks if a cached response exists and, if so, returns the cached response instead of processing the request again.
How to access REST API URL for WordPress site?
Use {your-site.com}/wp-json/wp/v2/{resource-endpoint}. Examples of “resource-endpoint” are posts, comments, users, etc. For instance, the {your-site.com}/wp-json/wp/v2/posts will show posts, and {your-site.com}/wp-json/wp/v2/films – a CPT named “films.”