Getting Started with

@coderkevin

https://github.com/coderkevin

Kevin Killingsworth

  • Introduction to the API
  • Define related terms and technology
  • Step through example code
  • Provide resources to get started!

Follow along: http://bit.do/wp-api-slides

Connect to your WordPress data

directly!

REST API v2

REST API v1

XML-RPC

A little history...

What is REST?

REpresentational

State

Transfer

The URL represents what you want to do

GET /wp/v2/posts
POST /wp/v2/comments/<id>

JSON

JavaScript Object Notation

Escher?

Everyone's doing it!

{
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 25,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    },
    {
      "type": "mobile",
      "number": "123 456-7890"
    }
  ],
  "children": [],
  "spouse": null
}

Platforms

Languages

+

"I believe quite strongly that JavaScript and API-driven interfaces are the future of not just WordPress but the web" -- Matt Mullenweg

Authentication

It's your content.

REST API (v2)

HTTP

JSON

Browser

JavaScript

External Web App

JSON

JavaScript?

PHP?
Python?

Ruby?

Java?

C/C++?

JSON

Mobile Device

Let's get to the code...

https://github.com/coderkevin

http://bit.do/api-example

Resources

Getting Started with the WordPress REST API

By Kevin Killingsworth

Getting Started with the WordPress REST API

Have you been hearing about the WordPress REST API? It’s an exciting way for plugins and standalone apps to utilize the power of WordPress and extend its functionality. This talk not only shows you the API and what is needed to make use of it, but will also bring you through example code you can use to bring the power of the REST API to your own plugins using simple jQuery AJAX calls.

  • 2,825