WordPress.com REST API (not slides)

Integrate and Build Cool Applications with WordPress.com

http://developer.wordpress.com

What is WordPress.com?

Hosted blogging (WordPress) platform run by Automattic

WordPress.com: By numbers

28m sites
34m users
~800K posts daily
~1.5m comments daily

Lots of activity. Lots of data.

REST API: In a nutshell

The API gives developers access to posts and comments, as well as the ability to Follow, Like, or Reblog content for users. Other features from WordPress.com, like the daily handpicked content on Freshly Pressed, are also available through the API.

Brand-spankin’ new. XML-RPC’s younger, cooler brother.

The API works with any WordPress.com site

This includes sites like TechCrunch, GigaOM, see http://vip.wordpress.com/clients
Self-hosted WordPress sites… not yet (but soon via Jetpack

What data can you get?

  • User info
  • Site info
  • Posts on a site
  • Recent comments on a site
  • Comments on a post
  • Categories/Tags on a site
  • etc.

What actions can you perform?

Sites

  • Add/Edit/Delete posts
  • Add/Edit/Delete comments
  • Add/Edit/Delete categories
  • Add/Edit/Delete tags

Users

  • Like a post
  • Reblog a post
  • Follow a site

Authenticate via OAuth

http://developer.wordpress.com/docs/oauth2/

Endpoints

https://public-api.wordpress.com/oauth2/authorize
https://public-api.wordpress.com/oauth2/token

Endpoint: GET /sites/$site/

curl 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/'

Response

{
    "ID": 3584907,
    "name": "WordPress.com News",
    "description": "The latest news on WordPress.com and the WordPress community.",
    "URL": "http:\/\/en.blog.wordpress.com",
    "meta": {
        "links": {
            "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
            "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/help",
            "posts": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/",
            "comments": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/"
        }
    }
}

Endpoint: GET /site/$site/posts/

curl 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/?number=5'

Response

{
    "found": 621,
    "posts": [
        {
            "ID": 10473,
            "author": {
                "ID": 821549,
                "email": false,
                "name": "Christopher Finke",
                "URL": "http:\/\/cfinke.wordpress.com\/",
                "avatar_URL": "http:\/\/1.gravatar.com\/avatar\/357b3dde1d3e7e3267d23f605a078d62?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/cfinke"
            },
            "date": "2012-04-05T20:26:54+00:00",
            "modified": "2012-04-05T20:26:54+00:00",
            "title": "Custom CSS gets an upgrade",
            "URL": "http:\/\/en.blog.wordpress.com\/2012\/04\/05\/custom-css-gets-an-upgrade\/",
            "short_URL": "http:\/\/wp.me\/pf2B5-2IV",
<snip>

Endpoint: POST /sites/$site/posts/new

curl \
 -H 'authorization: Bearer YOUR_API_TOKEN' \
 --data-urlencode 'title=Hello World' \
 --data-urlencode 'content=Hello. I am a test post. I was created by the API' \
 --data-urlencode 'tags=tests' \
 --data-urlencode 'categories=API' \
 'https://public-api.wordpress.com/rest/v1/sites/30434183/posts/new/'

Endpoint: GET /freshly-pressed/

curl "https://public-api.wordpress.com/rest/v1/freshly-pressed/"

Developer Docs

Self-documenting!

http://developer.wordpress.com

Example App: Windows 8 app

Developer Console

https://developer.wordpress.com/docs/api/console/

Useful Links

Other APIs

Me

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: