Retrieving a list of moderators through the API

I noticed that there’s an endpoint to retrieve a list of editors for a channel, but not moderators.

How would one go about retrieving a list of moderators through the API if there is no endpoint? Have to spin up an IRC bot to do /mods or whatever everytime I want to check the moderators for a channel?

Cheers,
Dexter

There is an undocumented endpoint you could use https://tmi.twitch.tv/group/user/{channelName}/chatters which will show you the mods that are currently in chat. I don’t know if there is a way to see a list of mods that includes those not in chat at the time though.

Keep in mind though that because this is an undocumented endpoint it’s not officially support and might break/change at any time (and in recent days has had some issues).

hmm interesting… I’m looking for a way to get all moderators that are (not) in chat. Also wouldn’t be safe to use a flakey endpoint in production. Sucks.

thanks anyway. Nice find :smiley:

You could easily make this holy endpoint yourself:

const tmi = require('tmi.js');
const express = require('express');

const app = express();
const client = new tmi.client({
		connection: {
			reconnect: true,
			secure: true
		},
		identity: {
			username: 'some_account',
			password: 'Chat OAuth token'
		}
	});

client.connect()
.then(() => {
	console.log('Connected');
});

app.listen(8058, err => {
	if(!err) {
		console.log('Listening');
	}
	else {
		console.log(err);
	}
});

app.get('/mods-api/channels/:channel', (req, res) => {
	if(client.readyState() !== 'OPEN') {
		return res.json({
			error: 'Service Unavailable',
			status: 503,
			message: 'Not ready'
		});
	}
	let channel = req.params.channel.toLowerCase();
	client.mods(channel)
	.then(moderators => {
		res.json({
			channel,
			moderators
		});
	})
	.catch(err => {
		res.json({
			error: 'Internal Server Error',
			status: 500,
			message: 'Some error occurred'
		})
	});
});

http://localhost:8058/mods-api/channels/Xangold

1 Like

Isn’t this just spinning up an IRC instance then using the mods command (which already said was an option that I didn’t really want to do)?

Even though you’re using NodeJS, i’m not sure how efficient this would be if many look ups were required.

Well to be fair you did not say you didn’t want to do it. There are no other options known to the community.

Connect to the person’s chat, send /mods or .mods as a PRIVMSG to the chat. You’re looking for the NOTICE reply that starts with The moderators of this room are:

It’s literally the only way to do it right now.

Do note that you do not have to JOIN the channel in order to send the command and receive the NOTICE back.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.