What's?

Carlos José (@carlosxjm)
Current Scenario
Mobile applications
Simple page applications
API REST
What is WP API REST?
"This plugin provides an easy to use REST API, available via HTTP. Grab your site’s data in simple JSON format, including users, posts, taxonomies and more. Retrieving or updating data is as simple as sending a HTTP request."
Plugin to core
- V1.0 deprecated
- V2.0 beta plugin (WP 4.4+)
- "The REST API is included in WP 4.7 (DEZ.2016)"
/wp-json


Basic usage
- /wp-json/wp/v2/posts
- /wp-json/wp/v2/posts/1
Basic usage
- GET
- POST
- PUT
- DELETE
Basic usage
- GET -> /wp-api/wp/posts
- POST ->/wp-api/wp/posts {data} --> Auth
- PUT -> /wp-api/wp/posts/1 {data} --> Auth
- DELETE -> /wp-api/wp/posts/1 --> Auth
Basic usage
- GET -> /wp-api/wp/posts --> WP_Query
- GET -> /wp-api/wp/posts/1 --> get_post()
- POST ->/wp-api/wp/posts {data} --> wp_insert_post()
- PUT -> /wp-api/wp/posts/1 {data} --> wp_update_post()
- DELETE -> /wp-api/wp/posts/1 --> wp_delete_post()
Basic usage
- In header: X-WP-Total, X-WP-TotalPages;
- Max 100 results;
Authentication
- Cookie
- OAuth
Cookie
Text

Cookie
Text

OAuth
How to customize?
CPT


Field
Schema
- Use JSON Schema;
- http://json-schema.org/
- https://spacetelescope.github.io/understanding-json-schema/index.html
Routes & Endpoints

Routes & Endpoints

Routes & Endpoints

Obrigado!
goo.gl/fYIJM8
deck
By Carlos José
deck
- 444