Get the App
SLTechnology News&Howtos  ›  Servers  › 

What are the basic uses of WordPress REST API

Shulou Source: shulou.com Published: 2022-06-02 07:20:51 10月03日 Update

This article will explain in detail what the basic use of WordPress REST API is, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

The WordPress system opens REST API by default, that is, except for outputting content in HTML format

You can also output data such as articles / users / comments in JSON format.

The reason why JSON data format response is supported is due to a variety of intelligent terminal devices, such as mobile phones / tablets / televisions / routers / home appliances / toys, etc.

They all have to communicate with the cloud server, and the data needed by the terminal device does not necessarily have to be presented to the user after parsing the HTML through the browser.

Therefore, JSON is usually used for data communication, which is easy to write / read / parse.

If you have deployed WordPress, you can get the data in JSON format through the corresponding link:

Example of link format:

Article list / wp-json/wp/v2/posts

Page list / wp-json/wp/v2/pages

User list / wp-json/wp/v2/users

Replace the sample domain name with your own domain name, and if the page returns a 404 error, you need to set the redirection rule for the WEB proxy server (Nginx).

For a complete resource API link, please visit

Https://developer.wordpress.org/rest-api/reference/

Thus it can be seen that if the website wants to provide data interface services for other devices, it can be used directly without development costs.

If you don't expect your website to open REST API, you can disable this feature by installing the plug-in Disable REST API.

Plug-in address:

Https://wordpress.org/plugins/disable-json-api/

After the installation is enabled, other users do not have access to data except the administrator who has logged in.

To make JSON data easy to read in browsers, you can install related extensions:

Chrome:

Https://chrome.google.com/webstore/detail/json-viewer/aimiinbnnkboelefkjlenlgimcabobli?utm_source=chrome-ntp-icon on the basic use of WordPress REST API to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Data formats articles users content devices links services available through domain names plug-ins data communications more servers browsers knowledge examples articles terminals terminal devices Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Apple Xiaomi OPPO Reno Shulou Information