KEMBAR78
Introduction to WordPress REST API | PDF
Introduction to
WP REST API
WPDay Pordenone, 13 Novembre 2015
simone d’amico
software engineer @ ideato
@dymissy
sd@ideato.it
WPDay Pordenone, 13 Novembre 2015
Introduction to WP REST API
PREAMBLE
Can WordPress be the
best choice for next
project?
OH, REALLY?
Buzzwords 2015
angular, react js, mobile app, …
very doge such wow
Introduction to WP REST API
CONCLUSION
WordPress could not be
the best solution
Introduction to WP REST API
WP REST API
Introduction to WP REST API
WP REST API
Introduction to WP REST API
WP REST API
Introduction to WP REST API
WP REST API
GET /posts
VERSION 1
GET /wp-json/wp/v2/posts
VERSION 2
- Infrastructure will be included from 4.4
- Endpoints available in the plugin
{
"name": "My WordPress Site",
"description": "Just another WordPress site",
"URL": "http://example.com",
"routes": {
"/": {
"supports": [
"HEAD",
"GET"
],
"meta": {
"self": "http://example.com/wp-json/"
}
}
...
Introduction to WP REST API
Why WP REST API
matters?
Y’ALL
Introduction to WP REST API
MOBILE APPS
mobile applications
SKY IS NOT THE
LIMIT
YOUR
IMAGINATION IS
Introduction to WP REST API
WP REST API REFERENCE
/wp-json/wp/v2 Routes and endpoints available
/wp-json/wp/v2/posts
Create, read, update and delete
posts
/wp-json/wp/v2/pages
Create, read, update and delete
pages
/wp-json/wp/v2/users
Create, read, update and delete
users
/wp-json/wp/v2/media
Create, read, update and delete
media items
/wp-json/wp/v2/taxonomies Read taxonomies and terms
GET /wp-json/wp/v2/posts List posts
GET /wp-json/wp/v2/posts/<id> Read the post <id>
POST /wp-json/wp/v2/posts Create a new post
PUT /wp-json/wp/v2/posts/<id> Update the post <id>
DELETE /wp-json/wp/v2/posts/<id> Delete the post <id>
Introduction to WP REST API
Extending WP REST API
Introduction to WP REST API
Extending
We are able to access to
posts, pages, etc…
What about custom post
types and custom fields?
Introduction to WP REST API
CUSTOM FIELDS
https://wordpress.org/plugins/acf-to-wp-api/
Introduction to WP REST API
CUSTOM POST TYPES
GET /wp-json/wp/v2/books List books
GET /wp-json/wp/v2/books/<id> Read the book <id>
POST /wp-json/wp/v2/books Create a new book
Introduction to WP REST API
CONCLUSIONS… FOR REAL
WP REST API allow
developers to build faster
and reactive applications
Introduction to WP REST API
THANKS
https://joind.in/15555
Introduction to WP REST API
QUESTIONS
?
Introduction to WP REST API
REFERENCE
https://developer.wordpress.com/docs/api/
https://make.wordpress.org/core/2015/10/28/rest-api-
welcome-the-infrastructure-to-core/
http://jacklenox.com/2015/03/30/building-themes-with-the-
wp-rest-api-wordcamp-london-march-2015/
https://github.com/kadamwhite/wordpress-rest-api
https://github.com/WP-API/client-js

Introduction to WordPress REST API