0

I am trying to write a python script to fetch my tweets using tweepy. I tried 2 versions. They result in 453/403 respectively. Detailed errors below. I have "Free" access to twitter APIs and I have a project with an app(see the screenshot below). Do I need paid access to achieve this?

First version with error:

import tweepy
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN = ''
ACCESS_SECRET = ''

authenticator = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
authenticator.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)

api = tweepy.API(authenticator, wait_on_rate_limit=True)

query = 'from:my_screen_name -is:retweet'

tweet_cursor = tweepy.Cursor(api.search_tweets, q= query, lang="en",
tweet_mode="extended").items(100)

tweets = [tweet.full_text for tweet in tweet_cursor]
print(tweets)

Error:

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 a different access level.

Second version with error:

client = tweepy.Client(
    consumer_key=CONSUMER_KEY,
    consumer_secret=CONSUMER_SECRET,
    access_token=ACCESS_TOKEN,
    access_token_secret=ACCESS_SECRET,
    bearer_token=BEARER_TOKEN
)
query = 'from:my_screen_name -is:retweet'

tweets = client.search_recent_tweets(query=query, tweet_fields=['context_annotations', 'created_at'], max_results=100)

for tweet in tweets.data:
    print(tweet.text)

Error:

When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.

enter image description here

simplfuzz
  • 12,479
  • 24
  • 84
  • 137
  • Good luck with the new Twitter API rules. – tadman Jun 19 '23 at 18:13
  • Did this work beforehand or did you just try it out rn? – NoBlockhit Jun 19 '23 at 18:30
  • @NoBlockhit just tried it out rn. – simplfuzz Jun 19 '23 at 18:51
  • well then its this line: 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 a different access level. – NoBlockhit Jun 19 '23 at 18:52
  • I am pretty sure that this part of the API is only available in other tiers other than free. You can see the API v2 tiers here https://developer.twitter.com/en/portal/products/free (Search for user and create/delete tweets) – Jack Dane Jun 19 '23 at 20:58
  • Isn't there a way to fetch "my" tweets. "I" can be identified by my tokens? – simplfuzz Jun 20 '23 at 19:23

0 Answers0