Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between on_data and on_status in the tweepy library?

I just started using tweepy library to connect with streaming api of twitter. I encountered both on_status() and on_data() methods of the StreamListener class. What is the difference? Total noob here!

like image 720
sidx Avatar asked Jun 25 '15 15:06

sidx


People also ask

Which Tweepy has StreamListener?

Tweepy v4. 0.0 was released recently and it merged StreamListener into Stream .

Is tweepy a Python library?

Tweepy is an open-sourced, easy-to-use Python library for accessing the Twitter API. It gives you an interface to access the API from your Python application. Alternatively, you can also install it from the GitHub repository.

What is Tweepy streaming?

Tweepy makes it easier to use the twitter streaming api by handling authentication, connection, creating and destroying the session, reading incoming messages, and partially routing messages. This page aims to help you get started using Twitter streams with Tweepy by offering a first walk through.


2 Answers

on_data() handles:

  • replies to statuses
  • deletes
  • events
  • direct messages
  • friends
  • limits, disconnects and warnings

whereas, on_status() just handles statuses.

source: https://github.com/tweepy/tweepy/blob/78d2883a922fa5232e8cdfab0c272c24b8ce37c4/tweepy/streaming.py

like image 141
sdemurjian Avatar answered Oct 17 '22 09:10

sdemurjian


If you're only concerned with tweets, use on_status(). This will give you what you needed without the added information and doing so will not hinder your limit.

If you want detailed information use on_data(). --That's rarely the case unless you're doing heavy analysis.

like image 40
Leb Avatar answered Oct 17 '22 08:10

Leb