Please help me resolve these errors: tweepy.errors.Forbidden: 403 Forbidden 453 - You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need


I’m trying to perform sentimental analysis on tweets from Twitter.

Here is my Project Code:

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)

Dash app initialization

app = dash.Dash(name)

Layout of the dashboard

app.layout = html.Div([
dcc.Input(id=‘keyword-input’, type=‘text’, value=‘data science’),
interval=30 * 1000, # in milliseconds

Callback to update the graph

@app.callback(Output(‘live-update-graph’, ‘figure’),
[Input(‘interval-component’, ‘n_intervals’),
Input(‘keyword-input’, ‘value’)])
def update_graph(n, keyword):
# Fetch tweets based on the provided keyword
tweets = api.search_tweets(q=keyword, count=100, lang=“en”, tweet_mode=‘extended’)

# Analyze sentiments
sentiments = {'Positive': 0, 'Negative': 0, 'Neutral': 0}
for tweet in tweets:
    analysis = TextBlob(tweet.full_text)
    if analysis.sentiment.polarity > 0:
        sentiments['Positive'] += 1
    elif analysis.sentiment.polarity < 0:
        sentiments['Negative'] += 1
        sentiments['Neutral'] += 1

# Create a pie chart
labels = list(sentiments.keys())
values = list(sentiments.values())

return {
    'data': [
        {'x': labels, 'y': values, 'type': 'pie', 'name': 'Sentiments'},
    'layout': {
        'title': f'Sentiment Analysis for "{keyword}" Tweets',

if name == ‘main’:

And I am encountering the following Errors when running the app.

What level of API access do you have? It sounds like you are trying to do this with a free developer twitter api account, which no longer lets you search tweets. Here is more information. Getting Started with the Twitter API | Docs | Twitter Developer Platform

As your keyword in the screenshot is data science, I suspect you are following along some tutorial related to sentiment analysis in a data science program or just on your own learning. Twitter API used to allow for searching tweets and it was a very common demonstration for accessing a common API and performing sentiment analysis. After being purchased by Elon Musk, the api was converted to a paid model for all but the very basic functions, as shown here…authenticating and posting a tweet. It does not allow for searching as it once did without paying a substantial amount of money, in my opinion. There are other APIs to play with though. I’m not familiar with which would be the best that has a good library implementation of the api to be honest.

1 Like