Find interesting Clubhouse rooms using Python
5 min read

Find interesting Clubhouse rooms using Python

Automate access to Clubhouse to find interesting rooms and discussions
Find interesting Clubhouse rooms using Python

Disclaimer: The following is just tinkering and research for my private use I will provide NOBODY the code. I contacted the Clubhouse team to make them aware of the issue. Go read something else if you want to search for something to spam or other silly stuff.

Lately I have been hanging out in Clubhouse to have interesting discussions about Tech, AI, Programming and other things.

It has been a great way to fill the silence of working from home listening to random Lo-Fi playlists that I started to really dislike.

Clubhouse is invite-only and iphone only at the moment, but it seems that a lot more users are joining the app, notoriously people like Elon Musk or Mark Zuckerberg.

Needless to say that I love the application and I'm having a lot of fun using it. The following is not a guide but more a collection of things that I tried out to understand how someone would write an automated bot for the platform. I am not releasing any source code since I don't want to contribute to anything negative, so consider it a writeup from someone who likes to tinker with things.

Many users on the plattform have a second account in the form of a second phone they use to organize or moderate rooms while keeping their main account separated. I did not want to go down that route since "there must be a better way".

Finding interesting conversations

The main thing that makes the app interesting is the different rooms that are available. A room is a virtual space people join to discuss different topics. The main way to find or discover new rooms is by following people that you like or people who discuss interesting things and then get recommendations from rooms they like or clubs they follow. A club is essentially a group of people, just like Facebook groups.

After some time, the room view gets bloated with uninteresting stuff that I'm not really into like "Learn to dream big by joining this bootcamp - as a millionaire" and other fake/conspiracy theory stuff. While I can see the appeal I don't want to have it suggested everytime. There are currently two ways to find rooms, the main view (aka suggested to you or "Upcoming for you") or the general view that lists all the discussions around the world ("Upcoming for All",  very hard to navigate).

App view

It is difficult to filter out through what I consider is fluff and find what is interesting to me. I don't want to be coached, I don't want to buy a course or whatever I just want to discuss or listen to interesting people that are not trying to sell me something.

There are also a LOT of rooms that people call "Silent networking" where they join and mainly follow each other recursively lol. These rooms are just for clout and absolutely useless, I hide them everytime but they keep coming back up. It's really like it sounds, rooms filled with people who just want to get their follower count up without having to put in any work or learn anything.  

Oldest trick in the book

Naturally something I grew very good in is automation and writing programs to automate whatever it is I am doing, from GUI's to apps to websites. Everything that can be automated should be automated is my mantra, it leaves time for life.

So what do you do in this case?

The first and natural option is to try to reverse engineer the app or in other words try to understand how it works and reproduce or automate those parts. In order to do that, one common way is to use a technique called "Man in the middle" which is essentially setting up a proxy on your phone to intercept the requests that the app is sending and then... modify them and send them again without all the finger tapping action!

Naturally, I began using mitmproxy which is an excellent tool to do just that but it looked like Clubhouse is using certificate pinning. This means I cannot use my custom certificate to intercept the traffic. The app was throwing NSURLErrorDomain errors  which implies just that.

There are MANY ways online to circumvent this, the main one is to use a jailbroken iPhone with some other tools and bypass that custom certificate... I will not elaborate much on this one however but you can learn it with some youtube and reading some other blogs.

So, doing that you can find out things like how Clubhouse is built and what endpoints it is using, what authentication methods...

One main discovery is that Clubhouse is using a REST api at clubhouseapi.com for authentication, registration, searching rooms and co. It uses Agora (audio chat) and Pubnub (real-time communication) under the hood for all the audio related stuff.

Someone posted a Swagger specification of the private Clubhouse API here (USE AT YOUR OWN RISK!!! I REMOVED THE URL ON PURPOSE), I did not verify any claim the poster did nor do I support it.

It is possible to get the Agora SDK to tinker around with things and get the audio after the token has been extracted.

This guide/writeup (in German) explains how it is possible to do fancy stuff with the Agora to listen into ANY room in Clubhouse and do whatever you want with the audio, which is nice I'd say. You just need the Token from the Clubhouse REST API.

So the point of the whole thing is this:

Search all the relevant rooms using a keyword

Now I can list all the rooms that have a certain topic of interest in their title, and then join the rooms and listen.  

I am working on a dashboard of interesting Clubhouse rooms and events but it is currently personal until Clubhouse releases a public API that is legit to access. This was a fun 2 hour project to implement :)

If you want to get notified of new stuff just follow me on Clubhouse as well, you can find me under "Karim Jedda", same picture as here.

Enjoy, have a great weekend and stay healthy.

Note: I was asked to contact the Clubhouse dev if they knew this was possible since it also would allow listening into rooms while remaining anonymous... so I tweeted them and let's see, hope that gets fixed easy peasy to avoid bad actors from ruining the clubhouse experience.