-
Notifications
You must be signed in to change notification settings - Fork 7
/
pinterest.js
61 lines (52 loc) · 1.68 KB
/
pinterest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
var Manager = require('../manager.js');
var _ = require('lodash');
/**
* Quota Preset for Pinterest's API
*
* Quota rules based on: https://developers.pinterest.com/docs/api/overview/
* Pinterest's API docs: https://developers.pinterest.com/docs/getting-started/introduction/
*
* In a cluster environment a local Server can be used if all requests made on
* behalf of a particular user are only made by a single node.js instance.
*
* @param options
* @returns {Manager}
*/
module.exports = function (options) {
var manager = new Manager({
backoff: 'timeout'
});
function addRule(resource) {
manager.addRule({
name: resource,
limit: 1000,
window: 60*60*1000,
throttling: 'window-sliding',
queueing: 'fifo',
scope: 'userId',
resource: resource
});
}
// Each unique client ID and user ID pair is limited to approximately 1000 calls per endpoint per hour.
addRule('v1/boards');
addRule('v1/boards/<board_id>');
addRule('v1/boards/<board_id>/pins');
addRule('v1/me');
addRule('v1/me/boards');
addRule('v1/me/followers');
addRule('v1/me/following/boards');
addRule('v1/me/following/boards/<board_id>');
addRule('v1/me/following/interests');
addRule('v1/me/following/interests/<interest_id>');
addRule('v1/me/following/users');
addRule('v1/me/following/users/<user_id>');
addRule('v1/me/likes');
addRule('v1/me/pins');
addRule('v1/me/search/boards');
addRule('v1/me/search/pins');
addRule('v1/pins');
addRule('v1/pins/<pin_id>');
addRule('v1/users/<username_or_id>');
return manager;
};