JSON REST APIs for WordPress
St. Louis WordPress Developer Meetup
What is JSON?
What is REST?
Representational State Transfer...
It relies on a stateless, client-server, cacheable communications protocol -- and in virtually all cases, the HTTP protocol is used.
REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms such as RPC or SOAP to connect between machines, simple HTTP is used to make calls between machines.
REST & CRUD
The four basic functions of persistent storage...
- RESTful applications use HTTP requests to:
- GET (read)
- POST (create)
- PUT (update)
- DELETE (delete)
Why not use XML?
- It's not the 90's anymore bro...
- Smaller message size
- More structural information in the document
- Can easily distinguish between:
- Number 1 and the string "1" as numbers, strings (and Booleans) are represented differently in JSON.
- Single items and collections of size one (using JSON arrays).
- Easier to represent a null value
XML vs JSON
Why does my WP site need an API?
- Expose your sites data to the world!
- Mobile Web
- Native Apps
JSON REST API is slated for WordPress 4.1 Release
What are my options?
- JSON REST API (WP API)
- Requires https://github.com/WP-API/OAuth1 for AUTH
- Jetpack REST API
- Thermal API
- ROLL YOUR OWN!