Title: The REST API in WordPress 5.0
Author: Will Earnhardt
Published: December 6, 2018

---

 [  ](https://profiles.wordpress.org/earnjam/) [Will Earnhardt](https://profiles.wordpress.org/earnjam/)
4:21 pm _on_ December 6, 2018     
Tags: [5.0 ( 36 )](https://make.wordpress.org/core/tag/5-0/),
[dev-notes ( 650 )](https://make.wordpress.org/core/tag/dev-notes/)   

# The REST API in WordPress 5.0

WordPress 5.0 contains several additions to the REST APIREST API The REST API is
an acronym for the RESTful Application Program Interface (API) that uses HTTP requests
to GET, PUT, POST and DELETE data. It is how the front end of an application (think“
phone app” or “website”) can communicate with the data store (think “database” or“
file system”) [https://developer.wordpress.org/rest-api/](https://developer.wordpress.org/rest-api/)
that help provide the new blockBlock Block is the abstract term used to describe
units of markup that, composed together, form the content or layout of a webpage
using the WordPress editor. The idea combines concepts of what in the past may have
achieved with shortcodes, custom HTML, and embed discovery into a single consistent
API and user experience. based editor with all the data it needs. Let’s talk about
them!

## New CoreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. Endpoints

Several new endpoints have been added to help supply the new block based editor 
with the data it needs. They all have been built on the existing REST API infrastructure,
so the same action and filterFilter Filters are one of the two types of Hooks [https://codex.wordpress.org/Plugin_API/Hooks](https://codex.wordpress.org/Plugin_API/Hooks).
They provide a way for functions to modify data of other functions. They are the
counterpart to Actions. Unlike Actions, filters are meant to work in an isolated
manner, and should never have side effects such as affecting global variables and
output. hooksHooks In WordPress theme and development, hooks are functions that 
can be applied to an action or a Filter in WordPress. Actions are functions performed
when a certain event occurs in WordPress. Filters allow you to modify certain functions.
Arguments used to hook both filters and actions look the same. throughout can be
used to modify requests and responses.

### Autosaves

An Autosaves endpoint has been added and registered for all post types except `attachment`(
but including custom post types). The endpoint utilizes the `WP_REST_Autosaves_Controller`
class which extends `WP_REST_Revisions_Controller`. Registering the endpoint for
all post types, and not just those with revisionsRevisions The WordPress revisions
system stores a record of each saved draft or published update. The revision system
allows you to see what changes were made in each revision by dragging a slider (
or using the Next/Previous buttons). The display indicates what has changed in each
revision., was an intentional design decision because all post types need the ability
to autosave whether or not revisions are enabled.

Only `id`, `title`, `post_content` and `excerpt` are saved on this endpoint, but
a full, updated post object is returned in the response. It also returns the `preview_link`,
which drives the Post Preview button in the new editor. 

_Note: This endpoint requires requests to be authenticated._

Ticketticket Created for both bug reports and feature development on the bug tracker.
[#43316](https://core.trac.wordpress.org/ticket/43316)

### Search

In order to facilitate searching across multiple post types, a new `WP_REST_Search_Controller`
class was added which registers a `/wp/v2/search` endpoint. This endpoint is used
by the link inserter in the new editor. 

Search types are handled by extending `WP_REST_Search_Handler`. The default search
type is `WP_REST_Post_Search_Handler`, but this can be filtered by plugins or a 
theme by using the `wp_rest_search_handlers` filter.

Ticket [#39965](https://core.trac.wordpress.org/ticket/39965)

### Block Type

A new hidden post type of `wp_block` has been added for storing reusable blocks.
Information about the post type is available at `wp/v2/types/wp_block`, including
the labels and the capabilitiescapability A **capability** is permission to perform
one or more types of task. Checking if a user has a capability is performed by the`
current_user_can` function. Each user of a WordPress site might have some permissions
but not others, depending on their role. For example, users who have the Author 
role usually have permission to edit their own posts (the “edit_posts” capability),
but not permission to edit other users’ posts (the “edit_others_posts” capability).
required in order to read and create reusable blocks.

Ticket [#45098](https://core.trac.wordpress.org/ticket/45098)

### Blocks

The individual reusable blocks can be retrieved from `wp/v2/blocks`. This uses the
standard post controller to return post objects containing the rendered content 
and associated data of each reusable block. 

_Note: This endpoint requires requests to be authenticated._

Ticket [#45098](https://core.trac.wordpress.org/ticket/45098)

### Block Renderer

All dynamic blocks with server-side rendering, such as the latest comments or archives,
can be accessed at `wp/v2/block-renderer/<name>`. Names have to be structured as`
namespace/block-name`, where namespace is the name of your pluginPlugin A plugin
is a piece of software containing a group of functions that can be added to a WordPress
website. They can extend functionality or add new features to your WordPress websites.
WordPress plugins are written in the PHP programming language and integrate seamlessly
with WordPress. These can be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
or can be cost-based plugin from a third-party. or theme. An example core endpoint
would be `wp/v2/block-renderer/core/archives`.

All registered attributes for the block being rendered are accepted as GET parameters.
These are validated against the schema matching what was declared in `register_block_type()`.

_Note: This endpoint requires requests to be authenticated._

Ticket [#45098](https://core.trac.wordpress.org/ticket/45098)

### Themes

A minimal `wp/v2/themes` themes endpoint has been introduced to inform the new block-
based editor of the features that the active theme supports. This allows the correct
panels, features, and UIUI User interface elements to be shown or hidden for the
user.

This will currently only return data about the active theme. This endpoint must 
also be accompanied by the `status` parameter with a value of `active`. For example:`
wp/v2/themes?status=active`

The current data included in the response is:

 * A list of post formats supported.
 * Post thumbnail support details.
 * Whether responsive embeds are supported.

In the future the themes endpoint can be expanded, but this was the minimum required
information for the new block editor to have all the data it needs to work correctly.

_Note: This endpoint requires requests to be authenticated._

Ticket [#45016](https://core.trac.wordpress.org/ticket/45016)

## Additional Changes of Note

In addition to the new endpoints, there are a number of changes to REST API responses
developers should be aware of.

 * All custom taxonomies must have `show_in_rest` set to true in order to appear
   in the new editor.
 * A new function `wp_is_json_request()` has been added to determine if the request
   is expecting a JSONJSON JSON, or JavaScript Object Notation, is a minimal, readable
   format for structuring data. It is used primarily to transmit data between a 
   server and web application, as an alternative to XML. response, and if so, silence
   PHPPHP The web scripting language in which WordPress is primarily architected.
   WordPress requires PHP 7.4 or higher warnings and errors. [[43730]](https://core.trac.wordpress.org/changeset/43730)
 * In order for clients to present permalink previews, the REST API must share the
   computed results of `get_sample_permalink()`. These values are now exposed as`
   permalink_template` and `generated_slug` for public, viewable post types, but
   only for `context=edit`. [[43720]](https://core.trac.wordpress.org/changeset/43720)
 * Any fields registered with `register_rest_field()` now respect the `?_fields=`
   filter parameter in the request URLURL A specific web address of a website or
   web page on the Internet, such as a website’s URL www.wordpress.org. [[43736]](https://core.trac.wordpress.org/changeset/43736)
 * Users with `read_private_posts` capabilitycapability A **capability** is permission
   to perform one or more types of task. Checking if a user has a capability is 
   performed by the `current_user_can` function. Each user of a WordPress site might
   have some permissions but not others, depending on their role. For example, users
   who have the Author role usually have permission to edit their own posts (the“
   edit_posts” capability), but not permission to edit other users’ posts (the “
   edit_others_posts” capability). can now query for private posts on the posts 
   endpoint. [[43694]](https://core.trac.wordpress.org/changeset/43694)
 * The `unfiltered_html` capability is now declared using JSON Hyper Schema `targetSchema`.
   [[43682]](https://core.trac.wordpress.org/changeset/43682)
 * A `block_version` value is added to the post object to denote whether post contains
   blocks and of what version. At this point there is only one version, but if the
   block format has backwards compatibility breaking changes in the future, we can
   increment this value as needed. [[43770]](https://core.trac.wordpress.org/changeset/43770)
 * New `rest_after_*` action hooks have been added that fire after all write operations
   have completed. [[42864]](https://core.trac.wordpress.org/changeset/42864)

[View all REST API tickets in the 5.0 release milestone »](https://core.trac.wordpress.org/query?component=REST+API&milestone=5.0&or&focuses=~rest-api&milestone=5.0&col=id&col=summary&col=status&col=milestone&col=owner&col=type&col=priority&order=priority)

[#5-0](https://make.wordpress.org/core/tag/5-0/), [#dev-notes](https://make.wordpress.org/core/tag/dev-notes/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2018/12/06/the-rest-api-in-wordpress-5-0/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2018/12/06/the-rest-api-in-wordpress-5-0/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2018/12/06/the-rest-api-in-wordpress-5-0/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2018/12/06/the-rest-api-in-wordpress-5-0/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2018/12/06/the-rest-api-in-wordpress-5-0/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2018/12/06/the-rest-api-in-wordpress-5-0/?share=linkedin)

 1.  ![](https://secure.gravatar.com/avatar/fea6c00b1c2aebaf6b3ffb0ae7114f0919449f355074d6951c39b73cbec6fd10?
     s=32&d=mm&r=g)
 2.   [Abdullah Ramzan](https://profiles.wordpress.org/abdullahramzan/)  5:12 pm _on_
     December 6, 2018
 3.  🎉 Yay!!!
      [@earnjam](https://profiles.wordpress.org/earnjam/) Would you mind 
     to remove an extra space in the first line.
 4.  > WordPress 5.0 contains several additions to the REST APIREST API The REST API
     > is an acronym for the RESTful Application Program Interface (API) that uses 
     > HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of 
     > an application (think “phone app” or “website”) can communicate with the data
     > store (think “database” or “file system”)
     >  [https://developer.wordpress.org/rest-api/](https://developer.wordpress.org/rest-api/)
 5.   * ![](https://secure.gravatar.com/avatar/96e43de37208e6999d2cda7ba1c6f76467a80218ae7c1d8abf45f4c709664ac9?
        s=32&d=mm&r=g)
      *  [William Earnhardt](https://profiles.wordpress.org/earnjam/)  5:14 pm _on_
        December 6, 2018
      * Thanks! I just fixed it.
 6.  ![](https://secure.gravatar.com/avatar/79afa9040f8dcefe5af28fef33a74a809cf0ac0801a65dfe5c71a7d9998e1472?
     s=32&d=mm&r=g)
 7.   [jane1811](https://profiles.wordpress.org/jane1811/)  8:59 pm _on_ December 6,
     2018
 8.  How do you switch back to edit in htmlHTML HyperText Markup Language. The semantic
     scripting language primarily used for outputting content in web browsers.? I need
     to put in short codes. I don’t like this, too much change. I like the old editor
     better, easier to use.
 9.   * ![](https://secure.gravatar.com/avatar/d28c0335e31f47e40a8e681d5bacc009f33ae64f37ee886cfca26ce362989edb?
        s=32&d=mm&r=g)
      *  [imranhossainalif](https://profiles.wordpress.org/imranhossainalif/)  5:53
        am _on_ December 8, 2018
      * **hey jane1811, you can see this , that will be help you – **[Solve post Editor problems with WordPress 5.0](http://www.itevs.com/solve-post-editor-problems-with-wordpress-5-0/)
 10. ![](https://secure.gravatar.com/avatar/a851894aeb0951805d114eb5d448b0354ff2d64e341e4ccd70edc282e6ee2564?
     s=32&d=mm&r=g)
 11.  [Jackalope Co.](https://profiles.wordpress.org/thedonquixotic/)  10:31 pm _on_
     December 11, 2018
 12. [@jane1811](https://profiles.wordpress.org/jane1811/) You can just hit ctr-shift-
     alt-m to switch to the code editor mode inside GutenbergGutenberg The Gutenberg
     project is the new Editor Interface for WordPress. The editor improves the process
     and experience of creating new content, making writing rich content much simpler.
     It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc.
      [https://wordpress.org/gutenberg/](https://wordpress.org/gutenberg/).
     You don’t even need the Classic editor that Imran linked you.
 13. As an aside, the “I don’t want things to change, I don’t want to learn new things”
     attitude will be the death of the WordPress community. I like a lot of things 
     about the WordPress community. It’s a good deal friendly in many ways than other
     developer focused open sourceOpen Source Open Source denotes software for which
     the original source code is made freely available and may be redistributed and
     modified. Open Source **must be** delivered via a licensing model, see GPL. projects.
     WordPress itself has a broader focus and appeal than many other projects. BUT 
     it also comes with some downsides, namely, lots of people just looking to make
     a quick buck with spam-blogs, and people seem to get very set in their ways and
     not as willing to learn or adapt. WordPress needs to stay open and welcoming to
     people but we also need to sharpen people up, push them and the community to better
     educate and elevate what we do.
 14. ![](https://secure.gravatar.com/avatar/eedf2aed611550aae688b658dae925458e935a8eb0f25b68eddd2d3ca9275dfd?
     s=32&d=mm&r=g)
 15.  [feedsy](https://profiles.wordpress.org/feedsy/)  11:34 am _on_ December 14, 
     2018
 16. Can someone please point me in the right direction?
 17. We used to use a pluginPlugin A plugin is a piece of software containing a group
     of functions that can be added to a WordPress website. They can extend functionality
     or add new features to your WordPress websites. WordPress plugins are written 
     in the PHP programming language and integrate seamlessly with WordPress. These
     can be free in the WordPress.org Plugin Directory [https://wordpress.org/plugins/](https://wordpress.org/plugins/)
     or can be cost-based plugin from a third-party. called [REST API](http://v2.wp-api.org/)
     that helped our WordPress posts feed into an app.
 18. But the plugin had to be deactivated because it stopped the new post editor in
     WordPress 5.0.1 from working (would not Publish/Save, Featured imageFeatured image
     A featured image is the main image used on your blog archive page and is pulled
     when the post or page is shared on social media. The image can be used to display
     in widget areas on your site or in a summary list of posts. preview and CategoryCategory
     The 'category' taxonomy lets you group posts / content together that share a common
     bond. Categories are pre-defined and broad ranging. and Tags tabs did not appear
     in editor).
 19. Now, with the plugin deactivated, no new posts are able to be received/viewed 
     in the app (but existing posts are OK).
 20. What is the different between the plugin and what is now done natively in coreCore
     Core is the set of software required to run WordPress. The Core Development Team
     builds WordPress. and what can we do to get back the bits of the plugin than mace
     the post to app work?
 21. Note: I am not a coder so am very happy to freelance this out to someone to fix
     for us.

Comments are closed.

# Post navigation

[← Media 5.0 Guide](https://make.wordpress.org/core/2018/12/06/media-5-0-guide/)

[WordPress 5.0 Field Guide →](https://make.wordpress.org/core/2018/12/06/wordpress-5-0-field-guide/)