Tutorials

Determining Tweet types

Introduction

The purpose of this tutorial is to help Twitter API developers understand the different types of Tweets they'll encounter with the Twitter API, and how to programmatically detect them. We will walk through two example functions that implement the logic for determining the type of a Tweet. If you're aware of the different Tweet types and just looking for the recipe, feel free to skip ahead to the "How to identify Tweet types" section below.

This is a helpful guide for developers building a service or doing analysis with Tweets where differentiating between Tweet types is valuable. For example, if you're building a dashboard and want to enable a user to view "original" Tweets only, the method described here will give you that data attribute.

It's worth noting that the API also offers specific operators such as: is:reply, is:retweet, and is:quote, allowing you to filter for certain types of Tweets at the API layer. However, there can be good reasons for retrieving all relevant Tweets about a topic first, and then adding the "Tweet type" dimension to slice and dice the data during analysis or visualization.

 

Types of Tweets to expect

There are four different types of Tweets that can be created using the Twitter platform.

  1. Original Tweet
    • A message posted to Twitter containing text, photos, a GIF, and/or video.
  2. Retweet
  3. Reply Tweet
    • A reply is when a person responds to another user's Tweet.
  4. Quote Tweet
    • A Quote Tweet is when a person adds their own comment to another person's Tweet. This is also referred to as a "Retweet with a comment."

A few notes:

  • Guides about the different Tweet types will sometimes call out "Mentions" as another type of Tweet. A mention is when a person includes the username (@handle) of another person in the body of the Tweet. For our purposes, this is not a unique type of Tweet because original Tweets, Replies, Retweets, and Quote Tweets can all contain a mention. This metadata is structured for you in the entities object in a Tweet payload.
  • You can have a Retweet of a Reply Tweet or of a Quote Tweet. But this guide will focus on classifying the outermost type of Tweet. So, a Retweet of a Quote Tweet will be classified as a "Retweet."

 

How to identify Tweet types

Now that you know about the different types of Tweets you may encounter, let's talk about how to identify them based on attributes found in the Tweet payload. This section will first cover the enterprise / standard v1.1 payload, followed by the newer payload available in the Twitter API v2.

Enterprise and standard v1.1 payload

Tweet type How to identify
Reply Tweet
  • Reply Tweet identification is based on the root-level "in_reply_to_status_id" field being populated (e.g., not "null")

  • A user can reply to themselves in the case of a "thread" – a series of connected Tweets from one person (How to create a thread on Twitter).
Key payload object: in_reply_to_status_id
Quote Tweet
  • The boolean root-level field, "is_quote_status", will have a value of "true"

  • Additionally, there will be a root-level "quoted_status" object in the payload (similar to Retweet)
Key payload object: is_quote_status
Retweet
  • A Retweet contains the root-level "retweeted_status" object.

  • Additionally, the root-level "text" field value will be prepended with "RT."
Key payload object: retweeted_status
Original Tweet
  • Identification is based on the absence of markers for a Retweet, Quote Tweet, or Reply Tweet

  • Make this the "default" case for all Tweets consumed

 

Twitter API v2 payload

Fortunately, the new v2 data format streamlines the Tweet identification process. There's a single field, "referenced_tweets.type", that allows for easy identification of the Tweet type.

Tweet type How to identify
Reply Tweet
  • The "data.referenced_tweets.type" field will have a value of "replied_to".

  • A user can reply to themselves in the case of a "thread" – a series of connected Tweets from one person (How to create a thread on Twitter).

Key payload object: data.referenced_tweets.type

Quote Tweet
  • The "data.referenced_tweets.type" field will have a value of "quoted"

Key payload object: data.referenced_tweets.type
Retweet
  • The "data.referenced_tweets.type" field will have a value of "retweeted"

Key payload object: data.referenced_tweets.type
Original Tweet
  • The "data.referenced_tweets" object will be absent from the payload

  • Make this the "default" case for all Tweets consumed

 

Programmatic methods to determine Tweet type

With an understanding of the key data attributes that help identify the type of a Tweet, let's take a look at working Python code that implement this logic with both the enterprise / v1.1 and v2 data formats.

Enterprise / v1.1 Function (Python)

