The favourite count will only be non-zero if the Tweet is from the authenticated user.

I’m new to TwitDev but can you explain how a user who is not authenticated can respond to a tweet?

Thanks!

(I ask because I, too, am getting 0 on retweet_count/favorite_count)

What do you mean “authenticated”. As far as I see the favorite_count field is always zero. How soon it will get a solution?

I’m still having this issue. Are there any plans to resolve this bug? It’s been 3 years…

For your own Tweets as the authenticated user of your app, or for any other Tweets from other users? Are you using app only or user authentication?

My web app uses the twitter Ruby gem to access the API so that a user who has authenticated with Twitter using OAuth can view metrics on their own tweets, including retweets.

So what results are you seeing and what results do you expect? Can you provide examples?

Using the twitter gem user_timeline method returns an array of Tweet objects, as expected. When I iterate over these, I expect the output of tweet.favorite_count to represent the number of likes a tweet has. What I’ve found instead is that tweet.favorite_count returns 0 unless the tweet is an original tweet and not a retweet. See code sample below:

client(uid).user_timeline(handle, {count: 100}).map { |tweet| tweet.favorite_count }
# Expected result
# => [0, 5, 3, 10]
# Actual result
# => [0, 0, 0, 0]

Right, so with the user_timeline call, you’ll find the correct favorite_count value inside the retweeted_status object of the Tweet (for retweets).

Example, from my user timeline today - I’ve marked the relevant values with **. If I look at my timeline on the web, I see 6.1K RTs and 4K likes for this retweet, which aligns with the values in the JSON for the original Tweet.

  {
    "created_at": "Tue Aug 16 22:02:26 +0000 2016",
    "id": 765670078457184256,
    "id_str": "765670078457184256",
    "text": "RT @mathiasverraes: There are only two hard problems in distributed systems:  2. Exactly-once delivery 1. Guaranteed order of messages 2. E…",
    "truncated": false,
    "entities": {
      "hashtags": [

      ],
      "symbols": [

      ],
      "user_mentions": [
        {
          "screen_name": "mathiasverraes",
          "name": "Mathias Verraes",
          "id": 17210045,
          "id_str": "17210045",
          "indices": [
            3,
            18
          ]
        }
      ],
      "urls": [

      ]
    },
    "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter for  iPhone</a>",
    "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": 786491,
      "id_str": "786491",
      "name": "Andy Piper aka Pipes",
      "screen_name": "andypiper",
      "location": "Kingston upon Thames, London",
      "description": "I'm on the @TwitterDev team, supporting and listening to developers working on the Twitter platform. Code, community, and respect. #HeForShe",
      "url": "https://t.co/doP36jplFL",
      "entities": {
        "url": {
          "urls": [
            {
              "url": "https://t.co/doP36jplFL",
              "expanded_url": "https://www.justgiving.com/fundraising/Debbie-Piper18",
              "display_url": "justgiving.com/fundraising/De…",
              "indices": [
                0,
                23
              ]
            }
          ]
        },
        "description": {
          "urls": [

          ]
        }
      },
      "protected": false,
      "followers_count": 13621,
      "friends_count": 3884,
      "listed_count": 780,
      "created_at": "Wed Feb 21 15:14:48 +0000 2007",
      "favourites_count": 67536,
      "utc_offset": 3600,
      "time_zone": "London",
      "geo_enabled": true,
      "verified": false,
      "statuses_count": 90775,
      "lang": "en",
      "contributors_enabled": false,
      "is_translator": false,
      "is_translation_enabled": false,
      "profile_background_color": "ACDEEE",
      "profile_background_image_url": "http://abs.twimg.com/images/themes/theme18/bg.gif",
      "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme18/bg.gif",
      "profile_background_tile": false,
      "profile_image_url": "http://pbs.twimg.com/profile_images/758942034195390464/JKfZFVIM_normal.jpg",
      "profile_image_url_https": "https://pbs.twimg.com/profile_images/758942034195390464/JKfZFVIM_normal.jpg",
      "profile_banner_url": "https://pbs.twimg.com/profile_banners/786491/1468424285",
      "profile_link_color": "6EA8E6",
      "profile_sidebar_border_color": "FFFFFF",
      "profile_sidebar_fill_color": "F6F6F6",
      "profile_text_color": "333333",
      "profile_use_background_image": true,
      "has_extended_profile": true,
      "default_profile": false,
      "default_profile_image": false,
      "following": false,
      "follow_request_sent": false,
      "notifications": false
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "retweeted_status": {
      "created_at": "Fri Aug 14 18:40:52 +0000 2015",
      "id": 632260618599403520,
      "id_str": "632260618599403520",
      "text": "There are only two hard problems in distributed systems:  2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery",
      "truncated": false,
      "entities": {
        "hashtags": [

        ],
        "symbols": [

        ],
        "user_mentions": [

        ],
        "urls": [

        ]
      },
      "source": "<a href=\"http://twitter.com/download/android\" rel=\"nofollow\">Twitter for Android</a>",
      "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": 17210045,
        "id_str": "17210045",
        "name": "Mathias Verraes",
        "screen_name": "mathiasverraes",
        "location": "Belgium",
        "description": "Student of Systems • Meddler of Models • Labourer of Legacy",
        "url": "http://t.co/wAktz2GjBa",
        "entities": {
          "url": {
            "urls": [
              {
                "url": "http://t.co/wAktz2GjBa",
                "expanded_url": "http://verraes.net",
                "display_url": "verraes.net",
                "indices": [
                  0,
                  22
                ]
              }
            ]
          },
          "description": {
            "urls": [

            ]
          }
        },
        "protected": false,
        "followers_count": 6163,
        "friends_count": 215,
        "listed_count": 297,
        "created_at": "Thu Nov 06 12:35:30 +0000 2008",
        "favourites_count": 2414,
        "utc_offset": 7200,
        "time_zone": "Brussels",
        "geo_enabled": false,
        "verified": false,
        "statuses_count": 17005,
        "lang": "en",
        "contributors_enabled": false,
        "is_translator": false,
        "is_translation_enabled": false,
        "profile_background_color": "C6E2EE",
        "profile_background_image_url": "http://pbs.twimg.com/profile_background_images/573049942643625984/SD4Zbuy-.png",
        "profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/573049942643625984/SD4Zbuy-.png",
        "profile_background_tile": true,
        "profile_image_url": "http://pbs.twimg.com/profile_images/695594250315010050/SZXk1Z6b_normal.jpg",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/695594250315010050/SZXk1Z6b_normal.jpg",
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/17210045/1454401848",
        "profile_link_color": "1692A5",
        "profile_sidebar_border_color": "FFFFFF",
        "profile_sidebar_fill_color": "DAECF4",
        "profile_text_color": "663B12",
        "profile_use_background_image": false,
        "has_extended_profile": true,
        "default_profile": false,
        "default_profile_image": false,
        "following": false,
        "follow_request_sent": false,
        "notifications": false
      },
      "geo": null,
      "coordinates": null,
      "place": null,
      "contributors": null,
      "is_quote_status": false,
      **"retweet_count": 6136,**
      **"favorite_count": 3987,**
      "favorited": false,
      "retweeted": true,
      "lang": "en"
    },
    "is_quote_status": false,
    **"retweet_count": 6136,**
    **"favorite_count": 0,**
    "favorited": false,
    "retweeted": true,
    "lang": "en"
  }

