10

I know about the REST API and I know what JSON is. My understanding is that to properly use the REST API right now it requires that the official plugin be installed. However when I hit the above directory even on sites that do not have the plugin installed I get data back.

What is generating this? Is this relatively new or has this been in place for a while?

0

1 Answer 1

5

That's the root URL for the REST API when pretty permalinks are turned on. All WordPress installs have it,

When this answer was originally written WP 4.6 was out and only a handful of endpoints existed, and the plugin was needed for content endpoints, but they were merged in WP v4.7. The core infrastructure for the REST API has been available since 4.5, with functions such as register_rest_route being available.

However when I hit the above directory even on sites that do not have the plugin installed I get data back.

This is endpoint discovery data! A list of all the endpoints you're allowed/able to access. You may notice a large number of endpoints if you have for example Jetpack for example. This is how apps can automatically figure out what your site can do, or check for the presence of endpoints.

Note that the information shared is only relevant to you the person accessing it. Endpoints that require capabilities you don't have are not listed unless you login as a user who can do those things. E.g. you won't see POST endpoints for some content unless you're making authenticated requests as an author/editor or higher.

3
  • Thanks. That's kind of what I thought, but I couldn't find an explanation anywhere.
    – hcu564
    Nov 17, 2016 at 13:14
  • I don't think that associating it with REST API is a very good thing as that term is associated with specific end points. It is just a generic end point (doesn't even have to be a json) outside of admin, similar to the xml-rpc one. Nov 17, 2016 at 13:20
  • WP API and the content API are WP API and the content API, the REST API is the REST API, /wp-json is the root of the REST API
    – Tom J Nowell
    Nov 17, 2016 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.