diff --git a/routes/api.js b/routes/api.js index a12e6b38..758b5224 100644 --- a/routes/api.js +++ b/routes/api.js @@ -315,6 +315,39 @@ router.post('/delete/:listId', (req, res) => { }); }); +router.get('/subscriptions/:listId', (req, res) => { + let start = parseInt(req.query.start || 0, 10); + let limit = parseInt(req.query.limit || 10000, 10); + + lists.getByCid(req.params.listId, (err, list) => { + if (err) { + res.status(500); + return res.json({ + error: err.message || err, + data: [] + }); + } + subscriptions.list(list.id, start, limit, (err, rows, total) => { + if (err) { + res.status(500); + return res.json({ + error: err.message || err, + data: [] + }); + } + res.status(200); + res.json({ + data: { + total: total, + start: start, + limit: limit, + subscriptions: rows + } + }); + }); + }); +}); + router.post('/field/:listId', (req, res) => { let input = {}; Object.keys(req.body).forEach(key => { diff --git a/views/users/api.hbs b/views/users/api.hbs index 5fed44e0..ca2feb92 100644 --- a/views/users/api.hbs +++ b/views/users/api.hbs @@ -43,6 +43,27 @@ +

GET /api/subscriptions/:listId – {{#translate}}Get list of subscriptions{{/translate}}

+ +

+ {{#translate}}Retrieve a list of subscriptions to the list referenced by :listId. All fields of the subscribers will be returned. Note that custom fields will have generated names.{{/translate}} +

+ +

+ GET {{#translate}}arguments{{/translate}} +

+ + +

+ {{#translate}}Example{{/translate}} +

+ +
curl -XGET '{{serviceUrl}}api/subscriptions/B16uVTdW?access_token={{accessToken}}&limit=10&start=0' 
+

POST /api/subscribe/:listId – {{#translate}}Add subscription{{/translate}}