Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Latest commit

 

History

History
308 lines (211 loc) · 6.2 KB

site.md

File metadata and controls

308 lines (211 loc) · 6.2 KB

Site

Site handler class.

Create a Site instance from WPCOM

var wpcom = require('wpcom')('<your-token>');
var post = wpcom.site('<site-id>').post('<post-id>');
});

API

Site(id, WPCOM)

Create a new Site instance giving id and WPCOM instance.

var site = Site('<id>', WPCOM);

Site#get([query, ]fn)

Get site information

site.get(function(err, info){
  // `info` data object
});

Site#usersList([query, ]fn)

List the users of a site

site.usersList(function(err, list){
  // `list` data object
});

Site#postsList([query, ]fn)

Get site posts list

site.postsList(function(err, list){
  // `list` data object
});

Site#mediaList([query, ]fn)

Get site media list

site.mediaList(function(err, list){
  // `list` data object
});

Site - Post

Site#post(id)

Create a new Post instance. More info in Site post page.

var post = site.post('<post-id>');

Site#addPost(data, fn)

Add a new post to site. Return a Post instance.

var new_post = site.addPost({ title: 'It is my new post' }, function(err, post){
});

Site#deletePost(id, fn)

Delete a blog post

var del_post = site.deletePost('<post-id>', function(err, post){
});

Site - Media

Site#media(id)

Create a new Media instance.

var media = site.media('<media-id>');

Site#addMediaFile(data, fn)

Add a new media to site. Return a Media instance.

var new_media = site.addMedia({ urls: [] }, function(err, list){
});

Site - Stats

With a site instance, you can also access all of the stats endpoints

var site = Site('<id>', WPCOM);

Site#stats([query, ]fn)

Returns basic site stats.

site.stats( function(err, data){
	// data is site stats response
});

Site#statsClicks([query, ]fn)

Returns stats clicks data.

site.statsClicks( function(err, data){
	// data clicks response
});

Site#statsComments([query, ]fn)

Returns stats comments data.

site.statsComments( function(err, data){
	// data comments response
});

Site#statsCommentFollowers([query, ]fn)

Returns stats comment followers data.

site.statsComments( function(err, data){
	// data comment-follwers response
});

Site#statsCountryViews([query, ]fn)

Returns stats country views data.

site.statsCountryViews( function(err, data){
	// data country-views response
});

Site#statsFollowers([query, ]fn)

Returns followers data.

site.statsFollowers( function(err, data){
	// data followers response
});

Site#statsPostViews(postId,[query, ]fn)

Returns stats for a certain post.

site.statsPostViews( <postId>, function(err, data){
	// data post views response
});

Site#statsPublicize([query, ]fn)

Returns publicize data.

site.statsPublicize( function(err, data){
	// data publicize response
});

Site#statsReferrers([query, ]fn)

Returns referrers data.

site.statsReferrers( function(err, data){
	// data referrers response
});

Site#statsRefferersSpamNew(domain, fn)

Marks a certain domain referrer as spam.

site.statsRefferersSpamNew( <domain>, function(err, response){
	// response returned from procedure
});

Site#statsRefferersSpamDelete(domain, fn)

Removes a domain from referrer spam list.

site.statsRefferersSpamDelete( <domain>, function(err, response){
	// response returned from procedure
});

Site#statsSearchTerms([query, ]fn)

Returns search terms data.

site.statsSearchTerms( function(err, data){
	// data search terms response
});

Site#statsStreak([query, ]fn)

Returns streak data.

site.statsStreak( function(err, data){
	// data streak response
});

Site#statsSummary([query, ]fn)

Returns summary data.

site.statsSummary( function(err, data){
	// data summary response
});

Site#statsTags([query, ]fn)

Returns tags data.

site.statsTags( function(err, data){
	// data tags response
});

Site#statsTopAutors([query, ]fn)

Returns top authors data.

site.statsTopAuthors( function(err, data){
	// data top authors response
});

Site#statsVideo(videoId,[query, ]fn)

Returns stats about a particular VideoPress video.

site.statsVideo( <videoId>, function(err, data){
	// data about the video
});

Site#statsVideoPlays([query, ]fn)

Returns video plays data.

site.statsVideoPlays( function(err, data){
	// data video plays response
});

Site#statsVisits([query, ]fn)

Returns visits data.

site.statsVisits( function(err, data){
	// data visits response
});