Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

WP REST API - Adding Your Own Endpoint


Published on

Need to get to know the WordPress REST API? In this webinar, I cover the history of the REST API, which pieces of the API are in WordPress core, how the REST API is being used on real-world websites, and walk you through creating your very own endpoint on your WordPress site.

Published in: Technology

WP REST API - Adding Your Own Endpoint

  1. 1. WP REST API: Adding Your Own Endpoint Keanan Koppenhaver
  2. 2. Who Am I? • WordPress Developer at doejo for 3 years • Worked on WP sites large (XX,XXX posts) and small (5 simple pages) • Have recently been using just pieces of the WP REST API in production
  3. 3. Why are we here today? • Learn a little about the WP REST API • See some real world examples • Learn which pieces of the API are available in core • Learn how to create our own endpoint
  4. 4. Questions? Ask them anytime in the chat box below.
  5. 5. How did the REST API come about? • Proposed just after the WP Community Summit in 2012 • JSON over XML because of how it maps to programming language constructs • REST because the REST paradigm matches up well with the CMS structure • Merged* into Core on October 8, 2015 
 ( Source:
  6. 6. WP REST API in the wild • • WP Live Search • A “Digital Newspaper” with the WP API • WP Powered Mobile Apps • Any many more…
  7. 7. Demo:
  8. 8. Demo: ustwo on Github
  9. 9. Is the WP REST API part of WP Core? • Yes* • Infrastructure is in core • Prebuilt endpoints aren’t in core • We can create our own endpoints without an additional plugin • If we want all the endpoints we need a plugin
  10. 10. What does the plugin give us? • Endpoints on posts, pages, revisions, media, post types, post statuses, comments, taxonomies, categories, tags and users • Can be enabled for CPT or custom taxonomy • For a full list, see the reference
  11. 11. And without the plugin? • No endpoints available, but they can be created • Step 1: Create a function to return the necessary data • Step 2: Register with register_rest_route • Step 3: Flush Rewrite Rules • Step 4: Profit!
  12. 12. Step 1 Create a function to return the necessary data
  13. 13. Step 2 Register with register_rest_route
  14. 14. Step 3 Flush Rewrite Rules
  15. 15. Step 4 Profit!
  16. 16. Q&A Keanan Koppenhaver