First, we'll focus on the below Python function to determine the type of a Tweet with the enterprise / v1.1 data format:

      def determine_tweet_type(tweet):
    # Check for reply indicator first
    if tweet["in_reply_to_status_id"] is not None:
        tweet_type = "Reply Tweet"
    # Check boolean quote status field and make sure it's not a RT of a Quote Tweet 
    elif tweet["is_quote_status"] is True and not tweet["text"].startswith("RT"):
        tweet_type = "Quote Tweet"
    # Check both indicators of a Retweet
    elif tweet["text"].startswith("RT") and tweet.get("retweeted_status") is not None:
        tweet_type = "Retweet"
    else:
        tweet_type = "Original Tweet"
    

In the code above, there are three conditions that we need to evaluate in order to determine the type of Tweet. With the recent introduction of Python 3.10, the language has added support for switch-case statements, or structural pattern matching as it's being called. However, for this tutorial we'll stick with an if...else statement to perform this decision-making operation. Here are the different conditions we need to evaluate:

  1. First, we check to see if the "in_reply_to_status_id" field is not null/none. If true, it must be a Reply Tweet. 
  2. Second, we check if the root-level "is_quote_status" field has a value of True and the "text" field does not start with "RT". If both are true, we can confidently say it's Quote Tweet.
  3. Third, we check to see if the "text" fields starts with "RT" and if the payload contains a root-level "retweeted_status" object. If both are true, it must be a Retweet.
  4. If none of the above conditions evaluate to true, then we know it's an original Tweet.

Tip: Run this Python Search API script to see the function above in action. For more details, see the description in the README.

 

v2 Function (Python)

The Python function below has been modified to determine the type of a Tweet with the v2 data format:

      def determine_tweet_type(tweet):
    # Check for reply indicator
    if tweet["referenced_tweets.type"] == "replied_to":
        tweet_type = "Reply Tweet"
    # Check for quote tweet indicator
    elif tweet["referenced_tweets.type"] == "quoted":
        tweet_type = "Quote Tweet"
    # Check for retweet indicator
    elif tweet["referenced_tweets.type"] == "retweeted":
        tweet_type = "Retweet"
    else:
        tweet_type = "Original Tweet"
    

You'll notice that the new v2 data format simplifies this operation as you only need to inspect a single field in the payload. Below are the steps required to do this programmatically:

  1. First, you'll need to include the tweet.fields parameter in your request, with referenced_tweets set as the value.
  2. Second, using an if...else statement, we check if the referenced_tweets.type field is equal to the value of each type of Tweet (replied_to, quoted, or retweeted).
  3. If none of the above conditions evaluate to true, then we know it's an Original Tweet.

 

Example payloads

Below are full Tweet payload examples of the four different types of Tweets. Feel free to inspect these to see the different attributes that help identify the Tweet type.

