Is there a way to collect stream chat setting?

Hi everyone,

I am trying to collect the chat setting (follower-only-chat / all) in streams, using python.

So far, I tried collecting the data (1) using Twitch Python, which is based on Twitch API; however, after looking into API document I do not think there is any way for me to collect the data using API.
I also tried (2) using requests and BeautifulSoup, but the chat setting won’t appear in the output.
Lastly I tried (3) selenium and use find_elements_by_xpath to extract the chat setting and it did not work – maybe I got it incorrect.

from bs4 import BeautifulSoup
from selenium import webdriver
from import WebDriverWait
from import expected_conditions as EC
from import By
from selenium.common.exceptions import TimeoutException

html = None
url = ‘Twitch’][0]
selector = ‘#dataTarget > div’
delay = 15 # seconds

browser = webdriver.Chrome()

# wait for button to be enabled
WebDriverWait(browser, delay).until(
EC.element_to_be_clickable((By.ID, ‘getData’))
button = browser.find_element_by_id(‘getData’)

# wait for data to be loaded
WebDriverWait(browser, delay).until(
    EC.presence_of_element_located((By.CSS_SELECTOR, selector))
content = driver.find_elements_by_xpath('/html/body/div[1]/div/div[2]/div/div[2]/div/div[1]/div/div/div/div/div/section/div/div[5]/div[2]/div/button/p')


So I was wondering if there is any other ways to collect the stream chat setting.

Connect to chat and read ROOMSTATE when you join the channel.

ROOMSTATE is also emitted when it changes

Thank you for the quick response.

I have one quick question: does this mean I need to make a chat bot?


It’s a much better/reliable option that scraping the website

Great, thanks!

I looked into the document that you sent me in the response above and found that it is is JavaScript. Is there a way for me to do this in python?


Either write a bot that can IRC or use one of the existing libraries

Also there is no javascript on the linked page… it’s just the documentation for the messages that Twitch Chat sends

Aha, I got confused because the guide told me to download node.js.

I will search for the library that can help me solve this issue.

Thank you!

The quick start guide use a nodeJS example.

But I linked to the specific guide for the Tags.

Twitch Chat is just an IRC compatible protocol

I see! Thank you for clarification.

I tried building a chat bot; however, I am not sure if I can use the chat bot to listen to other channels. The issue I was having was that I would like to collect the chat setting of channels that I do not own. Is this still possible?


It is set on join.

Why are you after it for channels you don’t “own”?

Oh, this is for research purpose. Without knowing the chat setting, it becomes difficult for me to analyze the data.

Then you probably need to contact Twitch legal since you are doing resaerch work.

What you are doing currently might constitute a violation of the Dev Agreement or TOS

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