The WordPress REST API enables the CMS to communicate with other web properties, no matter what programming language they’re written in. According to the WordPress handbook:
The WordPress REST API provides API endpoints for WordPress data types that allow developers to interact with sites remotely by sending and receiving JSON (JavaScript Object Notation) objects.
However, a lot of sites don’t use this, and therefore in most cases, it is just unnecessary code. By default, every site includes a link in the header:
<link rel='https://api.w.org/' href='https://domain.com/wp-json/' />
There is also a header that is sent on each request:
function rest_output_link_header() { if ( headers_sent() ) { return; } $api_root = get_rest_url(); if ( empty( $api_root ) ) { return; }
There is also an API tag that gets added to the Really Simple Discovery (RSD) endpoint.
<api name="WP-API" blogID="1" preferred="false" apiLink="<?php echo esc_url( $api_root ); ?>" />
Remove WordPress REST API links
Follow the steps below to remove REST API links.
Step 1
Click into the Perfmatters plugin settings.
Step 2
Make sure you’re on the “General” submenu.
Step 3
Scroll down and toggle on “Remove REST API Links.”
Step 4
Scroll down and click “Save Changes.”
The above only removes the front-end code. Check out our article on how to completely disable the WordPress REST API.