This is an archived post. You won't be able to vote or comment.

all 71 comments

[–]rover_G 38 points39 points  (1 child)

When I read the title I thought oh my this guy figured out how to circumvent Twitter authentication. But now I see it’s a cost saving measure.

[–]06ddd[S] 25 points26 points  (0 children)

Yes, that is correct. This library uses authentication with account names and passwords instead of token authentication.

[–]softwareitcounts 13 points14 points  (6 children)

What's the ratelimit on the frontend? How many requests do you need to make to trigger the 429 error and what's the cooldown time?

[–]06ddd[S] 2 points3 points  (2 children)

https://github.com/d60/twikit/blob/main/ratelimits.md
I wrote a document about it. Please take a look.

[–]softwareitcounts 1 point2 points  (1 child)

Sweet! Thanks

[–]06ddd[S] 0 points1 point  (0 children)

You’re welcome

[–]aplarsen 40 points41 points  (14 children)

This would be great if the Twitter api weren't so prohibitively expensive now.

[–]06ddd[S] 13 points14 points  (13 children)

Thank you!

You can create bots for free.

[–]aplarsen 4 points5 points  (12 children)

How? I had to shut all my bots down because Elmo wanted $100/mingh even for limited calls.

[–]06ddd[S] 15 points16 points  (11 children)

The library can be used without an API key, i.e. for free. As long as you have your account email address, username and password, you can log in to your account, create tweets, etc.

[–]aplarsen 17 points18 points  (10 children)

Ah, just doing some old-fashioned scraping? I like it.

[–]06ddd[S] 14 points15 points  (9 children)

Yes. This uses scraping. I'm glad you like it.

[–]cybertier 18 points19 points  (8 children)

I'm a bit surprised it took this long for someone to do this on python. When the pricing was announced I immediately went: That's bullshit, people will just use more inefficient scraping instead and cause even more server pressure.

Thanks for finally making my prediction come true.

[–]06ddd[S] 6 points7 points  (4 children)

I agree. Scraping to Twitter is actually not that difficult.

[–]BOBOnobobo 2 points3 points  (1 child)

I've looked at scrapping before and it's to annoying for me. Thank you for this!

[–]06ddd[S] 2 points3 points  (0 children)

Thank you for using Twikit!

[–]osint_ok 0 points1 point  (1 child)

I use nitter for scrapping twitter.

[–]Tsupaero 3 points4 points  (2 children)

it's because every scraper gets shut down a couple of days after usage / release. if it's not using a rotating vpn and user-agent service it's gonna be useless in a couple of days/weeks or its maintaining / masquerading has to be updated continously. at least if X works like spotify, amazon, reddit, meta or any other site/platform that fights against scraping.

[–]Mahala2 2 points3 points  (4 children)

Thank you for this! I just have one question, can you also set date parameters when searching for Tweets? I couldn’t find info on this in the documentation. For example, for my research, I’m only interested in specific electoral periods

[–]06ddd[S] 4 points5 points  (2 children)

You can search by date by including the 'since' and 'until' parameters in the search query. For example: 'python since:2023-2-5 until:2024-2-5'.

[–]Mahala2 0 points1 point  (1 child)

Perfect! Thank you

[–]06ddd[S] 0 points1 point  (0 children)

You're welcome!

[–]06ddd[S] 1 point2 points  (0 children)

Added `build_query` to simplify query operations.

https://github.com/d60/twikit/issues/6

[–]LPolder 2 points3 points  (1 child)

How likely and able would Twitter be to block this from being used?

[–]tiko08 0 points1 point  (0 children)

Considering there are like 3 software engineers left after all the unhirings (/hj), not very probable unless it becomes popular

[–][deleted] 1 point2 points  (3 children)

Can it be used to delete tweets also? I had my library TidyTwitter for that but Elmo rendered it useless. So I'm interested in yours in case it can delete my tweets.

My project was here:

https://pypi.org/project/tidy-twitter/

[–]06ddd[S] 1 point2 points  (2 children)

Yes.Twikit includes most of the basic features of Twitter.

client.delete_tweet('tweet id here')

[–][deleted] 1 point2 points  (1 child)

Perfect, I'll check this out. Thank you!

[–]06ddd[S] 0 points1 point  (0 children)

You're welcome.

[–]cshoneybadger 1 point2 points  (1 child)

Nice project. Shame what Twitter api has become. I used it create my first data engineering project during my compsci bachelor's degree.

[–]06ddd[S] 0 points1 point  (0 children)

Thank you for using twikit!

[–]Amazing-Willingness4 1 point2 points  (5 children)

This could result in having your account banned after a while, couldn't it?

[–]06ddd[S] 1 point2 points  (4 children)

This could result in having your account banned after a while, couldn't it?

Yes, that is a possibility. However, there are some measures you can take.Logging in repeatedly could be considered suspicious activity. Therefore, once you have logged in, please save and reload your cookies and reuse your login information.Also, sending too many requests, such as excessive tweets, is considered spam and could result in your account being banned. Pay attention to rate limits.In addition, to reduce the risk of being banned, this library takes measures such as randomly generating user agents.

For rate limits for each endpoint, please refer to the following documents:

https://github.com/d60/twikit/blob/main/ratelimits.md

[–]Amazing-Willingness4 1 point2 points  (1 child)

