Default Rest API Endpoints

Advertisement

WordPress provides various lists of Rest API endpoints.

They are used in various places.

In this article, we are going to see:

WordPress Rest API Default Endpoints 1
WordPress Rest API Default Endpoints 6

What are the Rest API endpoints? What are the Rest API endpoints?

Rest API endpoints are the way to access your WordPress website data outside your WordPress website.

Top ↑

What is the use of Rest API endpoints? What is the use of Rest API endpoints?

Suppose, You have to build an eCommerce website, Where you have used WooCommmerce and added multiple products.

Now, Suppose you want to build your eCommerce website mobile app then the Rest API endpoints allow accessing your website data.

So, You can manage products from your website which are accessible on the website itself and in the mobile app as well.

Struggling with downtime and WordPress problems? Kinsta is the hosting solution designed to save you time! Check out our features

Top ↑

How to use Rest API endpoints? How to use Rest API endpoints?

In WordPress you can access the Rest API endpoints by visiting the URL:

/wp-json/

E.g. My website is https://maheshwaghmare.com/

So, I can see my Rest API endpoints at:

https://maheshwaghmare.com/wp-json/

Top ↑

How to see your website Rest API endpoints? How to see your website Rest API endpoints?

Open the browser and visit:

https://example.com/wp-json/

Note: Here, I have used example.com. YOu can change it with your own website domain name. You can also use the localhost if you working local by flywheel or XAMPP.

Top ↑

WordPress Rest API Namespace WordPress Rest API Namespace

WordPress is amazing. It allows the developer to add custom Rest API endpoints as per requirement.

Each RestAPI endpoint is available with the namespaces.

What are namespaces?

Namespaces are simply prefixed paths.

WordPress uses the namespaces /wp/v2/ to register all the endpoints.

E.g.

https://maheshwaghmare.com/wp-json/wp/v2/

Here,

  • https://maheshwaghmare.com/wp-json/ – This is a Rest API base URL.
  • /wp/v2/ – This is a namespace reserve to the WordPress default endpoints.

Deploy your application to Kinsta – Start with a $20 Credit now. Deploy now and get $20 off

Top ↑

List of Default Endpoints List of Default Endpoints

Now, As we see in the above section when we visit the URL:
https://maheshwaghmare.com/wp-json/wp/v2/

We’ll see all the default list of Rest API endpoints.

See the categorized list of all the endpoints.

Posts Posts

Below is the list of all post’s endpoints:

/wp/v2/posts: {},
/wp/v2/posts/(?P<id>[\d]+): {},
/wp/v2/posts/(?P<parent>[\d]+)/revisions: {},
/wp/v2/posts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/posts/(?P<id>[\d]+)/autosaves: {},
/wp/v2/posts/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},

With the help of these endpoints, you’ll access the WordPress posts outside your WordPress website.

E.g.

Display the list of all WordPress posts with Rest API Display the list of all WordPress posts with Rest API

We can visit the URL:

https://maheshwaghmare.com/wp-json/wp/v2/posts/

By visiting this URL, we’ll get all the posts in JSON format.

E.g.

WordPress Rest API Default Endpoints 2
All Posts in JSON format

Here, You may confuse about how these data look like.

It’s a JSON format that shows like a big string.

To see the formatted output of the JSON data then install the browser extension.

I’m using the Chrome browser so, I’m installing the JSONVue chrome browser extension.

WordPress Rest API Default Endpoints 3
Chrome JSONVue Exntesion

After installing and activating the extension, just refresh the page.

You’ll see the formatted JSON output as:

WordPress Rest API Default Endpoints 4
JSON formatted output

Top ↑

Pages Pages

/wp/v2/pages: {},
/wp/v2/pages/(?P<id>[\d]+): {},
/wp/v2/pages/(?P<parent>[\d]+)/revisions: {},
/wp/v2/pages/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/pages/(?P<id>[\d]+)/autosaves: {},
/wp/v2/pages/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},

Top ↑

Media Media

/wp/v2/media: {},
/wp/v2/media/(?P<id>[\d]+): {},
/wp/v2/media/(?P<id>[\d]+)/post-process: {},
/wp/v2/media/(?P<id>[\d]+)/edit: {},

Top ↑

/wp/v2/menu-items: {},
/wp/v2/menu-items/(?P<id>[\d]+): {},
/wp/v2/menu-items/(?P<id>[\d]+)/autosaves: {},
/wp/v2/menu-items/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},

Top ↑

