Search code examples
apitwittertwitter-oauth

Can a tweeter bot post tweets (or quotes) via V2 API? (Essential access)


I'm a very newbie to Twitter bots. I've started reading some tutorials but I got this error while running the code:

TweepError: [{'message': 'You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve', 'code': 453}]

So then I went to this page and I find out I have "Essential Access" and I can only use V2 API. Then I went to see if I can post or quote tweets with this V2 API, but I only found some lookup API not posting. (for posting, I only found this but it is for V1 I guess)

I'm wondering if there exists such an API but I failed to find it (I find these APIs a little bit confusing, to be honest). So I'm here to ask you. If I can't do that with V2 API I should request Elevated access.


Solution

  • I finally found out how to do that, and Twitter documentations didn't help!

    Install tweepy, then do as I do to tweet "Yeah boy! I did it".

    !pip3 install tweepy --upgrade # to install and upgrade tweepy if you didn't.
    

    Then make your BEARER, CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, and ACCESS_SECRET ready. If you don't know how to find them you should check Developer Platform -> Developer Portal -> Projects & Apps -> click on your project -> then look for "Keys and tokens"

    import tweepy
    
    client = tweepy.Client(bearer_token=BEARER, consumer_key=CONSUMER_KEY, consumer_secret=CONSUMER_SECRET, access_token=ACCESS_KEY, access_token_secret=ACCESS_SECRET)
    
    client.create_tweet(text="Yeah boy! I did it")
    

    This worked for me 100% tested. I still don't know if I can quote or reply to a tweet with V2 or not.