On Instagram, if a hashtag is often used on a publication type that violates Instagram’s usage and community guidelines, it risks being banned. The problem with these banned hashtags is that when used by a user, they can greatly decrease the engagement rate of the posts. According to some figures, on average 10% of your followers will see your posts on their feeds.
Our goal today will be to see how Instagram marks its banned hashtags and how to detect them automatically with a program.
Note that banned hashtag lists are regularly updated by Instagram, so it is difficult for a human to track all changes.
Before automating our detection we need to see how a classic user can easily spot banned hashtags.
When you go on the page of a hashtag (link with the format of https://www.instagram.com/explore/tags/your_tag/), two cases can occur to you if the hashtag is banned :
If you scroll to the bottom of the page this type of message may be present:
The page may simply not exist:
If you have thousands of hashtags on your account checking them one by one can be very tedious. We will now see how to automate the process.
My first approach was to use Web Scrapping to check the validity of a hastag. Indeed by digging in the sources of a hashtag page we can notice that when the hashtag is banned, there is in the sources a
div html tag with the class
_4Kbb_ which contains the message that allows to know manually if a hashtag is banned :
The problem with this method is that it depends a lot on the Instagram sources because if the sources are updated the method has a high chance of becoming obsolete.
Let’s look for a more stable method. After long research, I decided to inspect the network activity with Chrome DevTools.
Bingo! I noticed that before loading the HTML page Instagram makes a GET request with the
?__a=1 parameter, to get all the information of a hashtag in the form of a JSON document :
Like users, hashtags can be followed on Instagram. Banned hashtags are hashtags that a user cannot follow. I quickly saw in the JSON document the key
graphql.hashtag.allow_following which has a boolean value. Knowing if a hashtag is banned is like checking the value of our key. In the case of a non-existent page, the JSON will be empty.
Easily with the Python language and the Selenium library (for browser automation), we can define a function that determines if a hashtag is valid or not :
from selenium import webdriver
Easy, right? Unfortunately, there are security features that prevent this kind of request from being used so easily. That’s why I made for you a python script that can analyze and detect all the banned hashtags on the posts of an account. The sources are available at the following address:
To use it you just need to have Python3 on your machine, download the sources on Github, install the requirements with
pip install -r requirements.txt and run the
main.py script. Then you just have to follow the instructions in your terminal. Your Instagram login credentials will be required to run the program.
Thank you for reading my article, and I hope you find it useful. As usual, don’t hesitate to contribute to the project or report bugs. See you soon 😄.