{"id":37601,"date":"2022-10-20T14:06:02","date_gmt":"2022-10-20T21:06:02","guid":{"rendered":"https:\/\/dhblog.dream.press\/blog\/?p=37601"},"modified":"2025-05-21T16:44:52","modified_gmt":"2025-05-21T23:44:52","slug":"tutorial-wp-rest-api","status":"publish","type":"post","link":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/","title":{"rendered":"An Introduction to the WordPress REST API"},"content":{"rendered":"\n<p>When the REST API was finally <a href=\"https:\/\/make.wordpress.org\/core\/2015\/10\/28\/rest-api-welcome-the-infrastructure-to-core\/\" target=\"_blank\" rel=\"noopener\">added to WordPress core<\/a>, it was the end of a long journey. Many had anticipated this change as the biggest step forward for WordPress in the platform\u2019s history. However, if you\u2019re not familiar with the REST API, you may be confused by what it all means.<\/p>\n\n\n\n<p>In short, the addition of <a href=\"http:\/\/v2.wp-api.org\/\" target=\"_blank\" rel=\"noopener\">the WordPress REST API<\/a> turned WordPress into a fully-featured application framework. This significantly increased its \u2018extensibility,\u2019 or its ability to be extended with new features and capabilities. Plus, it expanded the platform\u2019s potential for communicating with other sites and applications.<\/p>\n\n\n\n<h2 id=\"h-an-introduction-to-rest-apis\" class=\"wp-block-heading\"><b>An Introduction to REST APIs<\/b><\/h2>\n\n\n\n<p>Before we dig deeper into the WordPress REST API, it\u2019s important to get our terminology straight. This is a subject where we\u2019ll need to use a lot of acronyms, so let\u2019s clear those up first.<\/p>\n\n\n\n<p>First and foremost, you\u2019ll need to know what <a href=\"https:\/\/help.dreamhost.com\/hc\/en-us\/articles\/217560167\" target=\"_blank\" rel=\"noopener\">Application Programming Interfaces (APIs)<\/a> are. In the simplest terms, an API is a means by which one system enables other systems to connect to its data.<\/p>\n\n\n\n<p>For example, when a website adds a Facebook \u2018like\u2019 button to a page, it does this by hooking into Facebook\u2019s API. This lets the web page use the API to receive data (the code for the like button) and send data (the like request).<\/p>\n\n\n\n<p>So, what is a REST API specifically? <a href=\"https:\/\/en.wikipedia.org\/wiki\/Representational_state_transfer\" target=\"_blank\" rel=\"noopener\">Representational State Transfer (REST)<\/a> is a type of API specific to web services. It contains a standardized set of instructions and rules, making it easier for all \u2018RESTful\u2019 services to connect with each other.<\/p>\n\n\n\n<p>In short, REST APIs enable you to make requests to an external system. One example of this is Twitter. You can use its API to request a certain number of tweets from a specific user. The API will then return the tweets based on your request, which you can embed on your site using <a href=\"https:\/\/www.dreamhost.com\/blog\/learn-html\/\" target=\"_blank\" rel=\"noopener\">HTML<\/a> and <a href=\"https:\/\/www.dreamhost.com\/blog\/learn-css\/\" target=\"_blank\" rel=\"noopener\">CSS<\/a>.<\/p>\n\n\n\n<p>These requests are carried out using <a href=\"https:\/\/www.w3schools.com\/js\/js_json_intro.asp\" target=\"_blank\" rel=\"noopener\">JavaScript Object Notation (JSON)<\/a>. This is a language specifically designed for sending, receiving, and storing data.<\/p>\n\n\n\n<p>We\u2019re going to cover JSON later in this article, but we recommend taking the time to familiarize yourself with this language upfront. This will help prime you for using the WordPress REST API and understanding some of the concepts we\u2019ll be talking about.<\/p>\n\n\n\n<h2 id=\"h-what-the-wordpress-rest-api-is-and-why-it-s-important\" class=\"wp-block-heading\"><b>What the WordPress REST API Is (And Why It\u2019s Important)<\/b><\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1024\" height=\"332\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/wordpress-wp-rest-api-1024x332.jpg\" alt=\"WordPress Rest API\" class=\"wp-image-37606 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/wordpress-wp-rest-api-1024x332.jpg 1024w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/wordpress-wp-rest-api-300x97.jpg 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/wordpress-wp-rest-api-768x249.jpg 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/wordpress-wp-rest-api-1536x497.jpg 1536w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/10\/wordpress-wp-rest-api-600x194.jpg.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/10\/wordpress-wp-rest-api-750x243.jpg.webp 750w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/wordpress-wp-rest-api-100x32.jpg 100w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/10\/wordpress-wp-rest-api.jpg.webp 1544w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/332;\" \/><\/figure><\/div>\n\n\n<p>The <a href=\"http:\/\/v2.wp-api.org\/\" target=\"_blank\" rel=\"noopener\">WordPress REST API<\/a> functions in largely the same way as the examples we\u2019ve touched on already. Basically, the WordPress REST API gives you full access to WordPress features from any JSON-compatible framework.<\/p>\n\n\n\n<p>Similarly to how Twitter\u2019s API enables you to retrieve and send tweets, the WordPress REST API can be used to manage posts, users, categories, and much more from external platforms. It lets you use WordPress in a number of previously unprecedented ways.<\/p>\n\n\n\n<p>The REST API <a href=\"https:\/\/make.wordpress.org\/core\/2013\/06\/17\/json-rest-api\/\" target=\"_blank\" rel=\"noopener\">was announced<\/a> all the way back in 2013. It started life <a href=\"https:\/\/wordpress.org\/plugins\/rest-api\/\" target=\"_blank\" rel=\"noopener\">as a plugin<\/a>, meant to be incorporated into the WordPress core by Version 4.1. As so often happens, delays pushed the release back until it was finally implemented into the core with the release of <a href=\"https:\/\/wordpress.org\/news\/2016\/12\/vaughan\/\" target=\"_blank\" rel=\"noopener\">WordPress 4.7<\/a> three years later.<\/p>\n\n\n\n<p>This was a long but worthwhile wait for many people who saw the WordPress REST API as an important step forward for the platform. You might be wondering why this addition was such a big deal, especially since a lot of users probably didn\u2019t notice much difference. As it turns out, the inclusion of the REST API was a fundamental change to WordPress for many reasons.<\/p>\n\n\n\n<p>By implementing a REST API, WordPress took a step away from simply being a platform for creating websites. Instead, it\u2019s now become a full-fledged application framework. This means developers can use a WordPress site to create applications for mobile devices and the web or as an information repository.<\/p>\n\n\n\n<p>This shift also enabled WordPress to take a step away from its <a href=\"https:\/\/help.dreamhost.com\/hc\/en-us\/articles\/214202188\" target=\"_blank\" rel=\"noopener\">reliance on PHP<\/a>. By making WordPress compatible with any JSON-compatible language, the REST API greatly expanded the possibilities for developers, enabling them to use WordPress functionality with practically any framework.<\/p>\n\n\n\n<p>Finally, the REST API provides increased flexibility with the interfaces you can use to work with the platform. It made the admin interface completely optional since you can now interact with your WordPress site entirely through JSON commands.<\/p>\n\n\n\n<p>Now, let\u2019s look at how JSON and the REST API come together to make this possible.<\/p>\n\n\n\n<h2 id=\"h-how-the-rest-api-and-json-work-together\" class=\"wp-block-heading\"><b>How the REST API and JSON Work Together<\/b><\/h2>\n\n\n\n<p>By now, you should have a handle on the theoretical aspects of the WordPress REST API. So, let\u2019s look at the more practical side of the technology. The <a href=\"https:\/\/developer.wordpress.org\/rest-api\/\" target=\"_blank\" rel=\"noopener\">official handbook<\/a> describes using the REST API as follows:<\/p>\n\n\n\n<p>\u201cThe 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.\u201d<\/p>\n\n\n\n<p>The first word we need to focus on here is \u201cendpoints\u201d. The easiest way to think of an endpoint is as a piece of data or a function that can be called using <a href=\"http:\/\/www.json.org\/JSONRequest.html\" target=\"_blank\" rel=\"noopener\">a JSON request<\/a>. By default, WordPress provides a huge number of <a href=\"https:\/\/developer.wordpress.org\/rest-api\/extending-the-rest-api\/routes-and-endpoints\/#endpoints\" target=\"_blank\" rel=\"noopener\">standard endpoints<\/a> to use, but developers can also create <a href=\"https:\/\/developer.wordpress.org\/rest-api\/extending-the-rest-api\/adding-custom-endpoints\/\" target=\"_blank\" rel=\"noopener\">custom endpoints<\/a>.<\/p>\n\n\n\n<p>To reach an endpoint, you must <a href=\"https:\/\/developer.wordpress.org\/rest-api\/extending-the-rest-api\/routes-and-endpoints\/#routes\" target=\"_blank\" rel=\"noopener\">use a \u2018route,\u2019<\/a> which takes the form of a normal URL. You can even try this yourself right now.<\/p>\n\n\n\n<p>Go to your own WordPress site, and add <i>\/wp-json\/wp\/v2<\/i> to the end of its URL. If your site is <i>http:\/\/example.com<\/i>, you would enter <i>http:\/\/example.com\/wp-json\/wp\/v2<\/i>.<\/p>\n\n\n\n<p>When you load this route, you will reach the endpoint, which in this case, returns all content and meta-data for your site in a (messy) JSON format. By using different routes, you can access different endpoints to get specific types of information and perform various tasks.<\/p>\n\n\n\n<p>There are three primary <a href=\"https:\/\/developer.wordpress.org\/rest-api\/requests\/\" target=\"_blank\" rel=\"noopener\">JSON requests<\/a> you will use with the REST API, so let\u2019s also take a quick look at them now. They are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><b>GET.<\/b> This type of request is used for retrieving and listing data from the API. For example, you would use a GET request to return a list of users on your site or compile blog posts from a certain timeframe.<\/li>\n\n\n\n<li><b>POST.<\/b> This request is used for sending data to the API. It enables you to push new information to WordPress, such as adding new users and posts or updating existing data.<\/li>\n\n\n\n<li><b>DELETE.<\/b> As the name suggests, this request is used to delete data. This enables you to remove posts, pages, users, and more.<\/li>\n<\/ul>\n\n\n\n<p>GET and POST can sometimes be used with the same endpoint to achieve different results.<\/p>\n\n\n\n<p>For example, let\u2019s look at the endpoint <i>\/me\/settings\/<\/i>. If you were to perform a <a href=\"https:\/\/developer.wordpress.com\/docs\/api\/1.1\/get\/me\/settings\/\" target=\"_blank\" rel=\"noopener\">GET request<\/a> on this endpoint, you would receive a list of the current user\u2019s settings. However, by using a <a href=\"https:\/\/developer.wordpress.com\/docs\/api\/1.1\/post\/me\/settings\/\" target=\"_blank\" rel=\"noopener\">POST request<\/a> on the same endpoint, you would be able to update the settings instead.<\/p>\n\n\n\n<div class=\"article-newsletter article-newsletter--gradient\">\n\n\n<h2>Get Content Delivered Straight to Your Inbox<\/h2><p>Subscribe now to receive all the latest updates, delivered directly to your inbox.<\/p><form class=\"nwsl-form\" id=\"newsletter_block_\" novalidate><div class=\"messages\"><\/div><div class=\"form-group\"><label for=\"input_newsletter_block_\"><input type=\"email\"name=\"email\"id=\"input_newsletter_block_\"placeholder=\"Enter your email address\"novalidatedisabled=\"disabled\"\/><\/label><button type=\"submit\"class=\"btn btn--brand\"disabled=\"disabled\"><span>Sign Me Up!<\/span><svg width=\"21\" height=\"14\" viewBox=\"0 0 21 14\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n<path d=\"M13.8523 0.42524L12.9323 1.34521C12.7095 1.56801 12.7132 1.9304 12.9404 2.14865L16.7241 5.7823H0.5625C0.251859 5.7823 0 6.03416 0 6.3448V7.6573C0 7.96794 0.251859 8.2198 0.5625 8.2198H16.7241L12.9405 11.8535C12.7132 12.0717 12.7095 12.4341 12.9323 12.6569L13.8523 13.5769C14.072 13.7965 14.4281 13.7965 14.6478 13.5769L20.8259 7.39879C21.0456 7.17913 21.0456 6.82298 20.8259 6.60327L14.6477 0.42524C14.4281 0.205584 14.0719 0.205584 13.8523 0.42524Z\" fill=\"white\"\/>\n<\/svg>\n<\/button><\/div><\/form><\/div>\n\n\n<h2 id=\"h-getting-started-with-the-wordpress-rest-api\" class=\"wp-block-heading\"><b>Getting Started with the WordPress REST API<\/b><\/h2>\n\n\n\n<p>We\u2019re now going to put all of this theory into practice and show you some very basic examples of what you can do with the REST API. This is only a taste to help you become comfortable using the REST API to process requests to WordPress.<\/p>\n\n\n\n<p>For more examples, we recommend checking out the <a href=\"https:\/\/developer.wordpress.org\/rest-api\/reference\/\" target=\"_blank\" rel=\"noopener\">official reference library<\/a> and the <a href=\"https:\/\/developer.wordpress.com\/docs\/api\/\" target=\"_blank\" rel=\"noopener\">REST API Resources<\/a>.<\/p>\n\n\n\n<p>The following techniques will require you to use the command line to process JSON requests. This enables you to interact with your WordPress site by using a text-based interface and sending simple commands.<\/p>\n\n\n\n<p>If you don\u2019t have any experience using <a href=\"https:\/\/help.dreamhost.com\/hc\/en-us\/articles\/214202238\" target=\"_blank\" rel=\"noopener\">the command line<\/a>, we recommend taking some time to <a href=\"https:\/\/www.codecademy.com\/learn\/learn-the-command-line\" target=\"_blank\" rel=\"noopener\">learn the basics<\/a> first. You may also want to <a href=\"https:\/\/help.dreamhost.com\/hc\/en-us\/articles\/216041267\" target=\"_blank\" rel=\"noopener\">use SSH<\/a> to create the connection with your site.<\/p>\n\n\n\n<p>Finally, when you\u2019re ready, let\u2019s look at some examples of how you can use the WordPress REST API!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-return-posts-from-a-site\"><b>1. Return Posts from a Site<\/b><\/h3>\n\n\n\n<p>While you will obviously need the proper authorization to edit a website, it\u2019s possible to retrieve some information from almost any WordPress site. This is because the REST API is consistent across all WordPress installations.<\/p>\n\n\n\n<p>As we discussed, the main reason that APIs exist is to enable external applications to access some of your data. In this example, we can <a href=\"https:\/\/developer.wordpress.org\/rest-api\/reference\/posts\/#list-posts\" target=\"_blank\" rel=\"noopener\">retrieve a single post<\/a> from the official WordPress news blog:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/posts\/1<\/pre>\n\n\n\n<p>The ID has been set to <i>1<\/i>, meaning that this request will retrieve the very first post on the blog. It might be hard to see since the JSON is not very readable, but among the code, you can spot all the content and meta-data for the post:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1024\" height=\"292\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/retrieve-post-using-wordpress-rest-api-1024x292.jpg\" alt=\"retrieve a post from the WordPress blog using the WordPress Rest API\" class=\"wp-image-37605 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/retrieve-post-using-wordpress-rest-api-1024x292.jpg 1024w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/retrieve-post-using-wordpress-rest-api-300x86.jpg 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/retrieve-post-using-wordpress-rest-api-768x219.jpg 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/retrieve-post-using-wordpress-rest-api-1536x438.jpg 1536w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/10\/retrieve-post-using-wordpress-rest-api-600x171.jpg.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/10\/retrieve-post-using-wordpress-rest-api-750x214.jpg.webp 750w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/retrieve-post-using-wordpress-rest-api-100x29.jpg 100w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2022\/10\/retrieve-post-using-wordpress-rest-api.jpg.webp 1999w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/292;\" \/><\/figure><\/div>\n\n\n<p>You could then use this information in an application, for example, to display it using your own customized styling.<\/p>\n\n\n\n<p>If you want to return every post from the blog instead, all you have to do is remove the ID at the end. However, it\u2019s more likely that you\u2019ll want to return a select number of posts. The following request will return the latest three posts:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl https:\/\/wordpress.org\/news\/wp-json\/wp\/v2\/posts\/?per_page=3<\/pre>\n\n\n\n<p>You can try this out for yourself with other sites, and even your own blog.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-update-a-post\"><b>2. Update a Post<\/b><\/h3>\n\n\n\n<p>Now, let\u2019s try to make some changes to WordPress using the REST API. To do this, you will need to be logged in to the site you want to manage. For example, if you\u2019re using SSH, you will need to log in to your server.<\/p>\n\n\n\n<p>In this example, we\u2019ll <a href=\"https:\/\/developer.wordpress.org\/rest-api\/reference\/posts\/#update-a-post\" target=\"_blank\" rel=\"noopener\">update an existing post<\/a>. First, let\u2019s use a request to update the title of the post with the ID of <i>1<\/i>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -X POST http:\/\/example.com\/wp-json\/wp\/v2\/posts\/1 -d '{\"title\":\"A Brand New Title\"}'<\/pre>\n\n\n\n<p>This is pretty self-explanatory. The title argument shows that you\u2019re updating the post\u2019s title, which is followed by the text string containing the replacement.<\/p>\n\n\n\n<p>There are <a href=\"https:\/\/developer.wordpress.org\/rest-api\/reference\/posts\/#arguments\" target=\"_blank\" rel=\"noopener\">plenty of other arguments<\/a> you can use to make changes to a post. For instance, you can use a list to assign categories to the post, publish it, or change its contents entirely.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-delete-a-user\"><b>3. Delete a User<\/b><\/h3>\n\n\n\n<p>Finally, let\u2019s look at how you can remove data using the REST API. In this example, we\u2019ll <a href=\"https:\/\/developer.wordpress.org\/rest-api\/reference\/users\/#delete-a-user\" target=\"_blank\" rel=\"noopener\">remove a user<\/a> from the site. Naturally, you\u2019ll need to be logged in and authorized to manage users before you can use this function.<\/p>\n\n\n\n<p>Then, you can use the following request to delete the user with an ID of <i>101<\/i>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -X DELETE http:\/\/example.com\/wp-json\/wp\/v2\/users\/101<\/pre>\n\n\n\n<p>This will remove the specified user from the site. You can use the <a href=\"https:\/\/developer.wordpress.org\/rest-api\/reference\/users\/#arguments\" target=\"_blank\" rel=\"noopener\">additional parameters<\/a> to reassign the user\u2019s posts to another user based on their ID. Alternatively, you can force a permanent deletion instead of adding the user to the trash.<\/p>\n\n\n\n<p>Through these examples, you can start to see how the REST API enables you to manage the content on your site and connect to others. If you want to learn more, we recommend digging deeper into the <a href=\"https:\/\/developer.wordpress.org\/rest-api\/\" target=\"_blank\" rel=\"noopener\">REST API Handbook<\/a>.<\/p>\n\n\n\n<h2 id=\"h-explore-wordpress-development\" class=\"wp-block-heading\"><b>Explore WordPress Development<\/b><\/h2>\n\n\n\n<p>The <a href=\"http:\/\/v2.wp-api.org\/\" target=\"_blank\" rel=\"noopener\">WordPress REST API<\/a> was a huge step forward for the platform, away from its roots and into the future. Developers were excited from day one, but if you weren\u2019t familiar with REST APIs to begin with, you might have been confused about why.<\/p>\n\n\n\n<p>Although the REST API might seem overwhelming for beginners, you don\u2019t need to be an experienced developer to use some basic requests. For example, the API enables you to perform diverse tasks on your own site (or others), such as returning posts, updating posts, and deleting users.<\/p>\n\n\n\n<p>Are you looking for high-performance hosting for your WordPress site? At Dreamhost, our <a href=\"https:\/\/www.dreamhost.com\/wordpress\/\" target=\"_blank\" rel=\"noopener\">DreamPress managed plans<\/a> offer professional staging environments, automatic backups, in-built caching, and more. Check out our plans today!<\/p>\n\n\n\n\n\n<div\n\tclass=\"article-cta-shared article-cta-small\"\n>\n    <div class=\"tr-img-wrap-outer jsLoading\"><img decoding=\"async\" class=\"js-img-lazy \" src=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/lazy-loading-transparent.webp\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/article-small-ad-cta-placeholder.webp 1x, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/article-small-ad-cta-placeholder-x2.webp 2x\"  alt=\"Ad background image\" \/><\/div>\n\n\n\n\n  <div class=\"content-btm\">\n    <h2\n      class=\"h2--md\"\n    >\n      Do More with DreamPress\n    <\/h2>\n    <p\n      class=\"p--md\"\n    >\n      DreamPress&#8217; automatic updates, caching, and strong security defenses take WordPress management off your hands so you can focus on your website.\n    <\/p>\n\n            <a\n            href=\"https:\/\/www.dreamhost.com\/wordpress\/managed\/\"\n                        class=\"btn btn--white-outline btn--sm btn--round\"\n                                    target=\"_blank\"\n            rel=\"noopener noreferrer\"\n            >\n                            Check Out Plans                    <\/a>\n\n  <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>When the REST API was finally added to WordPress core, it was the end of a long journey. Many had anticipated this change as the biggest step forward for WordPress in the platform\u2019s history. However, if you\u2019re not familiar with the REST API, you may be confused by what it all means. In short, the [&hellip;]<\/p>\n","protected":false},"author":1062,"featured_media":37607,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_yoast_wpseo_metadesc":"REST APIs enable you to make requests between WordPress and external systems. In this article, you'll learn all about the WordPress REST API.","toc_headlines":"[[\"h-an-introduction-to-rest-apis\",\"<b>An Introduction to REST APIs<\/b>\"],[\"h-what-the-wordpress-rest-api-is-and-why-it-s-important\",\"<b>What the WordPress REST API Is (And Why It\u2019s Important)<\/b>\"],[\"h-how-the-rest-api-and-json-work-together\",\"<b>How the REST API and JSON Work Together<\/b>\"],[\"h-getting-started-with-the-wordpress-rest-api\",\"<b>Getting Started with the WordPress REST API<\/b>\"],[\"h-explore-wordpress-development\",\"<b>Explore WordPress Development<\/b>\"]]","hide_toc":false,"footnotes":""},"categories":[13129,550,696],"tags":[],"class_list":["post-37601","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developer-central","category-tutorials","category-wordpress"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.3 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>An Introduction to the WordPress REST API - DreamHost<\/title>\n<meta name=\"description\" content=\"REST APIs enable you to make requests between WordPress and external systems. In this article, you&#039;ll learn all about the WordPress REST API.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"An Introduction to the WordPress REST API\" \/>\n<meta property=\"og:description\" content=\"REST APIs enable you to make requests between WordPress and external systems. In this article, you&#039;ll learn all about the WordPress REST API.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/\" \/>\n<meta property=\"og:site_name\" content=\"DreamHost Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DreamHost\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-20T21:06:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-21T23:44:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/WordPress-REST-API-Social.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jason Cosper\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dreamhost\" \/>\n<meta name=\"twitter:site\" content=\"@dreamhost\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jason Cosper\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"An Introduction to the WordPress REST API - DreamHost","description":"REST APIs enable you to make requests between WordPress and external systems. In this article, you'll learn all about the WordPress REST API.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/","og_locale":"en_US","og_type":"article","og_title":"An Introduction to the WordPress REST API","og_description":"REST APIs enable you to make requests between WordPress and external systems. In this article, you'll learn all about the WordPress REST API.","og_url":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/","og_site_name":"DreamHost Blog","article_publisher":"https:\/\/www.facebook.com\/DreamHost\/","article_published_time":"2022-10-20T21:06:02+00:00","article_modified_time":"2025-05-21T23:44:52+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/WordPress-REST-API-Social.jpg","type":"image\/jpeg"}],"author":"Jason Cosper","twitter_card":"summary_large_image","twitter_creator":"@dreamhost","twitter_site":"@dreamhost","twitter_misc":{"Written by":"Jason Cosper","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/#article","isPartOf":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/"},"author":{"name":"Jason Cosper","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/person\/2273b8bf7336df78f6d99a89c17253c4"},"headline":"An Introduction to the WordPress REST API","datePublished":"2022-10-20T21:06:02+00:00","dateModified":"2025-05-21T23:44:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/"},"wordCount":1937,"publisher":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/#primaryimage"},"thumbnailUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/WordPress-REST-API-Feature.jpg","articleSection":["Developer Central","Tutorials","WordPress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/","url":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/","name":"An Introduction to the WordPress REST API - DreamHost","isPartOf":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/#primaryimage"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/#primaryimage"},"thumbnailUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/WordPress-REST-API-Feature.jpg","datePublished":"2022-10-20T21:06:02+00:00","dateModified":"2025-05-21T23:44:52+00:00","description":"REST APIs enable you to make requests between WordPress and external systems. In this article, you'll learn all about the WordPress REST API.","breadcrumb":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/#primaryimage","url":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/WordPress-REST-API-Feature.jpg","contentUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/10\/WordPress-REST-API-Feature.jpg","width":900,"height":598,"caption":"WordPress Rest API"},{"@type":"BreadcrumbList","@id":"https:\/\/www-dev.dreamhost.com\/blog\/tutorial-wp-rest-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dhblog.dream.press\/blog\/"},{"@type":"ListItem","position":2,"name":"An Introduction to the WordPress REST API"}]},{"@type":"WebSite","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#website","url":"https:\/\/www-dev.dreamhost.com\/blog\/","name":"DreamHost Blog","description":"","publisher":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www-dev.dreamhost.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization","name":"DreamHost","url":"https:\/\/www-dev.dreamhost.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/dhblog.dream.press\/blog\/wp-content\/uploads\/2019\/01\/dh_logo-blue-2.png","contentUrl":"https:\/\/dhblog.dream.press\/blog\/wp-content\/uploads\/2019\/01\/dh_logo-blue-2.png","width":1200,"height":168,"caption":"DreamHost"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DreamHost\/","https:\/\/x.com\/dreamhost","https:\/\/www.instagram.com\/dreamhost\/","https:\/\/www.linkedin.com\/company\/dreamhost\/","https:\/\/www.youtube.com\/user\/dreamhostusa"]},{"@type":"Person","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/person\/2273b8bf7336df78f6d99a89c17253c4","name":"Jason Cosper","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/02\/IMG_4807-scaled.jpeg","url":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/02\/IMG_4807-scaled.jpeg","contentUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/02\/IMG_4807-scaled.jpeg","caption":"Jason Cosper"},"description":"Jason is DreamHost\u2019s WordPress Product Advocate, based out of Bakersfield, CA. He is currently working on making our DreamPress product even better. In his free time, he likes to curl up on the couch and watch scary movies with his wife Sarah and three very small dogs. Follow him on Twitter.","url":"https:\/\/www-dev.dreamhost.com\/blog\/author\/jasoncosper\/"}]}},"lang":"en","translations":{"en":37601,"es":37643,"pl":52101,"de":53897,"ru":53939,"pt":53954,"uk":54144,"it":67909,"fr":69414,"nl":69443},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/37601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/users\/1062"}],"replies":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/comments?post=37601"}],"version-history":[{"count":7,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/37601\/revisions"}],"predecessor-version":[{"id":61507,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/37601\/revisions\/61507"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/media\/37607"}],"wp:attachment":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/media?parent=37601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/categories?post=37601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/tags?post=37601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}