opened 12:36PM - 16 Dec 19 UTC
product: api
ticketed
**Brief description**
The API doesn't let me fetch ALL banned/timed out users… for a channel
**How to reproduce**
User this script with a valid broadcaster oAuth and the relevant broadcaster/user ID
```
const fs = require('fs');
const path = require('path');
const got = require('got');
var users = {};
let page = 0;
fetchPage = function(c) {
got({
url: 'https://api.twitch.tv/helix/moderation/banned',
searchParams: {
broadcaster_id: 'ACasterID',
after: c,
first: 100
},
headers: {
authorization: 'Bearer AnOauthForCaster'
},
responseType: 'json'
})
.then(resp => {
page++;
for (var x=0;x<resp.body.data.length;x++) {
users[resp.body.data[x].user_id] = 1;
}
console.log('Page',page,'has',resp.body.data.length,'users',Object.keys(users).length);
fs.appendFileSync(path.join(
__dirname,
'pages',
page + '.json'
), JSON.stringify(resp.body,null,4));
if (resp.body.pagination && resp.body.pagination.cursor) {
fetchPage(resp.body.pagination.cursor);
}
})
.catch(err => {
console.log(err);
});
}
fetchPage('');
```
```
$ node fetch.js
Page 1 has 100 users 100
Page 2 has 100 users 200
Page 3 has 100 users 200
Page 4 has 100 users 200
Page 5 has 100 users 200
Page 6 has 100 users 200
Page 7 has 100 users 200
Page 8 has 100 users 200
Page 9 has 100 users 200
Page 10 has 100 users 200
{ HTTPError: Response code 500 (Internal Server Error)
at EventEmitter.emitter.on (SOMEWHERE/node_modules/got/dist/source/as-promise.js:109:31)
at process._tickCallback (internal/process/next_tick.js:68:7) code: undefined, name: 'HTTPError' }
```
Additionally page 2 thru 10 are identical
**Expected behavior**
Page 1 has 100 users 100
Page 2 has 100 users 200
Page 3 has 100 users 300
Page 4 has 100 users 400
and so on till all banned users are fetched
**Additional context or questions**
Original Post: https://discuss.dev.twitch.tv/t/bug-moderation-api-for-banned-users-is-bugged/23483