Search code examples
twittertweepy

Understanding twitter streaming api response


I am not a very avid user and hence having a hard time figuring out what each field means in twitter api response. Going thru documentation has only resulted in me going in circles.

What I am trying to do is analyzing how things go viral. So, what I did was grabbed data from twitter streaming api with hope of analyzing the response but I am totally confused. So a sample json response is :

{"created_at":"Thu Mar 14 18:19:12 +0000 2013","id":312266679390457857,"id_str":"312266679390457857","text":"The first four winners of our March Madness Giveaway (4x ADATA Technology (USA) 16GB DashDrives) are:\n\nAaron... http:\/\/t.co\/ikPbfRZQdq","source":"\u003ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003eFacebook\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":179622147,"id_str":"179622147","name":"Levetron","screen_name":"Levetron","location":"Los Angeles","url":"http:\/\/www.aziocorp.com","description":"Official Twitter for Levetron by AZiO. Here for customer questions, gaming tips & tricks, sharing cool ideas, product launch releases, reviews and more!","protected":false,"followers_count":1042,"friends_count":25,"listed_count":4,"created_at":"Tue Aug 17 18:56:29 +0000 2010","favourites_count":5,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":false,"verified":false,"statuses_count":707,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"131516","profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme14\/bg.gif","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme14\/bg.gif","profile_background_tile":true,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/3223061028\/999ac6efc782d85983cbcf7f2deab7c1_normal.png","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/3223061028\/999ac6efc782d85983cbcf7f2deab7c1_normal.png","profile_banner_url":"https:\/\/si0.twimg.com\/profile_banners\/179622147\/1360294489","profile_link_color":"009999","profile_sidebar_border_color":"EEEEEE","profile_sidebar_fill_color":"EFEFEF","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"entities":{"hashtags":[],"urls":[{"url":"http:\/\/t.co\/ikPbfRZQdq","expanded_url":"http:\/\/fb.me\/M6YPCk9W","display_url":"fb.me\/M6YPCk9W","indices":[112,134]}],"user_mentions":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"medium"}

1)My guess is if this tweet is a result of a retweet then "retweeted" should be true. But how do i figure out from which user it was retweeted? 2) Is "id" user id or tweet id?

Basically, if lets say I want to analyze how (say) Gangham style went viral.. who retweeted/followed that particular tweet, how should i do this?

Also, has twitter recently changed its api. I am using python for this but looks to me that all of those api's examples are not working

For example: https://github.com/tweepy/tweepy

Any suggestions. Thanks


Solution

  • Please see the Twitter API documentation relating to tweets. It describes all parameters returned in the Twitter JSON response.

    That tweet was not retweeted because retweeted is set to false and retweeted_count is 0.

    From the documentation:

    id = The integer representation of the unique identifier for this Tweet.

    Retweets can be distinguished from typical Tweets by the existence of a retweeted_status attribute. This attribute contains a representation of the original Tweet that was retweeted.

    Also, here is a list of supported twitter libraries. There are several other libraries other than tweepy listed that might work for you.