Enterprise / standard v1.1 Tweets

      {
  "created_at": "Mon Oct 04 18:33:29 +0000 2021",
  "id": 1445094741222248452,
  "id_str": "1445094741222248452",
  "text": "@oscarmayer can we have the keys to the hot dog car",
  "display_text_range": [
    12,
    51
  ],
  "source": "Sprinklr",
  "truncated": false,
  "in_reply_to_status_id": 1445090423962279937,
  "in_reply_to_status_id_str": "1445090423962279937",
  "in_reply_to_user_id": 97028131,
  "in_reply_to_user_id_str": "97028131",
  "in_reply_to_screen_name": "oscarmayer",
  "user": {
    "id": 783214,
    "id_str": "783214",
    "name": "Twitter",
    "screen_name": "Twitter",
    "location": "everywhere",
    "url": "https://about.twitter.com/",
    "description": "what’s happening?!",
    "translator_type": "regular",
    "protected": false,
    "verified": true,
    "followers_count": 60417056,
    "friends_count": 0,
    "listed_count": 87619,
    "favourites_count": 6270,
    "statuses_count": 14824,
    "created_at": "Tue Feb 20 14:35:54 +0000 2007",
    "utc_offset": null,
    "time_zone": null,
    "geo_enabled": true,
    "lang": null,
    "contributors_enabled": false,
    "is_translator": false,
    "profile_background_color": "ACDED6",
    "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": true,
    "profile_link_color": "1B95E0",
    "profile_sidebar_border_color": "FFFFFF",
    "profile_sidebar_fill_color": "F6F6F6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "profile_image_url": "http://pbs.twimg.com/profile_images/1354479643882004483/Btnfm47p_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/1354479643882004483/Btnfm47p_normal.jpg",
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/783214/1628709359",
    "default_profile": false,
    "default_profile_image": false,
    "following": null,
    "follow_request_sent": null,
    "notifications": null,
    "withheld_in_countries": [

    ]
  },
  "geo": null,
  "coordinates": null,
  "place": null,
  "contributors": null,
  "is_quote_status": false,
  "quote_count": 266,
  "reply_count": 448,
  "retweet_count": 2813,
  "favorite_count": 100798,
  "entities": {
    "hashtags": [

    ],
    "urls": [

    ],
    "user_mentions": [
      {
        "screen_name": "oscarmayer",
        "name": "Oscar Mayer",
        "id": 97028131,
        "id_str": "97028131",
        "indices": [
          0,
          11
        ]
      }
    ],
    "symbols": [

    ]
  },
  "favorited": false,
  "retweeted": false,
  "filter_level": "low",
  "lang": "en"
}
    
      {
  "created_at": "Wed Sep 29 01:03:37 +0000 2021",
  "id": 1443018592648192005,
  "id_str": "1443018592648192005",
  "text": "Happening now! We'd love to see you there! https://t.co/zX1mE4mWce",
  "display_text_range": [
    0,
    42
  ],
  "source": "Twitter Web App",
  "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": 2244994945,
    "id_str": "2244994945",
    "name": "Twitter Dev",
    "screen_name": "TwitterDev",
    "location": "127.0.0.1",
    "url": "https://developer.twitter.com/en/community",
    "description": "The voice of the #TwitterDev team and your official source for updates, news, and events, related to the #TwitterAPI.",
    "translator_type": "regular",
    "protected": false,
    "verified": true,
    "followers_count": 525770,
    "friends_count": 2022,
    "listed_count": 1862,
    "favourites_count": 2114,
    "statuses_count": 3828,
    "created_at": "Sat Dec 14 04:35:55 +0000 2013",
    "utc_offset": null,
    "time_zone": null,
    "geo_enabled": true,
    "lang": null,
    "contributors_enabled": false,
    "is_translator": false,
    "profile_background_color": "FFFFFF",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_link_color": "0084B4",
    "profile_sidebar_border_color": "FFFFFF",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/2244994945/1633532194",
    "default_profile": false,
    "default_profile_image": false,
    "following": null,
    "follow_request_sent": null,
    "notifications": null,
    "withheld_in_countries": [

    ]
  },
  "geo": null,
  "coordinates": null,
  "place": null,
  "contributors": null,
  "quoted_status_id": 1441113332644139010,
  "quoted_status_id_str": "1441113332644139010",
  "quoted_status": {
    "created_at": "Thu Sep 23 18:52:47 +0000 2021",
    "id": 1441113332644139010,
    "id_str": "1441113332644139010",
    "text": "Curious how @PetaBencana built their app for realtime disaster and emergency response using the #TwitterAPI? Join… https://t.co/RQ78FpcS33",
    "display_text_range": [
      0,
      140
    ],
    "source": "Twitter Web App",
    "truncated": true,
    "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": 2244994945,
      "id_str": "2244994945",
      "name": "Twitter Dev",
      "screen_name": "TwitterDev",
      "location": "127.0.0.1",
      "url": "https://developer.twitter.com/en/community",
      "description": "The voice of the #TwitterDev team and your official source for updates, news, and events, related to the #TwitterAPI.",
      "translator_type": "regular",
      "protected": false,
      "verified": true,
      "followers_count": 525770,
      "friends_count": 2022,
      "listed_count": 1862,
      "favourites_count": 2114,
      "statuses_count": 3828,
      "created_at": "Sat Dec 14 04:35:55 +0000 2013",
      "utc_offset": null,
      "time_zone": null,
      "geo_enabled": true,
      "lang": null,
      "contributors_enabled": false,
      "is_translator": false,
      "profile_background_color": "FFFFFF",
      "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
      "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
      "profile_background_tile": false,
      "profile_link_color": "0084B4",
      "profile_sidebar_border_color": "FFFFFF",
      "profile_sidebar_fill_color": "DDEEF6",
      "profile_text_color": "333333",
      "profile_use_background_image": false,
      "profile_image_url": "http://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
      "profile_image_url_https": "https://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
      "profile_banner_url": "https://pbs.twimg.com/profile_banners/2244994945/1633532194",
      "default_profile": false,
      "default_profile_image": false,
      "following": null,
      "follow_request_sent": null,
      "notifications": null,
      "withheld_in_countries": [

      ]
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "is_quote_status": false,
    "extended_tweet": {
      "full_text": "Curious how @PetaBencana built their app for realtime disaster and emergency response using the #TwitterAPI? Join @snowman and @nashin_mahtani on Sep 28 at 6PM PT: https://t.co/GrtBOXh5Y1 https://t.co/NV3vUjAotu",
      "display_text_range": [
        0,
        187
      ],
      "entities": {
        "hashtags": [
          {
            "text": "TwitterAPI",
            "indices": [
              96,
              107
            ]
          }
        ],
        "urls": [
          {
            "url": "https://t.co/GrtBOXh5Y1",
            "expanded_url": "http://twitch.tv/twitterdev",
            "display_url": "twitch.tv/twitterdev",
            "unwound": {
              "url": "https://www.twitch.tv/twitterdev",
              "status": 200,
              "title": "TwitterDev - Twitch",
              "description": "Brought to you by Twitter's Developer Relations team"
            },
            "indices": [
              164,
              187
            ]
          }
        ],
        "user_mentions": [
          {
            "screen_name": "petabencana",
            "name": "PetaBencana.id",
            "id": 2276880895,
            "id_str": "2276880895",
            "indices": [
              12,
              24
            ]
          },
          {
            "screen_name": "snowman",
            "name": "Jim is waiting for snow",
            "id": 17200003,
            "id_str": "17200003",
            "indices": [
              114,
              122
            ]
          },
          {
            "screen_name": "nashin_mahtani",
            "name": "Nashin Mahtani",
            "id": 745261210707206145,
            "id_str": "745261210707206145",
            "indices": [
              127,
              142
            ]
          }
        ],
        "symbols": [

        ],
        "media": [
          {
            "id": 1441112962526113799,
            "id_str": "1441112962526113799",
            "indices": [
              188,
              211
            ],
            "description": "Twitter Demo Days: Extreme Weather & Climate Conversations on Tuesday, September 28th, 2021 at 6PM PST on Twitch",
            "media_url": "http://pbs.twimg.com/media/E__cmqSUcAcq2wL.jpg",
            "media_url_https": "https://pbs.twimg.com/media/E__cmqSUcAcq2wL.jpg",
            "url": "https://t.co/NV3vUjAotu",
            "display_url": "pic.twitter.com/NV3vUjAotu",
            "expanded_url": "https://twitter.com/TwitterDev/status/1441113332644139010/photo/1",
            "type": "photo",
            "sizes": {
              "thumb": {
                "w": 150,
                "h": 150,
                "resize": "crop"
              },
              "large": {
                "w": 1600,
                "h": 900,
                "resize": "fit"
              },
              "medium": {
                "w": 1200,
                "h": 675,
                "resize": "fit"
              },
              "small": {
                "w": 680,
                "h": 383,
                "resize": "fit"
              }
            }
          }
        ]
      },
      "extended_entities": {
        "media": [
          {
            "id": 1441112962526113799,
            "id_str": "1441112962526113799",
            "indices": [
              188,
              211
            ],
            "description": "Twitter Demo Days: Extreme Weather & Climate Conversations on Tuesday, September 28th, 2021 at 6PM PST on Twitch",
            "media_url": "http://pbs.twimg.com/media/E__cmqSUcAcq2wL.jpg",
            "media_url_https": "https://pbs.twimg.com/media/E__cmqSUcAcq2wL.jpg",
            "url": "https://t.co/NV3vUjAotu",
            "display_url": "pic.twitter.com/NV3vUjAotu",
            "expanded_url": "https://twitter.com/TwitterDev/status/1441113332644139010/photo/1",
            "type": "photo",
            "sizes": {
              "thumb": {
                "w": 150,
                "h": 150,
                "resize": "crop"
              },
              "large": {
                "w": 1600,
                "h": 900,
                "resize": "fit"
              },
              "medium": {
                "w": 1200,
                "h": 675,
                "resize": "fit"
              },
              "small": {
                "w": 680,
                "h": 383,
                "resize": "fit"
              }
            }
          }
        ]
      }
    },
    "quote_count": 6,
    "reply_count": 2,
    "retweet_count": 12,
    "favorite_count": 42,
    "entities": {
      "hashtags": [
        {
          "text": "TwitterAPI",
          "indices": [
            96,
            107
          ]
        }
      ],
      "urls": [
        {
          "url": "https://t.co/RQ78FpcS33",
          "expanded_url": "https://twitter.com/i/web/status/1441113332644139010",
          "display_url": "twitter.com/i/web/status/1…",
          "indices": [
            115,
            138
          ]
        }
      ],
      "user_mentions": [
        {
          "screen_name": "petabencana",
          "name": "PetaBencana.id",
          "id": 2276880895,
          "id_str": "2276880895",
          "indices": [
            12,
            24
          ]
        }
      ],
      "symbols": [

      ]
    },
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "filter_level": "low",
    "lang": "en"
  },
  "quoted_status_permalink": {
    "url": "https://t.co/zX1mE4mWce",
    "expanded": "https://twitter.com/TwitterDev/status/1441113332644139010",
    "display": "twitter.com/TwitterDev/sta…"
  },
  "is_quote_status": true,
  "quote_count": 0,
  "reply_count": 0,
  "retweet_count": 2,
  "favorite_count": 12,
  "entities": {
    "hashtags": [

    ],
    "urls": [
      {
        "url": "https://t.co/zX1mE4mWce",
        "expanded_url": "https://twitter.com/TwitterDev/status/1441113332644139010",
        "display_url": "twitter.com/TwitterDev/sta…",
        "indices": [
          43,
          66
        ]
      }
    ],
    "user_mentions": [

    ],
    "symbols": [

    ]
  },
  "favorited": false,
  "retweeted": false,
  "possibly_sensitive": false,
  "filter_level": "low",
  "lang": "en"
}
    
      {
  "created_at": "Thu Sep 23 16:54:11 +0000 2021",
  "id": 1441083486559866882,
  "id_str": "1441083486559866882",
  "text": "RT @SproutSocial: We're excited to share that we partnered with @officialpartner on their #ExtremeWeather project to better understand how…",
  "source": "Twitter Web App",
  "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": 2244994945,
    "id_str": "2244994945",
    "name": "Twitter Dev",
    "screen_name": "TwitterDev",
    "location": "127.0.0.1",
    "url": "https://developer.twitter.com/en/community",
    "description": "The voice of the #TwitterDev team and your official source for updates, news, and events, related to the #TwitterAPI.",
    "translator_type": "regular",
    "protected": false,
    "verified": true,
    "followers_count": 525768,
    "friends_count": 2022,
    "listed_count": 1861,
    "favourites_count": 2114,
    "statuses_count": 3828,
    "created_at": "Sat Dec 14 04:35:55 +0000 2013",
    "utc_offset": null,
    "time_zone": null,
    "geo_enabled": true,
    "lang": null,
    "contributors_enabled": false,
    "is_translator": false,
    "profile_background_color": "FFFFFF",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_link_color": "0084B4",
    "profile_sidebar_border_color": "FFFFFF",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/2244994945/1633532194",
    "default_profile": false,
    "default_profile_image": false,
    "following": null,
    "follow_request_sent": null,
    "notifications": null,
    "withheld_in_countries": [

    ]
  },
  "geo": null,
  "coordinates": null,
  "place": null,
  "contributors": null,
  "retweeted_status": {
    "created_at": "Thu Sep 23 16:49:24 +0000 2021",
    "id": 1441082281406308356,
    "id_str": "1441082281406308356",
    "text": "We're excited to share that we partnered with @officialpartner on their #ExtremeWeather project to better understan… https://t.co/Q4fXhT7R31",
    "display_text_range": [
      0,
      140
    ],
    "source": "Sprout Social",
    "truncated": true,
    "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": 42793960,
      "id_str": "42793960",
      "name": "Sprout Social",
      "screen_name": "SproutSocial",
      "location": "Chicago, IL, USA",
      "url": "http://sproutsocial.com",
      "description": "We build social media software that enables marketers to see social differently and grow their business using social. \nStart today: http://bit.ly/2paovei",
      "translator_type": "none",
      "protected": false,
      "verified": true,
      "followers_count": 113679,
      "friends_count": 27936,
      "listed_count": 5674,
      "favourites_count": 37866,
      "statuses_count": 101774,
      "created_at": "Wed May 27 02:30:57 +0000 2009",
      "utc_offset": null,
      "time_zone": null,
      "geo_enabled": true,
      "lang": null,
      "contributors_enabled": false,
      "is_translator": false,
      "profile_background_color": "1A1B1F",
      "profile_background_image_url": "http://abs.twimg.com/images/themes/theme9/bg.gif",
      "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme9/bg.gif",
      "profile_background_tile": true,
      "profile_link_color": "2BB656",
      "profile_sidebar_border_color": "FFFFFF",
      "profile_sidebar_fill_color": "252429",
      "profile_text_color": "666666",
      "profile_use_background_image": true,
      "profile_image_url": "http://pbs.twimg.com/profile_images/625697856330952709/3dynAKiy_normal.png",
      "profile_image_url_https": "https://pbs.twimg.com/profile_images/625697856330952709/3dynAKiy_normal.png",
      "profile_banner_url": "https://pbs.twimg.com/profile_banners/42793960/1634149922",
      "default_profile": false,
      "default_profile_image": false,
      "following": null,
      "follow_request_sent": null,
      "notifications": null,
      "withheld_in_countries": [

      ]
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "is_quote_status": false,
    "extended_tweet": {
      "full_text": "We're excited to share that we partnered with @officialpartner on their #ExtremeWeather project to better understand how the #TexasFreeze unfolded using social listening. In times of crisis, these actionable insights can make a real-world impact. Dive in: https://t.co/1BQxH7ns9K https://t.co/YKy4oPVoez",
      "display_text_range": [
        0,
        279
      ],
      "entities": {
        "hashtags": [
          {
            "text": "ExtremeWeather",
            "indices": [
              72,
              87
            ]
          },
          {
            "text": "TexasFreeze",
            "indices": [
              125,
              137
            ]
          }
        ],
        "urls": [
          {
            "url": "https://t.co/1BQxH7ns9K",
            "expanded_url": "https://bit.ly/2XQIciI",
            "display_url": "bit.ly/2XQIciI",
            "unwound": {
              "url": "https://developer.twitter.com/en/use-cases/build-for-good/extreme-weather/texas-freeze",
              "status": 200,
              "title": "Build for Good: Texas Freeze",
              "description": "Build for good on the Twitter Developer Platform. Understand how climate change is creating extreme weather. Explore how Twitter is used during extreme temperature changes."
            },
            "indices": [
              256,
              279
            ]
          }
        ],
        "user_mentions": [
          {
            "screen_name": "OfficialPartner",
            "name": "Twitter Official Partner",
            "id": 791978718,
            "id_str": "791978718",
            "indices": [
              46,
              62
            ]
          }
        ],
        "symbols": [

        ],
        "media": [
          {
            "id": 1441082253904318466,
            "id_str": "1441082253904318466",
            "indices": [
              280,
              303
            ],
            "additional_media_info": {
              "monetizable": false
            },
            "media_url": "http://pbs.twimg.com/media/E__AsVjVEA0wRMZ.jpg",
            "media_url_https": "https://pbs.twimg.com/media/E__AsVjVEA0wRMZ.jpg",
            "url": "https://t.co/YKy4oPVoez",
            "display_url": "pic.twitter.com/YKy4oPVoez",
            "expanded_url": "https://twitter.com/SproutSocial/status/1441082281406308356/video/1",
            "type": "video",
            "video_info": {
              "aspect_ratio": [
                16,
                9
              ],
              "duration_millis": 8000,
              "variants": [
                {
                  "content_type": "application/x-mpegURL",
                  "url": "https://video.twimg.com/amplify_video/1441082253904318466/pl/sitXNXCzHu1oIxIg.m3u8?tag=14"
                },
                {
                  "bitrate": 2176000,
                  "content_type": "video/mp4",
                  "url": "https://video.twimg.com/amplify_video/1441082253904318466/vid/1280x720/r9l0OhGILfjR4dcx.mp4?tag=14"
                },
                {
                  "bitrate": 288000,
                  "content_type": "video/mp4",
                  "url": "https://video.twimg.com/amplify_video/1441082253904318466/vid/480x270/JsxBClBO-eK1LcmA.mp4?tag=14"
                },
                {
                  "bitrate": 832000,
                  "content_type": "video/mp4",
                  "url": "https://video.twimg.com/amplify_video/1441082253904318466/vid/640x360/ODmBf2h9J9khcE3Y.mp4?tag=14"
                }
              ]
            },
            "sizes": {
              "thumb": {
                "w": 150,
                "h": 150,
                "resize": "crop"
              },
              "large": {
                "w": 1920,
                "h": 1080,
                "resize": "fit"
              },
              "medium": {
                "w": 1200,
                "h": 675,
                "resize": "fit"
              },
              "small": {
                "w": 680,
                "h": 383,
                "resize": "fit"
              }
            }
          }
        ]
      },
      "extended_entities": {
        "media": [
          {
            "id": 1441082253904318466,
            "id_str": "1441082253904318466",
            "indices": [
              280,
              303
            ],
            "additional_media_info": {
              "monetizable": false
            },
            "media_url": "http://pbs.twimg.com/media/E__AsVjVEA0wRMZ.jpg",
            "media_url_https": "https://pbs.twimg.com/media/E__AsVjVEA0wRMZ.jpg",
            "url": "https://t.co/YKy4oPVoez",
            "display_url": "pic.twitter.com/YKy4oPVoez",
            "expanded_url": "https://twitter.com/SproutSocial/status/1441082281406308356/video/1",
            "type": "video",
            "video_info": {
              "aspect_ratio": [
                16,
                9
              ],
              "duration_millis": 8000,
              "variants": [
                {
                  "content_type": "application/x-mpegURL",
                  "url": "https://video.twimg.com/amplify_video/1441082253904318466/pl/sitXNXCzHu1oIxIg.m3u8?tag=14"
                },
                {
                  "bitrate": 2176000,
                  "content_type": "video/mp4",
                  "url": "https://video.twimg.com/amplify_video/1441082253904318466/vid/1280x720/r9l0OhGILfjR4dcx.mp4?tag=14"
                },
                {
                  "bitrate": 288000,
                  "content_type": "video/mp4",
                  "url": "https://video.twimg.com/amplify_video/1441082253904318466/vid/480x270/JsxBClBO-eK1LcmA.mp4?tag=14"
                },
                {
                  "bitrate": 832000,
                  "content_type": "video/mp4",
                  "url": "https://video.twimg.com/amplify_video/1441082253904318466/vid/640x360/ODmBf2h9J9khcE3Y.mp4?tag=14"
                }
              ]
            },
            "sizes": {
              "thumb": {
                "w": 150,
                "h": 150,
                "resize": "crop"
              },
              "large": {
                "w": 1920,
                "h": 1080,
                "resize": "fit"
              },
              "medium": {
                "w": 1200,
                "h": 675,
                "resize": "fit"
              },
              "small": {
                "w": 680,
                "h": 383,
                "resize": "fit"
              }
            }
          }
        ]
      }
    },
    "quote_count": 0,
    "reply_count": 4,
    "retweet_count": 13,
    "favorite_count": 33,
    "entities": {
      "hashtags": [
        {
          "text": "ExtremeWeather",
          "indices": [
            72,
            87
          ]
        }
      ],
      "urls": [
        {
          "url": "https://t.co/Q4fXhT7R31",
          "expanded_url": "https://twitter.com/i/web/status/1441082281406308356",
          "display_url": "twitter.com/i/web/status/1…",
          "indices": [
            117,
            140
          ]
        }
      ],
      "user_mentions": [
        {
          "screen_name": "OfficialPartner",
          "name": "Twitter Official Partner",
          "id": 791978718,
          "id_str": "791978718",
          "indices": [
            46,
            62
          ]
        }
      ],
      "symbols": [

      ]
    },
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "filter_level": "low",
    "lang": "en"
  },
  "is_quote_status": false,
  "quote_count": 0,
  "reply_count": 0,
  "retweet_count": 0,
  "favorite_count": 0,
  "entities": {
    "hashtags": [
      {
        "text": "ExtremeWeather",
        "indices": [
          90,
          105
        ]
      }
    ],
    "urls": [

    ],
    "user_mentions": [
      {
        "screen_name": "SproutSocial",
        "name": "Sprout Social",
        "id": 42793960,
        "id_str": "42793960",
        "indices": [
          3,
          16
        ]
      },
      {
        "screen_name": "OfficialPartner",
        "name": "Twitter Official Partner",
        "id": 791978718,
        "id_str": "791978718",
        "indices": [
          64,
          80
        ]
      }
    ],
    "symbols": [

    ]
  },
  "favorited": false,
  "retweeted": false,
  "filter_level": "low",
  "lang": "en"
}
    
      {
  "created_at": "Wed Sep 22 20:06:40 +0000 2021",
  "id": 1440769535355748358,
  "id_str": "1440769535355748358",
  "text": "Learn how to use the Twitter API with Google Cloud Products to ingest and analyze large volumes of Tweets in this t… https://t.co/SzVYjzhPHC",
  "source": "Twitter Web App",
  "truncated": true,
  "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": 2244994945,
    "id_str": "2244994945",
    "name": "Twitter Dev",
    "screen_name": "TwitterDev",
    "location": "127.0.0.1",
    "url": "https://developer.twitter.com/en/community",
    "description": "The voice of the #TwitterDev team and your official source for updates, news, and events, related to the #TwitterAPI.",
    "translator_type": "regular",
    "protected": false,
    "verified": true,
    "followers_count": 525764,
    "friends_count": 2022,
    "listed_count": 1861,
    "favourites_count": 2114,
    "statuses_count": 3828,
    "created_at": "Sat Dec 14 04:35:55 +0000 2013",
    "utc_offset": null,
    "time_zone": null,
    "geo_enabled": true,
    "lang": null,
    "contributors_enabled": false,
    "is_translator": false,
    "profile_background_color": "FFFFFF",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
    "profile_background_tile": false,
    "profile_link_color": "0084B4",
    "profile_sidebar_border_color": "FFFFFF",
    "profile_sidebar_fill_color": "DDEEF6",
    "profile_text_color": "333333",
    "profile_use_background_image": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/1445764922474827784/W2zEPN7U_normal.jpg",
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/2244994945/1633532194",
    "default_profile": false,
    "default_profile_image": false,
    "following": null,
    "follow_request_sent": null,
    "notifications": null,
    "withheld_in_countries": [

    ]
  },
  "geo": null,
  "coordinates": null,
  "place": null,
  "contributors": null,
  "is_quote_status": false,
  "extended_tweet": {
    "full_text": "Learn how to use the Twitter API with Google Cloud Products to ingest and analyze large volumes of Tweets in this tutorial by @prasannacs. Read more ⏬\n\nhttps://t.co/zvNHX85img",
    "display_text_range": [
      0,
      175
    ],
    "entities": {
      "hashtags": [

      ],
      "urls": [
        {
          "url": "https://t.co/zvNHX85img",
          "expanded_url": "https://developer.twitter.com/en/docs/tutorials/post-processing-twitter-data-with-the-google-cloud-platform",
          "display_url": "developer.twitter.com/en/docs/tutori…",
          "unwound": {
            "url": "https://developer.twitter.com/en/docs/tutorials/post-processing-twitter-data-with-the-google-cloud-platform",
            "status": 200,
            "title": "Post-processing Twitter data with the Google Cloud Platform",
            "description": null
          },
          "indices": [
            152,
            175
          ]
        }
      ],
      "user_mentions": [
        {
          "screen_name": "prasannacs",
          "name": "Prasanna CS",
          "id": 58757319,
          "id_str": "58757319",
          "indices": [
            126,
            137
          ]
        }
      ],
      "symbols": [

      ]
    }
  },
  "quote_count": 1,
  "reply_count": 1,
  "retweet_count": 14,
  "favorite_count": 48,
  "entities": {
    "hashtags": [

    ],
    "urls": [
      {
        "url": "https://t.co/SzVYjzhPHC",
        "expanded_url": "https://twitter.com/i/web/status/1440769535355748358",
        "display_url": "twitter.com/i/web/status/1…",
        "indices": [
          117,
          140
        ]
      }
    ],
    "user_mentions": [

    ],
    "symbols": [

    ]
  },
  "favorited": false,
  "retweeted": false,
  "possibly_sensitive": false,
  "filter_level": "low",
  "lang": "en"
}
    

