What is JSON?
If you go to your WordPress Site and add /wp-json to the end of the URL, you will most likely see an entire page of characters display in the browser. This data format is called JSON. JSON, or JavaScript Object Notation, is a lightweight format for storing and transporting data, often used when data is sent from a the server behind the website to a web page itself. It’s easy to read and write for humans, and simple to parse and generate for machines, making it a popular choice in web development.
The WordPress REST API
JSON is the data format used to implement the REST API for WordPress. The WordPress REST API is a tool that allows developers to interact with a WordPress site from external applications or services using a standardized format. This API enables the retrieval and manipulation of site data, such as posts, pages, and users, through web-friendly commands, facilitating the integration of WordPress content with other platforms and technologies. We will demystify some of the content of the /wp-json page for you here.
Getting into the details with JSON
The content of this page is a JSON string. JSON makes it easy for other programs to access and process the data. You can see the content of the JSON better if you format it in a way that organizes the information better, such as Postman.
On the top of the page you see some basic information about your site, followed by “namespaces” and “routes”. Namespaces are different methods or services provided by your WordPress Rest API. Routes are different URLs you can visit to drill down on the information regarding your site.
Let’s look at a couple of specific URLs. If you add /wp-json/wp/v2/types to your site’s URL you see the different types of information from your site available in json format. One of the options is /wp-json/wp/v2/posts which shows information about the content of all the posts on your site.
What is the purpose of wp-json?
Other website or applications can connect to your site using the Rest API interface. Some of the content requires the Rest API user to log in, other is available to anyone.
The content can also be used by search engines and web crawlers to index your pages, posts and products.
What can I do with the WordPress REST API?
The WordPress REST API is used for lots of interesting applications, such as enabling real-time content delivery to mobile apps and creating responsive corporate websites with headless CMS (a content management system that provides backend storage and management of content without a built-in front-end display layer) setups using JavaScript frameworks. It also facilitates seamless integration with ERPs or other e-commerce platforms for data synchronization, automates social media posting for new blog content, and supports event management through external applications for real-time updates and registrations. In some cases you might see information posted in the JSON format that you did not want to have displayed to the public and available for web crawlers. Many plugins post information from your site to wp-json without your knowledge so it’s good to check and see what is there.
Have you found some information in the wp-json that you would like to block? Do you have an application you would like to connect to your website so that it can use that data?
Send us a note and we will assist you with any WordPress API needs.