Site
handler class.
var wpcom = require('wpcom')('<your-token>');
var post = wpcom.site('<site-id>').post('<post-id>');
});
Create a new Site
instance giving id
and WPCOM
instance.
var site = Site('<id>', WPCOM);
Get site information
site.get(function(err, info){
// `info` data object
});
List the users of a site
site.usersList(function(err, list){
// `list` data object
});
Get site posts list
site.postsList(function(err, list){
// `list` data object
});
Get site media list
site.mediaList(function(err, list){
// `list` data object
});
Create a new Post
instance.
More info in Site post page.
var post = site.post('<post-id>');
Add a new post to site. Return a Post
instance.
var new_post = site.addPost({ title: 'It is my new post' }, function(err, post){
});
Delete a blog post
var del_post = site.deletePost('<post-id>', function(err, post){
});
Create a new Media
instance.
var media = site.media('<media-id>');
Add a new media to site. Return a Media
instance.
var new_media = site.addMedia({ urls: [] }, function(err, list){
});
With a site instance, you can also access all of the stats endpoints
var site = Site('<id>', WPCOM);
Returns basic site stats.
site.stats( function(err, data){
// data is site stats response
});
Returns stats clicks data.
site.statsClicks( function(err, data){
// data clicks response
});
Returns stats comments data.
site.statsComments( function(err, data){
// data comments response
});
Returns stats comment followers data.
site.statsComments( function(err, data){
// data comment-follwers response
});
Returns stats country views data.
site.statsCountryViews( function(err, data){
// data country-views response
});
Returns followers data.
site.statsFollowers( function(err, data){
// data followers response
});
Returns stats for a certain post.
site.statsPostViews( <postId>, function(err, data){
// data post views response
});
Returns publicize data.
site.statsPublicize( function(err, data){
// data publicize response
});
Returns referrers data.
site.statsReferrers( function(err, data){
// data referrers response
});
Marks a certain domain referrer as spam.
site.statsRefferersSpamNew( <domain>, function(err, response){
// response returned from procedure
});
Removes a domain from referrer spam list.
site.statsRefferersSpamDelete( <domain>, function(err, response){
// response returned from procedure
});
Returns search terms data.
site.statsSearchTerms( function(err, data){
// data search terms response
});
Returns streak data.
site.statsStreak( function(err, data){
// data streak response
});
Returns summary data.
site.statsSummary( function(err, data){
// data summary response
});
Returns tags data.
site.statsTags( function(err, data){
// data tags response
});
Returns top authors data.
site.statsTopAuthors( function(err, data){
// data top authors response
});
Returns stats about a particular VideoPress video.
site.statsVideo( <videoId>, function(err, data){
// data about the video
});
Returns video plays data.
site.statsVideoPlays( function(err, data){
// data video plays response
});
Returns visits data.
site.statsVisits( function(err, data){
// data visits response
});