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.
WP REST API:
Adding Your Own Endpoint
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
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
• Learn how to create our own endpoint
Ask them anytime in the chat box below.
How did the REST API
• Proposed just after the WP Community Summit in
• 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
WP REST API in the wild
• WP Live Search
• A “Digital Newspaper” with the WP API
• WP Powered Mobile Apps
• Any many more…
Is the WP REST API part of
• Infrastructure is in core
• Prebuilt endpoints aren’t in core
• We can create our own endpoints without an
• If we want all the endpoints we need a plugin
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
And without the plugin?
• No endpoints available, but they can be
• Step 1: Create a function to return the
• Step 2: Register with register_rest_route
• Step 3: Flush Rewrite Rules
• Step 4: Proﬁt!
Create a function to return the necessary data