Blocks Blocks

/wp/v2/blocks: {},
/wp/v2/blocks/(?P<id>[\d]+): {},
/wp/v2/blocks/(?P<parent>[\d]+)/revisions: {},
/wp/v2/blocks/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/blocks/(?P<id>[\d]+)/autosaves: {},
/wp/v2/blocks/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},

Top ↑

Templates Templates

/wp/v2/templates: {},
/wp/v2/templates/lookup: {},
/wp/v2/templates/(?P<id>([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w-]+): {},
/wp/v2/templates/(?P<parent>[\d]+)/revisions: {},
/wp/v2/templates/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/templates/(?P<id>[\d]+)/autosaves: {},
/wp/v2/templates/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},

Top ↑

Template Parts Template Parts

/wp/v2/template-parts: {},
/wp/v2/template-parts/lookup: {},
/wp/v2/template-parts/(?P<id>([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w-]+): {},
/wp/v2/template-parts/(?P<parent>[\d]+)/revisions: {},
/wp/v2/template-parts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/template-parts/(?P<id>[\d]+)/autosaves: {},
/wp/v2/template-parts/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},

Top ↑

/wp/v2/navigation: {},
/wp/v2/navigation/(?P<id>[\d]+): {},
/wp/v2/navigation/(?P<parent>[\d]+)/revisions: {},
/wp/v2/navigation/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/navigation/(?P<id>[\d]+)/autosaves: {},
/wp/v2/navigation/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},

Top ↑

Types Types

/wp/v2/types: {},
/wp/v2/types/(?P<type>[\w-]+): {},

Top ↑

Statuses Statuses

/wp/v2/statuses: {},
/wp/v2/statuses/(?P<status>[\w-]+): {},

Top ↑

Taxonomies Taxonomies

/wp/v2/taxonomies: {},
/wp/v2/taxonomies/(?P<taxonomy>[\w-]+): {},

Top ↑

Categories Categories

/wp/v2/categories: {},
/wp/v2/categories/(?P<id>[\d]+): {},

Top ↑

Tags Tags

/wp/v2/tags: {},
/wp/v2/tags/(?P<id>[\d]+): {},

Top ↑

/wp/v2/menus: {},
/wp/v2/menus/(?P<id>[\d]+): {},

Top ↑

Users Users

/wp/v2/users: {},
/wp/v2/users/(?P<id>[\d]+): {},
/wp/v2/users/me: {},
/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords: {},
/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords/introspect: {},
/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords/(?P<uuid>[\w\-]+): {},

Top ↑

Comments Comments

/wp/v2/comments: {},
/wp/v2/comments/(?P<id>[\d]+): {},

Top ↑

/wp/v2/search: {},

Top ↑

Block Renderer Block Renderer

/wp/v2/block-renderer/(?P<name>[a-z0-9-]+/[a-z0-9-]+): {},

Top ↑

Block Types Block Types

/wp/v2/block-types: {},
/wp/v2/block-types/(?P<namespace>[a-zA-Z0-9_-]+): {},
/wp/v2/block-types/(?P<namespace>[a-zA-Z0-9_-]+)/(?P<name>[a-zA-Z0-9_-]+): {},

Top ↑

Global Styles Global Styles

