Home

Awesome

node-wordpress

A node.js JavaScript client for working with WordPress.

Support this project by donating on Gratipay.

Requires WordPress 3.4 or newer (uses the WordPress XML-RPC API).

Installation

npm install wordpress

Usage

var wordpress = require( "wordpress" );
var client = wordpress.createClient({
	url: "my-site.com",
	username: "admin",
	password: "secret"
});

client.getPosts(function( error, posts ) {
	console.log( "Found " + posts.length + " posts!" );
});

More usage examples can be found in the examples directory.

Full Site Synchronization

Looking for a way to manage your WordPress site without writing a bunch of code? Use Gilded WordPress to easily synchronize your entire site from a local directory.

API

Note: In order to provide a slightly nicer API, the XML-RPC field names have been mapped to CamelCase names. In some cases, the names are also altered because the original names are awkward. See the Fields section for a list of fields by type.

Client

wordpress.createClient( settings )

Creates a new client instance.

wordpress.Client

The constructor used for client connections. Useful for creating extensions.

Posts

client.getPost( id [, fields], callback )

Gets a post by ID.

client.getPosts( [filter] [, fields], callback )

Gets all posts, optionally filtered.

client.newPost( data, callback )

Creates a new post.

client.editPost( id, data, callback )

Edits an existing post.

client.deletePost( id, callback )

Deletes a post.

NOTE: Deleting a post may move it to the trash and then deleting a second time will actually delete.

client.getPostType( name, [, fields], callback )

Gets a post type by name.

client.getPostTypes( [filter], [, fields], callback )

Gets all post types.

Taxonomies

client.getTaxonomy( name, callback )

Gets a taxonomy by name.

client.getTaxonomies( callback )

Gets all taxonomies.

client.getTerm( taxonomy, id, callback )

Gets a taxonomy term by ID.

client.getTerms( taxonomy [, fields], callback )

Gets all taxonomy terms.

client.newTerm( data, callback )

Creates a new taxonomy term.

client.editTerm( id, data, callback )

Edits an existing taxonomy term.

client.deleteTerm( taxonomy, id, callback )

Deletes a taxonomy term.

Media

client.getMediaItem( id, callback )

Gets a piece of media by ID.

client.getMediaLibrary( [filter], callback )

client.uploadFile( data, callback )

Uploads a file to Wordpress.

Utilities

client.listMethods( callback )

Gets a list of all avaialble methods.

client.call( method [, args... ], callback )

Invokes a method.

client.authenticatedCall( method [, args... ], callback )

Invokes a method with the username and password provided by the client.

Fields

Files

Labels

Posts

Post Types

Post Type Capabilities

Taxonomies

Taxanomy Capabilities

Terms

Media

License

Copyright Scott González. Released under the terms of the MIT license.


Support this project by donating on Gratipay.