SlideShare a Scribd company logo
WP REST API:
Adding Your Own Endpoint
Keanan Koppenhaver
http://levelupwp.net
https://www.facebook.com/levelupwp
http://github.com/kkoppenhaver
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
core
• Learn how to create our own endpoint
Questions?
Ask them anytime in the chat box below.
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 

(https://core.trac.wordpress.org/changeset/34928)
Source: https://youtu.be/tV4IuS_KnvU?t=19m24s
WP REST API in the wild
• ustwo.com
• WP Live Search
• A “Digital Newspaper” with the WP API
• WP Powered Mobile Apps
• Any many more…
Demo: ustwo.com
Demo: ustwo on Github
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
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
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!
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!
Q&A
Keanan Koppenhaver
http://levelupwp.net
https://www.facebook.com/levelupwp
http://github.com/kkoppenhaver

More Related Content

PDF
Api Versioning
PDF
Contributing to open source
PDF
Look, Ma! No servers! Serverless application development with MongoDB Stitch
PDF
Android development at mercari 2015
PDF
PPTX
The development workflow of git github for beginners
PDF
Joomla! Framework + Issue Management + GitHub = Fun Code
PDF
API Publishers Series, Part 1: Introduction to Documentation
Api Versioning
Contributing to open source
Look, Ma! No servers! Serverless application development with MongoDB Stitch
Android development at mercari 2015
The development workflow of git github for beginners
Joomla! Framework + Issue Management + GitHub = Fun Code
API Publishers Series, Part 1: Introduction to Documentation

What's hot (19)

PDF
Versioning strategy for a complex internal API (Konstantin Yakushev)
PDF
Postman Webinar: Postman 101
PDF
Space Camp :: Introduction to API Security
PDF
Neotys PAC 2018 - Wilson Mar
ODP
Accelerate Quality with Postman - Basics
PDF
Londons Calling 2021
PDF
Build social apps for Facebook
PDF
Migrate PHP E-Commerce Site to Go
PDF
It Takes a Village to Make WordPress
PPTX
JavaScript Build System Battle Royale | PrDC 2017
PPTX
Story Testing Approach for Enterprise Applications using Selenium Framework
PDF
WordPress 4.1
PPTX
Austin Elixir: Slack Bots With Hedwig
PPTX
Super tools to boost productivity in React dev env!
PDF
POST/CON Keynote 2019
PPTX
How to Supercharge your PHP Web API
PDF
Postman: An Introduction for Testers
PPTX
DevNet 1056 WIT Spark API and Chat Bot Workshop
PDF
Design & Prototype an API
Versioning strategy for a complex internal API (Konstantin Yakushev)
Postman Webinar: Postman 101
Space Camp :: Introduction to API Security
Neotys PAC 2018 - Wilson Mar
Accelerate Quality with Postman - Basics
Londons Calling 2021
Build social apps for Facebook
Migrate PHP E-Commerce Site to Go
It Takes a Village to Make WordPress
JavaScript Build System Battle Royale | PrDC 2017
Story Testing Approach for Enterprise Applications using Selenium Framework
WordPress 4.1
Austin Elixir: Slack Bots With Hedwig
Super tools to boost productivity in React dev env!
POST/CON Keynote 2019
How to Supercharge your PHP Web API
Postman: An Introduction for Testers
DevNet 1056 WIT Spark API and Chat Bot Workshop
Design & Prototype an API
Ad

Viewers also liked (7)

PDF
RESTFul API Design and Documentation - an Introduction
PDF
API Design Essentials - Akana Platform Overview
PPTX
Building a REST API for Longevity
PDF
Deep-dive into Microservice Outer Architecture
PPTX
Beautiful REST+JSON APIs with Ion
PDF
Building Beautiful REST APIs with ASP.NET Core
PDF
RESTful API Design, Second Edition
RESTFul API Design and Documentation - an Introduction
API Design Essentials - Akana Platform Overview
Building a REST API for Longevity
Deep-dive into Microservice Outer Architecture
Beautiful REST+JSON APIs with Ion
Building Beautiful REST APIs with ASP.NET Core
RESTful API Design, Second Edition
Ad

Similar to WP REST API - Adding Your Own Endpoint (20)

PPTX
WordPress Rest API
PDF
2019 WordCamp Orange County - An Introduction to the WordPress REST API
PDF
WORDPRESS_REST_API_WORDPRESS_REST_API.pdf
PDF
WordCamp Wilmington 2017 WP-API Why?
PDF
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
PDF
Old WP REST API, New Tricks
PDF
JSON REST API for WordPress
PDF
Intro the WordPress REST API by tomhermans
PDF
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
PPTX
Word press rest api sudarshan shrestha
PPTX
An Introduction to the WP REST API
PDF
Maine WordPress Meetup JSON REST API, 3/16/2016
PPTX
The WordPress REST API as a Springboard for Website Greatness
PDF
Building a mini-theme with WordPress REST API
PDF
React with WordPress : Headless CMS
PDF
JSON REST API for WordPress
PPTX
The JSON REST API for WordPress
PDF
Introduction to WordPress REST API
PDF
Using the new WordPress REST API
PDF
Wp JSON API and You!
WordPress Rest API
2019 WordCamp Orange County - An Introduction to the WordPress REST API
WORDPRESS_REST_API_WORDPRESS_REST_API.pdf
WordCamp Wilmington 2017 WP-API Why?
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
Old WP REST API, New Tricks
JSON REST API for WordPress
Intro the WordPress REST API by tomhermans
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
Word press rest api sudarshan shrestha
An Introduction to the WP REST API
Maine WordPress Meetup JSON REST API, 3/16/2016
The WordPress REST API as a Springboard for Website Greatness
Building a mini-theme with WordPress REST API
React with WordPress : Headless CMS
JSON REST API for WordPress
The JSON REST API for WordPress
Introduction to WordPress REST API
Using the new WordPress REST API
Wp JSON API and You!

More from Keanan Koppenhaver (13)

PDF
The WP REST API as the Foundation of the Open Web 
PDF
Advanced WordPress Tooling
PDF
Voice is the New Keyboard - Voice Interfaces in 2018 and Beyond
PDF
Selling DevOps To Non-Technical Management
PDF
Debugging Tips and Tricks
PDF
Contributing to WordPress - #WCNYC
PDF
Contributing to open source as a non developer - #wclax
PDF
Building a WordPress plugin
PDF
WordPress Debugging Tips and Tricks
PDF
WordPress Debugging Tips and Tricks
PDF
Your WordPress Site Has Been Hacked: What Now?
PDF
Enterprise-Scale WordPress
PPTX
The WP REST API as the Foundation of the Open Web 
Advanced WordPress Tooling
Voice is the New Keyboard - Voice Interfaces in 2018 and Beyond
Selling DevOps To Non-Technical Management
Debugging Tips and Tricks
Contributing to WordPress - #WCNYC
Contributing to open source as a non developer - #wclax
Building a WordPress plugin
WordPress Debugging Tips and Tricks
WordPress Debugging Tips and Tricks
Your WordPress Site Has Been Hacked: What Now?
Enterprise-Scale WordPress

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Modernizing your data center with Dell and AMD
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPT
Teaching material agriculture food technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Approach and Philosophy of On baking technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
cuic standard and advanced reporting.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Understanding_Digital_Forensics_Presentation.pptx
Modernizing your data center with Dell and AMD
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Teaching material agriculture food technology
NewMind AI Weekly Chronicles - August'25 Week I
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...
Approach and Philosophy of On baking technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
cuic standard and advanced reporting.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Spectral efficient network and resource selection model in 5G networks

WP REST API - Adding Your Own Endpoint

  • 1. WP REST API: Adding Your Own Endpoint Keanan Koppenhaver http://levelupwp.net https://www.facebook.com/levelupwp http://github.com/kkoppenhaver
  • 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. 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. Questions? Ask them anytime in the chat box below.
  • 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 
 (https://core.trac.wordpress.org/changeset/34928) Source: https://youtu.be/tV4IuS_KnvU?t=19m24s
  • 6. WP REST API in the wild • ustwo.com • WP Live Search • A “Digital Newspaper” with the WP API • WP Powered Mobile Apps • Any many more…
  • 8. Demo: ustwo on Github
  • 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. 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. 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. Step 1 Create a function to return the necessary data
  • 13. Step 2 Register with register_rest_route