v2 Tweets

      
{
    "data": {
        "id": "1445094741222248452",
        "referenced_tweets": [
            {
                "type": "replied_to",
                "id": "1445090423962279937"
            }
        ],
        "text": "@oscarmayer can we have the keys to the hot dog car"
    }
}
    
      {
    "data": {
        "id": "1443018592648192005",
        "referenced_tweets": [
            {
                "type": "quoted",
                "id": "1441113332644139010"
            }
        ],
        "text": "Happening now! We'd love to see you there! https://t.co/zX1mE4mWce"
    }
}
    
      {
    "data": {
        "id": "1441083486559866882",
        "referenced_tweets": [
            {
                "type": "retweeted",
                "id": "1441082281406308356"
            }
        ],
        "text": "RT @SproutSocial: We're excited to share that we partnered with @officialpartner on their #ExtremeWeather project to better understand how…"
    }
}
    
      {
    "data": {
        "id": "1440769535355748358",
        "text": "Learn how to use the Twitter API with Google Cloud Products to ingest and analyze large volumes of Tweets in this tutorial by @prasannacs. Read more ⏬\n\nhttps://t.co/zvNHX85img"
    }
}
    

Conclusion

This tutorial provided an explanation of the different types of Tweets you'll encounter on Twitter and showed you how to programmatically detect them using the API. To see the code in action, you can run this Python script that classifies the type of Tweets returned by an enterprise Search API query.

We hope you found it useful, and are able to apply these learnings in your next project with the Twitter API.

 

Ready to build your solution?

Apply for developer access to get started