Python Twitter library: which one? [closed]

2024/11/19 7:27:56

I realize this is a bit of a lazyweb question, but I wanted to see which python library for Twitter people have had good experiences with.

I've used Python Twitter Tools and like its brevity and beauty of interface, but it doesn't seem to be one of the popular ones - it's not even listed on the Twitter Libraries page.

There are, however, plenty of others listed:

  • oauth-python-twitter2 by Konpaku Kogasa. Combines python-twitter and oauth-python-twitter to create an evolved OAuth Pokemon.
  • python-twitter by DeWitt Clinton. This library provides a pure Python interface for the Twitter API.
  • python-twyt by Andrew Price. BSD licensed Twitter API interface library and command line client.
  • twitty-twister by Dustin Sallings. A Twisted interface to Twitter.
  • twython by Ryan McGrath. REST and Search library inspired by python-twitter.
  • Tweepy by Josh Roesslein. Supports OAuth, Search API, Streaming API.

My requirements are fairly simple:

  • Be able to use OAuth
  • Be able to follow a user
  • Be able to send a direct message
  • Be able to post
  • Streaming API would be nice

Twisted one aside (I'm not using twisted in this case), have you used any of the others, and if so, do you recommend them?

[Update] FWIW, I ended up going with Python Twitter Tools again. The new version supported OAuth nicely, and it's a very clever API, so I stuck to it.

Answer

python-twitter should cover the first four requirements. I've used it before, and it's fairly easy to start developing with it. For leveraging Twitter's streaming API, I would recommend tweetstream. It's a fantastic Python module that grabs tweets in real-time as they are posted. Based on whether you have gardenhose/firehose access to the twitter stream, you'll only get a small fraction of tweets posted. With tweetstream, you can also provide a list of search predicates to filter specific tweets that you are looking for. I used it for a project that involved mining tweets over an 8 hour period and it worked flawlessly. Both of these modules should be available through Python's easy-install.

EDIT: I don't know what you intend on doing with Python/Twitter but if you do plan on capturing a lot of tweets, keep in mind that Twitter receives myriad tweets in languages besides English. Remember to encode everything properly.

https://en.xdnf.cn/q/26463.html

Related Q&A

How do I use url_for if my method has multiple route annotations?

So I have a method that is accessible by multiple routes:@app.route("/canonical/path/") @app.route("/alternate/path/") def foo():return "hi!"Now, how can I call url_for(&q…

Shortest Python Quine?

Python 2.x (30 bytes): _=_=%r;print _%%_;print _%_Python 3.x (32 bytes) _=_=%r;print(_%%_);print(_%_)Is this the shortest possible Python quine, or can it be done better? This one seems to improve o…

How to find all python installations on mac os x and uninstall all but the native OS X installation

I have installed a few versions on my MacBook for different projects and have only now realized what a mistake that was. I have used homebrew to install it, installed it via pythons website (Python 2.7…

Who runs the callback when using apply_async method of a multiprocessing pool?

Im trying to understand a little bit of whats going on behind the scenes when using the apply_sync method of a multiprocessing pool. Who runs the callback method? Is it the main process that called ap…

Difference between hash() and id()

I have two user-defined objects, say a and b. Both these objects have the same hash values. However, the id(a) and id(b) are unequal.Moreover, >>> a is b False >>> a == b TrueFrom th…

get class name for empty queryset in django

I have empty queryset of model Studentstudents = Students.objects.all()If the above queryset is empty, then how can i get the model(class name)?How can i get the model name for empty queryset?EDIT:Ho…

`Sudo pip install matplotlib` fails to find freetype headers. [OS X Mavericks / 10.9] [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.This question does not appear to be about a specific programming problem, a software algorithm, or s…

Parallel processing from a command queue on Linux (bash, python, ruby... whatever)

I have a list/queue of 200 commands that I need to run in a shell on a Linux server. I only want to have a maximum of 10 processes running (from the queue) at once. Some processes will take a few secon…

How do I select and store columns greater than a number in pandas? [duplicate]

This question already has answers here:How do I select rows from a DataFrame based on column values?(17 answers)Closed 28 days ago.I have a pandas DataFrame with a column of integers. I want the rows …

Plotting transparent histogram with non transparent edge

I am plotting a histogram, and I have three datasets which I want to plot together, each one with different colours and linetype (dashed, dotted, etc). I am also giving some transparency, in order to s…