/wp/v2/global-styles/themes/(?P<stylesheet>[\/\s%\w\.\(\)\[\]\@_\-]+)/variations: {},
/wp/v2/global-styles/themes/(?P<stylesheet>[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?): {},
/wp/v2/global-styles/(?P<id>[\/\w-]+): {},

Top ↑

Settings Settings

/wp/v2/settings: {},

Top ↑

Themes Themes

/wp/v2/themes: {},
/wp/v2/themes/(?P<stylesheet>[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?): {},

Top ↑

Plugins Plugins

/wp/v2/plugins: {},
/wp/v2/plugins/(?P<plugin>[^.\/]+(?:\/[^.\/]+)?): {},

Top ↑

/wp/v2/sidebars: {},
/wp/v2/sidebars/(?P<id>[\w-]+): {},

Top ↑

Widget Types Widget Types

/wp/v2/widget-types: {},
/wp/v2/widget-types/(?P<id>[a-zA-Z0-9_-]+): {},
/wp/v2/widget-types/(?P<id>[a-zA-Z0-9_-]+)/encode: {},
/wp/v2/widget-types/(?P<id>[a-zA-Z0-9_-]+)/render: {},

Top ↑

Widgets Widgets

/wp/v2/widgets: {},
/wp/v2/widgets/(?P<id>[\w\-]+): {},

Top ↑

How to show the Rest API data? How to show the Rest API data?

There are different ways to access the Rest API data.

I’m showing you how to access it with the help of the JavaScript fetch() method.

fetch( 'https://maheshwaghmare.com/wp-json/wp/v2/pages/' )
.then( res => res.json() )
.then( allPages => {
     console.log( allPages );
})

The output you’ll see something as below:

WordPress Rest API Default Endpoints 5
Display all pages with Rest API

See the code pen for more details:
https://codepen.io/maheshwaghmare/pen/dyjYEjz

Top ↑

List of All Default Endpoints List of All Default Endpoints

/wp/v2/posts: {},
/wp/v2/posts/(?P<id>[\d]+): {},
/wp/v2/posts/(?P<parent>[\d]+)/revisions: {},
/wp/v2/posts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/posts/(?P<id>[\d]+)/autosaves: {},
/wp/v2/posts/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},
/wp/v2/pages: {},
/wp/v2/pages/(?P<id>[\d]+): {},
/wp/v2/pages/(?P<parent>[\d]+)/revisions: {},
/wp/v2/pages/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/pages/(?P<id>[\d]+)/autosaves: {},
/wp/v2/pages/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},
/wp/v2/media: {},
/wp/v2/media/(?P<id>[\d]+): {},
/wp/v2/media/(?P<id>[\d]+)/post-process: {},
/wp/v2/media/(?P<id>[\d]+)/edit: {},
/wp/v2/menu-items: {},
/wp/v2/menu-items/(?P<id>[\d]+): {},
/wp/v2/menu-items/(?P<id>[\d]+)/autosaves: {},
/wp/v2/menu-items/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},
/wp/v2/blocks: {},
/wp/v2/blocks/(?P<id>[\d]+): {},
/wp/v2/blocks/(?P<parent>[\d]+)/revisions: {},
/wp/v2/blocks/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/blocks/(?P<id>[\d]+)/autosaves: {},
/wp/v2/blocks/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},
/wp/v2/templates: {},
/wp/v2/templates/lookup: {},
/wp/v2/templates/(?P<id>([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w-]+): {},
/wp/v2/templates/(?P<parent>[\d]+)/revisions: {},
/wp/v2/templates/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/templates/(?P<id>[\d]+)/autosaves: {},
/wp/v2/templates/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},
/wp/v2/template-parts: {},
/wp/v2/template-parts/lookup: {},
/wp/v2/template-parts/(?P<id>([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w-]+): {},
/wp/v2/template-parts/(?P<parent>[\d]+)/revisions: {},
/wp/v2/template-parts/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/template-parts/(?P<id>[\d]+)/autosaves: {},
/wp/v2/template-parts/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},
/wp/v2/navigation: {},
/wp/v2/navigation/(?P<id>[\d]+): {},
/wp/v2/navigation/(?P<parent>[\d]+)/revisions: {},
/wp/v2/navigation/(?P<parent>[\d]+)/revisions/(?P<id>[\d]+): {},
/wp/v2/navigation/(?P<id>[\d]+)/autosaves: {},
/wp/v2/navigation/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},
/wp/v2/rank_math_schema: {},
/wp/v2/rank_math_schema/(?P<id>[\d]+): {},
/wp/v2/rank_math_schema/(?P<id>[\d]+)/autosaves: {},
/wp/v2/rank_math_schema/(?P<parent>[\d]+)/autosaves/(?P<id>[\d]+): {},
/wp/v2/types: {},
/wp/v2/types/(?P<type>[\w-]+): {},
/wp/v2/statuses: {},
/wp/v2/statuses/(?P<status>[\w-]+): {},
/wp/v2/taxonomies: {},
/wp/v2/taxonomies/(?P<taxonomy>[\w-]+): {},
/wp/v2/categories: {},
/wp/v2/categories/(?P<id>[\d]+): {},
/wp/v2/tags: {},
/wp/v2/tags/(?P<id>[\d]+): {},
/wp/v2/menus: {},
/wp/v2/menus/(?P<id>[\d]+): {},
/wp/v2/users: {},
/wp/v2/users/(?P<id>[\d]+): {},
/wp/v2/users/me: {},
/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords: {},
/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords/introspect: {},
/wp/v2/users/(?P<user_id>(?:[\d]+|me))/application-passwords/(?P<uuid>[\w\-]+): {},
/wp/v2/comments: {},
/wp/v2/comments/(?P<id>[\d]+): {},
/wp/v2/search: {},
/wp/v2/block-renderer/(?P<name>[a-z0-9-]+/[a-z0-9-]+): {},
/wp/v2/block-types: {},
/wp/v2/block-types/(?P<namespace>[a-zA-Z0-9_-]+): {},
/wp/v2/block-types/(?P<namespace>[a-zA-Z0-9_-]+)/(?P<name>[a-zA-Z0-9_-]+): {},
/wp/v2/global-styles/themes/(?P<stylesheet>[\/\s%\w\.\(\)\[\]\@_\-]+)/variations: {},
/wp/v2/global-styles/themes/(?P<stylesheet>[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?): {},
/wp/v2/global-styles/(?P<id>[\/\w-]+): {},
/wp/v2/settings: {},
/wp/v2/themes: {},
/wp/v2/themes/(?P<stylesheet>[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?): {},
/wp/v2/plugins: {},
/wp/v2/plugins/(?P<plugin>[^.\/]+(?:\/[^.\/]+)?): {},
/wp/v2/sidebars: {},
/wp/v2/sidebars/(?P<id>[\w-]+): {},
/wp/v2/widget-types: {},
/wp/v2/widget-types/(?P<id>[a-zA-Z0-9_-]+): {},
/wp/v2/widget-types/(?P<id>[a-zA-Z0-9_-]+)/encode: {},
/wp/v2/widget-types/(?P<id>[a-zA-Z0-9_-]+)/render: {},
/wp/v2/widgets: {},
/wp/v2/widgets/(?P<id>[\w\-]+): {},
/wp/v2/block-directory/search: {},
/wp/v2/pattern-directory/patterns: {},
/wp/v2/block-patterns/patterns: {},
/wp/v2/block-patterns/categories: {},
/wp/v2/menu-locations: {},
/wp/v2/menu-locations/(?P<location>[\w-]+): {},
/wp-site-health/v1: {},
/wp-site-health/v1/tests/background-updates: {},
/wp-site-health/v1/tests/loopback-requests: {},
/wp-site-health/v1/tests/https-status: {},
/wp-site-health/v1/tests/dotorg-communication: {},
/wp-site-health/v1/tests/authorization-header: {},
/wp-site-health/v1/directory-sizes: {},
/wp-site-health/v1/tests/page-cache: {},
/wp-block-editor/v1: {},
/wp-block-editor/v1/url-details: {},
/wp-block-editor/v1/export: {}

Top ↑

Frequently Asked Questions for Rest API Frequently Asked Questions for Rest API

Top ↑

What is a REST API endpoint in WordPress? What is a REST API endpoint in WordPress?

A REST API endpoint is a URL on a WordPress website that provides access to specific data or functionality via the REST API.

The WordPress REST API includes several default endpoints that allow developers to retrieve, create, update, and delete various types of WordPress content.

Top ↑

What are the default endpoints provided by the WordPress REST API? What are the default endpoints provided by the WordPress REST API?

The WordPress REST API includes several default endpoints, including /wp/v2/posts, /wp/v2/pages, /wp/v2/media, /wp/v2/users, /wp/v2/comments, and /wp/v2/settings.

These endpoints allow developers to access and manipulate various types of content on a WordPress site.

Top ↑

How can I use the WordPress REST API to retrieve data from my site? How can I use the WordPress REST API to retrieve data from my site?

You can use a tool like Postman or a programming language like JavaScript to make HTTP requests to the WordPress REST API and retrieve data from your site.

For example, you could use the /wp/v2/posts endpoint to retrieve a list of all the posts on your site, or the /wp/v2/media endpoint to retrieve a list of all the media items on your site.

Top ↑

Can I modify the default endpoints provided by the WordPress REST API? Can I modify the default endpoints provided by the WordPress REST API?

Yes, you can modify the default endpoints or create custom endpoints using the WordPress REST API.

You can use plugins like the REST API Custom Endpoints plugin or custom code to add new functionality to your site’s REST API.

Top ↑

Are there any security concerns I should be aware of when using the WordPress REST API? Are there any security concerns I should be aware of when using the WordPress REST API?

Yes, like any web API, the WordPress REST API can be vulnerable to attacks like SQL injection or cross-site scripting (XSS).

It’s important to make sure your site is running the latest version of WordPress and any plugins you’re using and to follow security best practices like validating user input and sanitizing data before it’s used in API requests.