1 |
|
2 | # Site
|
3 |
|
4 | `Site` handler class.
|
5 |
|
6 | ### Create a `Site` instance from WPCOM
|
7 |
|
8 | ```js
|
9 | var wpcom = require('wpcom')('<your-token>');
|
10 | var post = wpcom.site('<site-id>').post('<post-id>');
|
11 | });
|
12 | ```
|
13 |
|
14 | ## API
|
15 |
|
16 | ### Site(id, WPCOM)
|
17 |
|
18 | Create a new `Site` instance giving `id` and `WPCOM` instance.
|
19 |
|
20 | ```js
|
21 | var site = Site('<id>', WPCOM);
|
22 | ```
|
23 |
|
24 | ### Site#get([query, ]fn)
|
25 |
|
26 | Get site information
|
27 |
|
28 | ```js
|
29 | site.get(function(err, info){
|
30 | // `info` data object
|
31 | });
|
32 | ```
|
33 |
|
34 | ### Site#usersList([query, ]fn)
|
35 |
|
36 | List the users of a site
|
37 |
|
38 | ```js
|
39 | site.usersList(function(err, list){
|
40 | // `list` data object
|
41 | });
|
42 | ```
|
43 |
|
44 | ### Site#postsList([query, ]fn)
|
45 |
|
46 | Get site posts list
|
47 |
|
48 | ```js
|
49 | site.postsList(function(err, list){
|
50 | // `list` data object
|
51 | });
|
52 | ```
|
53 |
|
54 | ### Site#mediaList([query, ]fn)
|
55 |
|
56 | Get site media list
|
57 |
|
58 | ```js
|
59 | site.mediaList(function(err, list){
|
60 | // `list` data object
|
61 | });
|
62 | ```
|
63 |
|
64 | ## Site - Post
|
65 |
|
66 | ### Site#post(id)
|
67 |
|
68 | Create a new `Post` instance.
|
69 | More info in [Site post page](./post.md).
|
70 |
|
71 | ```js
|
72 | var post = site.post('<post-id>');
|
73 | ```
|
74 |
|
75 | ### Site#addPost(data, fn)
|
76 |
|
77 | Add a new post to site. Return a `Post` instance.
|
78 |
|
79 | ```js
|
80 | var new_post = site.addPost({ title: 'It is my new post' }, function(err, post){
|
81 | });
|
82 | ```
|
83 |
|
84 | ### Site#deletePost(id, fn)
|
85 |
|
86 | Delete a blog post
|
87 |
|
88 | ```js
|
89 | var del_post = site.deletePost('<post-id>', function(err, post){
|
90 | });
|
91 | ```
|
92 |
|
93 | ## Site - Media
|
94 |
|
95 | ### Site#media(id)
|
96 |
|
97 | Create a new `Media` instance.
|
98 |
|
99 | ```js
|
100 | var media = site.media('<media-id>');
|
101 | ```
|
102 |
|
103 | ### Site#addMediaFile(data, fn)
|
104 |
|
105 | Add a new media to site. Return a `Media` instance.
|
106 |
|
107 | ```js
|
108 | var new_media = site.addMedia({ urls: [] }, function(err, list){
|
109 | });
|
110 | ```
|
111 |
|
112 | ## Site - Stats
|
113 |
|
114 | With a site instance, you can also access all of the [stats endpoints](https://developer.wordpress.com/docs/api/#stats)
|
115 |
|
116 | ```js
|
117 | var site = Site('<id>', WPCOM);
|
118 | ```
|
119 |
|
120 | ### Site#stats([query, ]fn)
|
121 |
|
122 | Returns basic site [stats](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/).
|
123 |
|
124 | ```js
|
125 | site.stats( function(err, data){
|
126 | // data is site stats response
|
127 | });
|
128 | ```
|
129 |
|
130 | ### Site#statsClicks([query, ]fn)
|
131 |
|
132 | Returns stats [clicks](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/clicks/) data.
|
133 |
|
134 | ```js
|
135 | site.statsClicks( function(err, data){
|
136 | // data clicks response
|
137 | });
|
138 | ```
|
139 |
|
140 | ### Site#statsComments([query, ]fn)
|
141 |
|
142 | Returns stats [comments](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/comments/) data.
|
143 |
|
144 | ```js
|
145 | site.statsComments( function(err, data){
|
146 | // data comments response
|
147 | });
|
148 | ```
|
149 |
|
150 | ### Site#statsCommentFollowers([query, ]fn)
|
151 |
|
152 | Returns stats [comment followers](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/comment-followers/) data.
|
153 |
|
154 | ```js
|
155 | site.statsComments( function(err, data){
|
156 | // data comment-follwers response
|
157 | });
|
158 | ```
|
159 |
|
160 | ### Site#statsCountryViews([query, ]fn)
|
161 |
|
162 | Returns stats [country views](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/country-views/) data.
|
163 |
|
164 | ```js
|
165 | site.statsCountryViews( function(err, data){
|
166 | // data country-views response
|
167 | });
|
168 | ```
|
169 |
|
170 | ### Site#statsFollowers([query, ]fn)
|
171 |
|
172 | Returns [followers](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/followers/) data.
|
173 |
|
174 | ```js
|
175 | site.statsFollowers( function(err, data){
|
176 | // data followers response
|
177 | });
|
178 | ```
|
179 |
|
180 | ### Site#statsPostViews(postId,[query, ]fn)
|
181 |
|
182 | Returns stats for a certain [post](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/post/%24post_id/).
|
183 |
|
184 | ```js
|
185 | site.statsPostViews( <postId>, function(err, data){
|
186 | // data post views response
|
187 | });
|
188 | ```
|
189 |
|
190 | ### Site#statsPublicize([query, ]fn)
|
191 |
|
192 | Returns [publicize](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/publicize/) data.
|
193 |
|
194 | ```js
|
195 | site.statsPublicize( function(err, data){
|
196 | // data publicize response
|
197 | });
|
198 | ```
|
199 |
|
200 | ### Site#statsReferrers([query, ]fn)
|
201 |
|
202 | Returns [referrers](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/referrers/) data.
|
203 |
|
204 | ```js
|
205 | site.statsReferrers( function(err, data){
|
206 | // data referrers response
|
207 | });
|
208 | ```
|
209 |
|
210 | ### Site#statsRefferersSpamNew(domain, fn)
|
211 |
|
212 | Marks a certain domain referrer as [spam](https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/stats/referrers/spam/new/).
|
213 |
|
214 | ```js
|
215 | site.statsRefferersSpamNew( <domain>, function(err, response){
|
216 | // response returned from procedure
|
217 | });
|
218 | ```
|
219 |
|
220 | ### Site#statsRefferersSpamDelete(domain, fn)
|
221 |
|
222 | Removes a domain from referrer [spam](https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/stats/referrers/spam/delete/) list.
|
223 |
|
224 | ```js
|
225 | site.statsRefferersSpamDelete( <domain>, function(err, response){
|
226 | // response returned from procedure
|
227 | });
|
228 | ```
|
229 |
|
230 | ### Site#statsSearchTerms([query, ]fn)
|
231 |
|
232 | Returns [search terms](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/search-terms/) data.
|
233 |
|
234 | ```js
|
235 | site.statsSearchTerms( function(err, data){
|
236 | // data search terms response
|
237 | });
|
238 | ```
|
239 |
|
240 | ### Site#statsStreak([query, ]fn)
|
241 |
|
242 | Returns [streak](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/streak/) data.
|
243 |
|
244 | ```js
|
245 | site.statsStreak( function(err, data){
|
246 | // data streak response
|
247 | });
|
248 | ```
|
249 |
|
250 | ### Site#statsSummary([query, ]fn)
|
251 |
|
252 | Returns [summary](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/summary/) data.
|
253 |
|
254 | ```js
|
255 | site.statsSummary( function(err, data){
|
256 | // data summary response
|
257 | });
|
258 | ```
|
259 |
|
260 | ### Site#statsTags([query, ]fn)
|
261 |
|
262 | Returns [tags](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/tags/) data.
|
263 |
|
264 | ```js
|
265 | site.statsTags( function(err, data){
|
266 | // data tags response
|
267 | });
|
268 | ```
|
269 |
|
270 | ### Site#statsTopAutors([query, ]fn)
|
271 |
|
272 | Returns [top authors](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/top-authors/) data.
|
273 |
|
274 | ```js
|
275 | site.statsTopAuthors( function(err, data){
|
276 | // data top authors response
|
277 | });
|
278 | ```
|
279 |
|
280 | ### Site#statsVideo(videoId,[query, ]fn)
|
281 |
|
282 | Returns stats about a particular VideoPress [video](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/video/%24post_id/).
|
283 |
|
284 | ```js
|
285 | site.statsVideo( <videoId>, function(err, data){
|
286 | // data about the video
|
287 | });
|
288 | ```
|
289 |
|
290 | ### Site#statsVideoPlays([query, ]fn)
|
291 |
|
292 | Returns [video plays](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/video-plays/) data.
|
293 |
|
294 | ```js
|
295 | site.statsVideoPlays( function(err, data){
|
296 | // data video plays response
|
297 | });
|
298 | ```
|
299 |
|
300 | ### Site#statsVisits([query, ]fn)
|
301 |
|
302 | Returns [visits](https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/stats/visits/) data.
|
303 |
|
304 | ```js
|
305 | site.statsVisits( function(err, data){
|
306 | // data visits response
|
307 | });
|
308 | ``` |
\ | No newline at end of file |