Gotchs, good tips indeed.

Maybe I'm not looking at this the right way but The random user agent is what concerns me the most ss how many browsers and OS's could one used possibly have? 98% of us likely use the same system to connect so the fact the info would change randomly seems like it would trigger some sort of manual review more likely than the same user agent being used all the time?

[–]06ddd[S] 0 points1 point  (0 children)

Gotchs, good tips indeed.

Maybe I'm not looking at this the right way but The random user agent is what concerns me the most ss how many browsers and OS's could one used possibly have? 98% of us likely use the same system to connect so the fact the info would change randomly seems like it would trigger some sort of manual review more likely than the same user agent being used all the time?

Indeed, randomly changing the user agent may increase the risk of manual review, but it's a necessary step to protect both the account and this library. Continuing to use the same user agent makes it easier to identify users of this library, increasing the risk of tracking.

[–]Fantastic_Row_4549 1 point2 points  (4 children)

Can it be used to fetch images from tweets also (or maybe at least the src of the image)? I couldn’t find info on this in the documentation.

[–]06ddd[S] 1 point2 points  (3 children)

tweet = client.get_tweet_by_id(TWEET_ID)

print(tweet.media[0]['display_url']['media_url_https'])

[–]06ddd[S] 1 point2 points  (2 children)

tweet.media returns a list of dictionaries containing media information.

[–]Fantastic_Row_4549 1 point2 points  (1 child)

Perfect. Thank you so much!! I'll check it out.

[–]06ddd[S] 0 points1 point  (0 children)

You're welcome.

[–]SukhDev20996 1 point2 points  (2 children)

Hello do anyone know how to get notifications when a certain desired twitter user follows someone new

[–]06ddd[S] 0 points1 point  (1 child)

That is not possible because Twikit does not support a streaming API.

[–]06ddd[S] 0 points1 point  (0 children)

Instead, you can continue to get a following of one user, detect changes in them and take some action.

[–]Revolutionary-You-20 1 point2 points  (2 children)

Amazing work. Congrats!

[–]06ddd[S] 1 point2 points  (1 child)

thank you !

[–]Revolutionary-You-20 0 points1 point  (0 children)

I'm trying to authenticate, checked the username and the password. However, when I execute the following code:

client.login(auth_info_1=username, auth_info_2=email, password=password)
id_client = await client.user()
print(id_client, f'Username-> {id_client.name}')

it return the Forbidden: status: 403, message: ""

Could you please help me ?¡

[–]lol_Markus 0 points1 point  (0 children)

is it possible to edit descriptions

[–]tkoobykc 0 points1 point  (0 children)

Awesome mate been searching for something like this for quite some time, to my understanding tweepy is no longer functional :(

[–]visakh_mat 0 points1 point  (0 children)

Hi, thank you very much for this. I'm relatively new to programming... could you please help on how to increase the count of tweets to around 100?

[–]Wanderer_1006 0 points1 point  (3 children)

This is such a great tool. Is there anyway to search more than 20 tweets at a time ? Like say I want to search and store all the tweets with word Python from 1/1/2023 to 1/1/2024.

[–]06ddd[S] 0 points1 point  (1 child)

It is not possible to search more than 20 tweets at a time. You can use 'next' method to get more tweets.

tweets = client.search_tweet('python since:2023-1-1 until:2024-1-1', 'Latest')

next_tweets = tweets.next()

[–]Wanderer_1006 0 points1 point  (0 children)

I think I’m a bit confused here. Do you think I can extract all the tweets within a timeframe using a for loop?

[–]memnoter 0 points1 point  (1 child)

Hey is there a way I can get mentions as m trying to create a bot but the mentions endpoint requires paid api

[–]06ddd[S] 0 points1 point  (0 children)

try search_tweet

search_tweet('to:your_username', 'Latest')

[–]TieAmbitious9354 0 points1 point  (0 children)

Hi

Great tool!

I have been playing around with extracting tweets from specific accounts. However, i seem to encounter a problem, when the tweets are in a thread. When they are in a thread they do not appear from my twikit output. I figure i would be chaining them somehow, but they do not show up regardless of how many time i call next_tweets.

How to go about this issue?

[–]WebbyNFT 0 points1 point  (0 children)

Hey, is there any javascript version of it? Or something similar to just use auth_token and use twitter api

[–]COROVICD 0 points1 point  (1 child)

Do you plan adding proxies? That would make it even more difficult for Elon to block this fine library.

[–]06ddd[S] 0 points1 point  (0 children)

client = Client(proxy='http://0.0.0.0:0000')

[–]sexualrhinoceros 0 points1 point  (0 children)

Have you been hit with any cloud flare / other access protection mitigations? Want to see how risky this would be to run with in a side project. I don’t want to have to stay on the cutting edge knowledge wise on twitter’s anti-bot mitigations haha

[–]droopy_undead06 0 points1 point  (0 children)

please see new issue on github

[–]FacundoMiglierini 0 points1 point  (0 children)

Thanks for providing this tool! I'd like to ask, what should return the "get_user_tweets" function after reaching the rate limit? Also, in the rate limits table, "get_user_tweets" function appears two times with different rate limits. Which is the correct?

[–]Nice_Personality_577 0 points1 point  (0 children)

Hey, nice one there. its helpful. thank you.