Faragiri

Learn The REST API WordPress

Four unauthenticated requests measured against a live install, the flag that decides whether your field appears at all, and the pagination that is not in the body.

4Sections
3Min read
5Depth

Four requests, no credentials

What a stranger can read from an install nobody configured

Every row was dispatched against a live site with no authentication at all, and the statuses are what came back.

  1. YesThe posts, with their content200. This is the design, and the block editor depends on itYes
  2. YesThe list of users who have published200. Display names and slugs, which are valid usernamesYes
  3. NoThe site settings401. Reading these needs a credentialNo
  4. NoCreating a post401. Every write doesNo
  5. Not checkedWhether your custom fields are in thereNobody checked. Only show_in_rest decides, and its default is falseNot checked

The unknown row cuts both ways: a field you wanted exposed may be missing, and a field you did not think about may be public. The only way to know is to read the response rather than the admin screen.

Every WordPress install answers a REST API whether or not anyone asked for
one. Measured on a live WordPress 7.1 site on 2026-09-02, 195 routes are
registered, and dispatched without any authentication:
GET /wp/v2/posts answers 200,
GET /wp/v2/users answers 200,
GET /wp/v2/settings answers 401 and
POST /wp/v2/posts answers 401.

The second of those is the one to look at. Reading is public by default for
content, and that includes the user list, which returns the display names and
slugs of everyone who has published. That is by design and it is also a list of
valid usernames for anyone attempting logins.

Using it as a backend, and the four things to know

  • Custom post types are only in the API if registered with
    'show_in_rest' => true, and the same is true of meta fields and
    taxonomies. This is the reason a field exists in the admin and not in the
    response
  • register_rest_field adds a computed field to an existing route,
    which is how you avoid a second request for something derived
  • _fields=id,title,link on any request trims the response, which
    matters because the default post object is large
  • Pagination is in headers: X-WP-Total and
    X-WP-TotalPages, not in the body, so a client that reads only the
    JSON has no idea how many pages there are

The route names themselves are worth reading once.
/wp/v2/ is core's namespace, and a plugin registering its own
appears as /its-name/v1/, so the list of namespaces on an install
is a list of what has opinions about your data. On this site the 195 routes
include core's content types, the block editor's own, and every plugin that
registered one.

Authentication is the part WordPress does not solve for you

Cookie authentication works only from within the site itself and requires a
nonce, so it covers the admin's own JavaScript and nothing else. For anything
external the built in answer is application passwords: generated per user in the
profile screen, sent as HTTP basic auth, and revocable individually.

They are a real credential with that user's full permissions, so the account
they belong to should be one created for the integration with the least role
that works. Sending them means sending a password on every request, which is
acceptable over https and is the reason the API refuses them otherwise.

What to run in 2026

wp rest, part of WP-CLI and free, lists the routes an install
actually exposes and calls them from the command line with the permissions of a
chosen user. It replaced guessing at the URL and getting a 404 that could mean
either the route or the resource is missing.

Application passwords are the second, free and built into WordPress since
5.6. They replaced installing a JWT plugin, which was the previous answer and
put authentication for the whole site in third party code. If an install has one
of those plugins and no application passwords in use, that is worth revisiting
rather than extending.

Where this stalls people

The stall is discovering the API is open after the site is live. Nobody
enabled it, it is on by default, and the user enumeration above is the finding
that turns up in a client's security review. The usual response is a plugin that
disables the whole API, which then breaks the block editor, because the editor
is a REST client.

The proportionate fix is narrower: filter the users route to require
authentication and leave the rest alone. Decide deliberately what should be
public, because the default is that content is, and check the actual statuses
rather than assuming. What the same site serves to a browser is
the template
hierarchy, and building one
, the hooks that filter these responses are
hooks, filters and
writing your own
, and the conventions the API follows are
resources, verbs and status codes,
inside what runs a large share of the
web
.

Alongside this

Above this