Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
WordPress
JSON REST API
Maine WordPress Meetup, Mar. 16, 2016
@andygagnon
Why Does WordPress Need an API?
Decoupling WordPress Content from Display
Templates, Plugins, Core
Jeff Bezos, Amazon
circa 2002
• All teams will henceforth expose their data and functionality through service interfaces.
...
1. Build Useful Software
2. Add API
3. Profit
What Does an API Do?
CRUD
90% of web development
REST = REpresentational State Transfer
REST 6 Constraints
• Client - Server
• Stateless
• Uniform Interface
• Caching
• Layered System
• Code on Demand
REST | HTTP API
Verbs
Nouns
Get/Post/Put/Delete
URI
Demo
http://rest.dev/simple.html
JSON
• JavaScript Object Notation
• Open Standard for data
• Key - Value pairs
• Better than XML
• http://json.org
• http:...
DEMO YouTube API
http://rest.dev/you-tube-api.html
Demo GitHub
http://api.github.com
WP JSON REST API
• Actions = Verbs (Get, Post, Put, Delete)
• Routes = URI
• Endpoints = Functions, Data returned
WP API
• http://v2.wp-api.org
• https://wordpress.org/plugins/rest-api/
• WP Version 4.4
• Pretty URLs, Save Permalinks
Demo WP API
http://jra.dev/wp-json/wp/v2
Demo PostMan
WP API Common Routes
• Posts
• Pages
• Custom Posts
• Categories
• Tags
• Taxonomies
• Users
• Comments
Demo ?filter[]=
https://codex.wordpress.org/Class_Reference/
WP_Query
Test Data
• https://codex.wordpress.org/Theme_Unit_Test
Demo Ajax Plugin
http://s2.dev/hello-world
Demo JS Theme
http://s2.dev/wp-admin
https://github.com/rachelbaker/wcus-demo
All New
WordPress
Static Sites
Hybrid Display
Single Page Web App
Native Mobile App
CMS x 2
Other Subjects
• Authorization
• OAuth1
• OAuth2, SSL required
• wp-login
• New Routes
• SEO
• Plugins e.g. Gravity Forms,...
WordPress Future Growth
• WP API can push WordPress beyond 25%
• The new API is fuel for new creativity
• New developers
WordPress Development
• WP API is a layer of abstraction over PHP/MySQL.
• Agnostic front end, now with JSON support.
• Ne...
Parting Words
from Matt Mullenwegg
GitHub
https://github.com/andygagnon/Maine-WordPress-Meetup-JSON-REST-API-demo
https://github.com/rachelbaker/wcus-demo
Thanks!
@andygagnon
http://andregagnon.com
Maine WordPress Meetup JSON REST API, 3/16/2016
Upcoming SlideShare
Loading in …5
×

Maine WordPress Meetup JSON REST API, 3/16/2016

1,137 views

Published on

Slides for Maine WordPress Meetup, JSON REST API.

Published in: Software
  • Be the first to comment

Maine WordPress Meetup JSON REST API, 3/16/2016

  1. 1. WordPress JSON REST API Maine WordPress Meetup, Mar. 16, 2016 @andygagnon
  2. 2. Why Does WordPress Need an API? Decoupling WordPress Content from Display
  3. 3. Templates, Plugins, Core
  4. 4. Jeff Bezos, Amazon circa 2002 • All teams will henceforth expose their data and functionality through service interfaces. • Teams must communicate with each other through these interfaces. • There will be no other form of interprocess communication allowed: no direct linking, no direct reads of another team’s data store, no shared-memory model, no back-doors whatsoever. The only communication allowed is via service interface calls over the network. • It doesn’t matter what technology they use. HTTP, Corba, Pubsub, custom protocols — doesn’t matter. • All service interfaces, without exception, must be designed from the ground up to be externalizable. That is to say, the team must plan and design to be able to expose the interface to developers in the outside world. No exceptions. • Anyone who doesn’t do this will be fired. • Thank you; have a nice day!
  5. 5. 1. Build Useful Software 2. Add API 3. Profit
  6. 6. What Does an API Do?
  7. 7. CRUD 90% of web development
  8. 8. REST = REpresentational State Transfer
  9. 9. REST 6 Constraints • Client - Server • Stateless • Uniform Interface • Caching • Layered System • Code on Demand
  10. 10. REST | HTTP API Verbs Nouns Get/Post/Put/Delete URI
  11. 11. Demo http://rest.dev/simple.html
  12. 12. JSON • JavaScript Object Notation • Open Standard for data • Key - Value pairs • Better than XML • http://json.org • http://jsonlint.com • http://jsoneditoronline.org • JSON View Extension
  13. 13. DEMO YouTube API http://rest.dev/you-tube-api.html
  14. 14. Demo GitHub http://api.github.com
  15. 15. WP JSON REST API • Actions = Verbs (Get, Post, Put, Delete) • Routes = URI • Endpoints = Functions, Data returned
  16. 16. WP API • http://v2.wp-api.org • https://wordpress.org/plugins/rest-api/ • WP Version 4.4 • Pretty URLs, Save Permalinks
  17. 17. Demo WP API http://jra.dev/wp-json/wp/v2
  18. 18. Demo PostMan
  19. 19. WP API Common Routes • Posts • Pages • Custom Posts • Categories • Tags • Taxonomies • Users • Comments
  20. 20. Demo ?filter[]= https://codex.wordpress.org/Class_Reference/ WP_Query
  21. 21. Test Data • https://codex.wordpress.org/Theme_Unit_Test
  22. 22. Demo Ajax Plugin http://s2.dev/hello-world
  23. 23. Demo JS Theme http://s2.dev/wp-admin https://github.com/rachelbaker/wcus-demo
  24. 24. All New WordPress
  25. 25. Static Sites
  26. 26. Hybrid Display
  27. 27. Single Page Web App
  28. 28. Native Mobile App
  29. 29. CMS x 2
  30. 30. Other Subjects • Authorization • OAuth1 • OAuth2, SSL required • wp-login • New Routes • SEO • Plugins e.g. Gravity Forms, WooCommerce
  31. 31. WordPress Future Growth • WP API can push WordPress beyond 25% • The new API is fuel for new creativity • New developers
  32. 32. WordPress Development • WP API is a layer of abstraction over PHP/MySQL. • Agnostic front end, now with JSON support. • New admin interfaces can also be created e.g. Calypso
  33. 33. Parting Words from Matt Mullenwegg
  34. 34. GitHub https://github.com/andygagnon/Maine-WordPress-Meetup-JSON-REST-API-demo https://github.com/rachelbaker/wcus-demo
  35. 35. Thanks! @andygagnon http://andregagnon.com

×