The WordPress REST API: A game changer for WordPress

60d03aad905487166cd4430d1b725a41?s=47 Silvan Hagen
November 18, 2016

The WordPress REST API: A game changer for WordPress

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

60d03aad905487166cd4430d1b725a41?s=128

Silvan Hagen

November 18, 2016
Tweet

Transcript

  1. The WordPress REST API A game changer for WordPress @

    #wcgva
  2. 27.1% of The Web Now available in a RESTful way.

  3. Silvan Hagen Co-Founder & WordPress Developer @wearerequired @neverything

  4. What is A REST API? Trust me it’s easier than

    it sounds.
  5. 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
  6. 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
  7. The HTTP methods in REST GET /friends => READ POST

    /friends => CREATE PUT /friends => UPDATE DELETE /friends => DELETE The famous CRUD
  8. What about REST and WordPress? GET /wp-json/wp/v2/posts => Collection of

    Posts GET /wp-json/wp/v2/posts/<id> => Singular Post GET /wp-json/ => Allows discovering the API
  9. REST & WordPRESS A little history lesson about the REST

    API.
  10. 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
  11. What’s in it? There are a few more concepts in

    the WP REST API.
  12. API Discovery via Response Header - In the response header

    of a request: Link: <http://example.com/wp-json/>; rel="https://api.w.org/"
  13. API Discovery via <link> Element - Added to the <head>

    of your HTML:
  14. API Feature Discovery - Authentication - The API will tell

    you how to authenticate
  15. API Feature Discovery - Extensions - The API will tell

    you what namespaces exist:
  16. API Feature Discovery - Combined

  17. API Routes

  18. API Routes

  19. Linking using HAL - Uses HAL (Hypertext Application Language) to

    link related resources
  20. Embed Related Resources - Add ?_embed to any API Request

    URI
  21. Relax: The Crazy Part is over, let’s look at Examples

  22. What Can You Build? A few examples and ideas.

  23. In The WP-Admin https://wordpress.org/plugins/dashboard-directory-size/

  24. None
  25. In Your Theme

  26. Standalone Web Apps/Sites

  27. DATA Heavy Things

  28. APPS APPS APPS https://github.com/joehoyle/vienna

  29. So are you ready for the WP REST API?

  30. Already Built Something?

  31. 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 - WP_List_Tables - Customizer - Data heavy widgets - Comments (cool once comment type is merged) - Links & more: https://goo.gl/N4RQ6N
  32. Thanks for Having Me! Questions?