Working On: Node and WordPress

Recently, I was working in node (shocking for a traditionally python dev!) and I do like it very much 3 weeks later. The ecosystem is well developed and excellently thought out. I felt right at home especially with the awesome npm package management tool (which is very much pip-ish). Alongside my recent node work, I am customizing WordPress. One of my current projects involves interfacing both node and WordPress. I needed a node WordPress(.org) xml-rpc client to continue developing the project. Unfortunately, the current WordPress package in npm seems to be dead on GitHub (no change in 11 months) and is missing half the API. Thus, I spent a couple of hours to write node-wporg, a complete node WordPress(.org) client. Node-wporg will let you query any part of the WordPress XML-RPC API with ease and it covers the entire API and performs simple validation. NOTE: Some APIs may not be available depending on your WordPress version installation. You will have to manually enable the XML-RPC API if you are running an older version of WordPress.

node-wporg is quite easy to install:

npm install wporg

The following is example usage.

var wp = require('wporg');

var client = wp.createClient({
    username: "username",
    password: "password",
    url: "http://example.com/xmlrpc.php"
});

client.getUsersBlogs(function(err, data){
    if(err){
        console.log(err);
    }
    else {
        console.log(data);
        // Do something.
    }
});

Take a look, send a pull request if you find a bug. I will be using node-wporg very frequently, so expect bug fixes to show up quickly. You can also generate docs by running grunt.

Leave a Reply

Your email address will not be published.