Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordPress JSON REST API

Rachel Baker
December 15, 2014

WordPress JSON REST API

#backboneconf

Rachel Baker

December 15, 2014
Tweet

More Decks by Rachel Baker

Other Decks in Programming

Transcript

  1. JSON REST API
    Current challenges
    and future impact

    View Slide

  2. Rachel Baker
    @rachelbaker
    Senior Web Engineer,
    Lead Developer,
    JSON REST API
    Project

    View Slide

  3. Democratize
    Publishing
    Mission:

    View Slide

  4. USA Today

    View Slide

  5. http://www.vogue.com/

    View Slide

  6. Five Thirty Eight

    View Slide

  7. View Slide

  8. USA Today

    View Slide

  9. Five Thirty Eight

    View Slide

  10. Five Thirty Eight

    View Slide

  11. http://open.nasa.gov/

    View Slide

  12. http://open.nasa.gov/

    View Slide

  13. http://open.nasa.gov/

    View Slide

  14. http://open.nasa.gov/

    View Slide

  15. Powers over
    60 million sites
    Stats:
    Forbes, 2011

    View Slide

  16. 23.3% of
    active sites
    Stats:
    W3 Techs, December 2014

    View Slide

  17. 4.0 downloaded
    29 million times
    Stats:
    WordPress.org, December 2014

    View Slide

  18. Multi-functional

    View Slide

  19. User-friendly

    View Slide

  20. Powered by a popular
    (and hated) language

    View Slide

  21. Backward compatible

    View Slide

  22. Why do we
    need an API?

    View Slide

  23. We made it to 11.

    View Slide

  24. Relevance for
    11 more years.

    View Slide

  25. 69.1% of the web
    doesn’t use a CMS.

    View Slide

  26. Build new, or iterate
    on existing features.

    View Slide

  27. View Slide

  28. Continue the mission.

    View Slide

  29. Challenges

    View Slide

  30. 60 million
    distributed APIs.

    View Slide

  31. Drink.

    View Slide

  32. 11 years late.

    View Slide

  33. Respect privacy
    expectations.

    View Slide

  34. Secure
    authentication.

    View Slide

  35. Different hosting
    environments.

    View Slide

  36. Different WordPress
    versions.

    View Slide

  37. Extensible
    with plugins.

    View Slide

  38. Cannot deploy
    a bug fix.

    View Slide

  39. Still has to be useful.

    View Slide

  40. Quality clients.

    View Slide

  41. Solutions

    View Slide

  42. Drink.

    View Slide

  43. Slow down
    we have a responsibility
    to not screw this up.

    View Slide

  44. Err on the side of
    authentication.

    View Slide

  45. Namespaced and
    versioned routes:
    wp/1.0/posts
    pluginname/2.0/events

    View Slide

  46. OAuth1.0a
    and possibly OAuth2 through
    WordPress.org.

    View Slide

  47. Educate our
    community
    and seek feedback from all
    communities.

    View Slide

  48. Official
    client libraries.

    View Slide

  49. Released version 1.0
    and encourage everyone to start
    using it now.

    View Slide

  50. Many are already using
    it in production
    New York Times
    Wired
    10up
    Bocoup
    …and more

    View Slide

  51. Future

    View Slide

  52. View Slide

  53. View Slide

  54. View Slide

  55. Backbone-based
    WordPress “themes”.

    View Slide

  56. Customized
    Dashboards.

    View Slide

  57. Customized
    Dashboards.

    View Slide

  58. Front-end (inline)
    content editing.

    View Slide

  59. Customized
    Dashboards.

    View Slide

  60. WordPress has been the
    gateway drug for
    tens of thousands
    of web developers.

    View Slide

  61. WordPress will be the
    gateway drug for
    tens of thousands
    of APIs.

    View Slide

  62. Check it out

    View Slide

  63. Read the
    Documentation
    wp-api.org

    View Slide

  64. Install the Plugin
    github.com/WP-API/WP-API

    View Slide

  65. Get the Schema
    http://example.com/wp-json/

    View Slide

  66. Build Stuff
    and Give Feedback
    Posts ✔ ✔ ✔ ✔
    Pages ✔ ✔ ✔ ✔
    Custom Post Types ✔ ✔ ✔ ✔
    Post Meta ✔ ✔ ✔ ✔
    Media ✔ ✔ ✔ ✔
    Comments ✔ ✔ ✔ ✔
    Taxonomies/Terms ✔ ✔ ✔ ✔
    Users ✔ ✔ ✔ ✔
    GET POST PUT DELETE

    View Slide

  67. Thank you
    github.com/WP-API

    View Slide

  68. STEP ONE

    READ THE DOCUMENTATION

    View Slide

  69. STEP TWO

    Install & Activate the Plugin

    View Slide

  70. STEP THREE

    GET the API ScHEMA
    http://example.com/wp-json/

    View Slide

  71. STEP THREE

    GET the API ScHEMA
    http://example.com/wp-json/

    View Slide

  72. STEP FOUR

    GET the POSTS COLLECTION
    http://example.com/wp-json/posts/

    View Slide

  73. http://example.com/wp-json/
    STEP FOUR

    GET the POSTS COLLECTION

    View Slide

  74. STEPs FIVE - Twenty-Two

    EXPLORE ALL THE POSSIBILITES
    Posts ✔ ✔ ✔ ✔
    Pages ✔ ✔ ✔ ✔
    Custom Post Types ✔ ✔ ✔ ✔
    Post Meta ✔ ✔ ✔ ✔
    Media ✔ ✔ ✔ ✔
    Comments ✔ ✔ ✔ ✔
    Taxonomies/Terms ✔ ✔ ✔ ✔
    Users ✔ ✔ ✔ ✔
    GET POST PUT DELETE

    View Slide

  75. STEP Twenty-THREE - ??

    Use the JSON REST API
    Use the JSON REST API plugin
    in/for a project.
    Give us feedback.

    View Slide