The WordPress REST API is finally coming to Core in 4.7 (December 2016). This talk is a brief introduction on the concept of REST and the WP REST API. Additionally it's a showcase of the exciting new things you'll be able to build on top of the WordPress REST API.
Talk held at WordCamp Geneva 2016: https://2016.geneva.wordcamp.org
Additional links to the slides: https://goo.gl/N4RQ6N
The WordPress REST API
A game changer for WordPress @ #wcgva
27.1% of The Web
Now available in a RESTful way.
Co-Founder & WordPress
What is A REST API?
Trust me it’s easier than it sounds.
REpresentational State Transfer
- Not any smarter yet? Well me neither ¯\_(ツ)_/¯
- It’s about resources & a little bit about verbs
- Uses HTTP methods in a specific way
REST: Let’s have a look
GET /friends => Returns a Collection of friends
GET /friends/joe => Returns a single friend
GET /friends/new => Could be a form to add a friend
The HTTP methods in REST
GET /friends => READ
POST /friends => CREATE
PUT /friends => UPDATE
DELETE /friends => DELETE
The famous CRUD
What about REST and WordPress?
GET /wp-json/wp/v2/posts => Collection of Posts
GET /wp-json/wp/v2/posts/ => Singular Post
GET /wp-json/ => Allows discovering the API
REST & WordPRESS
A little history lesson about the REST API.
How did we get here?
- Started as GSoC project in 2013 by Ryan McCue
- Infrastructure merged into WP 4.4 in 2015
- Content Endpoints merged into WP 4.7 in 2016
What’s in it?
There are a few more concepts in the WP REST API.
API Discovery via Response Header
- In the response header of a request:
API Discovery via Element
- Added to the of your HTML:
API Feature Discovery - Authentication
- The API will tell you how to authenticate
API Feature Discovery - Extensions
- The API will tell you what namespaces exist:
API Feature Discovery - Combined
Linking using HAL
- Uses HAL (Hypertext Application Language) to link related
Embed Related Resources
- Add ?_embed to any API Request URI
The Crazy Part is over,
let’s look at Examples
What Can You Build?
A few examples and ideas.
In The WP-Admin
In Your Theme
Standalone Web Apps/Sites
DATA Heavy Things
APPS APPS APPS
So are you ready for the WP
Already Built Something?
Some more Ideas
- Mobile Apps
- Other technologies can consume WP in a standardised way
- New Admin Interfaces
- Meta Boxes in the backend
- All the lame admin-ajax.php stuff
- Data heavy widgets
- Comments (cool once comment type is merged)
- Links & more: https://goo.gl/N4RQ6N
Thanks for Having Me!