node package manager


Wordpress REST API module for nodejs


Layer to get resources from WordPress using the [](REST API).

Create a new instance of WPCONN. If you wanna a way to get the access token then can use WPOAuth npm module.

var WPCONN = require('wp-connect');
var wpconn = WPCONN();
var WPCONN = require('wp-connect');
var wpconn = new WPCONN('<your token>');
// get the user info, user){
  // user info related with the given access token 

Set site identifier

Get the site information

var WPCONN = require('wp-connect');
var wpconn = new WPCONN('<your token here>');
// get site info'');, site){
  // site data object 

Get the site posts'');{ number: 10 }, function(err, posts){
  // posts array 

Get post site data

// get post data, params, function(err, post){
  // post data object 

Get post site data by the given slug

// get post data'we-are-the-loosers', function(err, post){
  // post data object 

Add a new post

// post data 
var data = {
  "title": "A new post",
  "slug": "a-new-post",
  "content": "<div>The content of the new post</div>"
};, function(err, new_post){
  // object data of the new post already added 

Edit a post, { title: "new Title !!!" }, function(err, edit_post){
  // the title in edit_post has changed 

Into example/ folder download the npm dependencies:

$ npm install

... and then run the application

$ node index.js

Create data.json file into test/ folder to can run the tests. You can copy or rename the test/data_example.json file.

  "client_id": "<your client_id here>",
  "client_secret": "<your client_secret here>",
  "token": "<your token app here>",
  "public_site": "<a public blog here>",
  "private_site": "<a private blog here>",
  "private_site_id": "<the ID of the private blog>",
  "new_post_data": {
    "title": "New testing post",
    "content": "<div style=\"color: red;\">The content of the new testing post</div>"

... and then

$ make

MIT – Copyright 2014 Automattic