I see. So if I understand correctly, the tweet shows the cumulative retweet_count, whereas the favorite_count is only for your individual retweet. In order to get the cumulative favorite_count (what you see in your feed) I have to pull it from the retweeted_status node. If this is correct, it would be very helpful to clarify this in the API docs for tweet. Thanks!

1 Like

I am making a call to the statuses/user_timeline API. This returns an array of tweets posted by the respective user making the call, as expected. When I iterate over the array returned the favorite_count returns the correct count, but the retweet_count however always returns 0.

same holds for statuses/retweets/:id.json, retweet_count always returns zero.

When trying to retrieve the same value using statuses/show/:id, i get the response [ { code: 34, message: ‘Sorry, that page does not exist.’ } ]

Please help.

Can you provide example Tweet IDs that demonstrate the issue you are describing? are you using statuses/show/:id.json?

I’m using the nodejs twitter npm for making authenticated calls to twitter.

The call im making is ‘statuses/user_timeline’ which gives me the following json object

[{“created_at”:“Wed Oct 05 10:57:04 +0000 2016”,
“id”:783622026544107500,
“id_str”:“783622026544107521”,
“text”:“PS. Most of y tweets are meant for testing purposes only!\n\n#nohashtags #testing”,
“truncated”:false,
“entities”:{“hashtags”:[{“text”:“nohashtags”,
“indices”:[59,70]},
{“text”:“testing”,“indices”:[71,79]}],
“symbols”:[],“user_mentions”:[],
“urls”:[]},
“source”:"<a href=“http://twitter.com” rel=“nofollow”>Twitter Web Client",
“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”:68600,
“id_str”:“68576”,
“name”:“melinda threeza”,
“screen_name”:“melTvaz”,
“location”:“Panaji, India”,
“description”:"",
“url”:null,
“entities”:{“description”:{“urls”:]}},
“protected”:false,
“followers_count”:0,
“friends_count”:15,
“listed_count”:0,
“created_at”:“Mon Aug 29 10:00:14 +0000 2016”,
“favourites_count”:5,
“geo_enabled”:false,
“verified”:false,
“statuses_count”:10,
“lang”:“en”,
“contributors_enabled”:false,
“is_translator”:false,
“is_translation_enabled”:false,
“has_extended_profile”:false,
“default_profile”:true,
“default_profile_image”:true,
“following”:false,
“follow_request_sent”:false,
“notifications”:false},
“geo”:null,
“coordinates”:null,
“place”:null,
“contributors”:null,
“is_quote_status”:false,
“retweet_count”:0,
“favorite_count”:1,
“favorited”:true,
“retweeted”:false,
“lang”:“en”}]

The favourites_count is correct. The “retweet_count” however comes in as 0 for all tweets.

Using ‘statuses/show/783622026544107521’ to retrieve a single tweet object still gives me retweet_couint as 0

{“created_at”:“Wed Oct 05 10:57:04 +0000 2016”,
“id”:783622026544107500,
“id_str”:“783622026544107521”,
“text”:“PS. Most of y tweets are meant for testing purposes only!\n\n#nohashtags #testing”,
“truncated”:false,
“entities”:{“hashtags”:[{“text”:“nohashtags”,“indices”:[59,70]},{“text”:“testing”,“indices”:[71,79]}],“symbols”:[],“user_mentions”:[],“urls”:[]},
“source”:"<a href=“http://twitter.com” rel=“nofollow”>Twitter Web Client",
“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”:68600,“id_str”:“68576”,
“name”:“melinda threeza”,
“screen_name”:“melTvaz”,
“location”:“Panaji, India”,“description”:"",
“url”:null,“entities”:{“description”:{“urls”:[]}},
“protected”:false,
“followers_count”:0,
“friends_count”:15,
“listed_count”:0,
“created_at”:“Mon Aug 29 10:00:14 +0000 2016”,
“favourites_count”:5,
“utc_offset”:null,
“time_zone”:null,
“geo_enabled”:false,
“verified”:false,
“statuses_count”:10,
“lang”:“en”,
“contributors_enabled”:false,
“has_extended_profile”:false,
“default_profile”:true,
“default_profile_image”:true,
“following”:false,
“follow_request_sent”:false,
“notifications”:false},
“contributors”:null,
“is_quote_status”:false,
“retweet_count”:0,
“favorite_count”:1,
“favorited”:true,
“retweeted”:false,“lang”:“en”}

the retweet_count value seems to be showing 0 in all cases.

I think there’s ambiguity about “retweets” and “quoted tweets”

retweet_count only counts “retweets without comment”

There is no count for “quotes” like https://twitter.com/SaeelParulekar/status/785353654769291264 - The quoted tweet is treated as an attatchment url, not as a retweet.

To count quotes, you can use the Search API, using the tweet permalink as the query: eg:
https://twitter.com/search?f=tweets&vertical=default&q=https%3A%2F%2Ftwitter.com%2FmelTvaz%2Fstatus%2F783622026544107521&src=typd

1 Like

Got it! Thanks a lot :slight_smile:

I also require a count or replies to a tweet (along with retweets count and favourites count) in order to show statistics as to how popular a particular users tweets are.

Is there a way i can get the count of replies to a tweet from the twitter api’s?

No, there’s no REST API for replies.

You might want to check out https://ads.twitter.com/ - In Analytics -> Tweets you can export a csv with impressions, engagements, engagement rate, retweets, replies, likes etc. But this is only available in your own account.

I’m not saying this a good idea, but you could use Streaming to follow and track those users, then compare in_reply_to_status_id to see who is replying to certain tweets from those users.

There are, of course, several caveats to this that pop up in my mind.

  1. You won’t get accurate retweet count and favourite count from those replies, because it’ll be live. Expect to see 0s.
    1.1) Although you would get the number of retweets in the stream itself later
  2. You’re limited to how many people you can track. (I don’t know what your plans are, so if you’re only looking to track a few people it shouldn’t be an issue. But if you’re planning on tracking hundreds, you may be out of luck.)
  3. You’re limited to 1% of the total stream, so you’d have to be very careful of #2 not saturating your stream limit.
  4. This method would also pick up tweets about the users you’re tracking, so if you try to track a well known person, you’d be getting more noise than quality. Be careful about #3.
  5. If you see a lot of retweets of a reply to a tweet sent by the user you’re interested in, you’d want to wait a while, then use REST to go back to the initial reply to grab the retweet and favourite count.

Just a thought.

I need to get the tweet related analytics programatically, with almost no human intervention.

The users I will be tracking have a strong hold on twitter so i guess i am very much likely to exceed the rate limit in case i follow these methods.