"Twitter" (Service Connection)

Connect your Twitter account to the Wolfram Language to analyze Twitter data like tweets, retweets, replies, and followers. Also send tweets directly from the Wolfram Language.

Connecting & Authenticating

ServiceConnect["Twitter"] creates a connection to the Twitter API. If a previously saved connection can be found, it will be used; otherwise, a new authentication request will be launched.

Requests

ServiceExecute["Twitter","request",params] sends a request to the Twitter API, using parameters params. The following give possible requests.

User Information

Requests:

"UserData" profile information for any user

Parameters:
  • "Username"authenticated userthe Twitter name
    "UserID"authenticated userthe user ID number
  • Requests:

    "UserMentions" list of user handles included in a timeline

    "UserReplies" user's replies

    "UserHashtags" hashtags in user's tweets

    Parameters:
  • "Username"authenticated userthe Twitter name
    "UserID"authenticated userthe user ID number
    MaxItems20number of results to return
  • Friends and Followers Information

    Requests:

    "Friends" who a user is following, or a list of names of the users followed by the provided user

    "FriendIDs" list of IDs of the users followed by the provided user

    "Followers" who is following a user, or a list of names of the users following the provided user

    "FollowerIDs" list of IDs of the users following the provided user

    Parameters:
  • "Username"authenticated userthe Twitter name
    "UserID"authenticated userthe user ID number
    MaxItems5000number of results to return
    "StartIndex"1start index
  • Requests:

    "FriendNetwork" graph of which of the user's friends follow each other

    "FollowerNetwork" graph of which of the user's followers follow each other

    "FriendMentionNetwork" graph of which friends mention each other

    "FollowerMentionNetwork" graph of which followers mention each other

    "FriendReplyToNetwork" graph of which friends reply to each other

    "FollowerReplyToNetwork" graph of which followers reply to each other

    Parameters:
  • "Username"authenticated userthe Twitter name
    "UserID"authenticated userthe user ID number
  • Sending Tweets

    Requests:

    "Tweet" send a tweet

    Parameters:
  • "Message"(required)message to send
    "InReplyToStatusID"Nonetweet ID being replied to
    GeoLocationNonelocation of the tweet
    "Image"Noneimage or list of images to attach to the tweet (max. 4)
  • Requests:

    "Retweet" Retweet a tweet

    Parameters:
  • "TweetID"(required)tweet ID to be retweeted
  • Retrieving Tweets

    Requests:

    "GetTweet" get a tweet

    Parameters:
  • "TweetID"(required)tweet ID to be retrieved
    "Elements""Data"
  • data elements to return
  • Requests:

    "TweetList" get a list of tweets

    Parameters:
  • "Username"authenticated userthe Twitter name
    "UserID"authenticated userthe user ID number
    MaxItems20number of results to return
    "Elements""Data"
  • data elements to return
  • "SinceID"Noneearliest tweet ID to use
    "MaxID"Nonelatest tweet ID to use
  • Requests:

    "TweetTimeline" get a timeline of tweets

    "TweetEventSeries" get tweets as a series of events

    Parameters:
  • "Username"authenticated userthe Twitter name
    "UserID"authenticated userthe user ID number
    MaxItems20number of results to return
  • Requests:

    "LastTweet" user's latest tweet

    Parameters:
  • "Username"authenticated userthe Twitter name
    "UserID"authenticated userthe user ID number
  • Content Search & Followers

    Requests:

    "TweetSearch" find recent tweets associated with a specified content search string

    Parameters:
  • "Query"(required)search string
    MaxItems20number of results to return
    "Language"Nonelanguage entity of the tweet
    "ResultType"Nonetype of tweet
    GeoLocationNonelocation of the tweet
    "Radius"radius around the location. This parameter will be used only if the GeoLocation parameter is included
  • Requests:

    "UserIDSearch" find user IDs associated with a specified content search string

    "SearchNetwork" follower network based on a specified content search string

    "SearchMentionNetwork" mention network based on a specified content search string

    "SearchReplyToNetwork" reply network based on a specified content search string

    Parameters:
  • "Query"(required)search string
    MaxItems20number of users to return
  • Access Information

    Requests:

    "RateLimit" check number of available and used requests for this connection

    Parameter Details

    Possible settings for "Elements" include:
  • "Data"return a dataset with a limited set of fields
    "Images"return a list of images
    "FullData"return a dataset with all available fields
    "Text"return a list of texts
  • Possible settings for "ShowThumbnails" include:
  • Trueincludes thumbnails
    Falseincludes thumbnails' URLs
  • Possible settings for "ResultType" include:
  • "Recent"return the latest tweets
    "Popular"return popular tweets
  • Examples

    Basic Examples  (1)

    Create a new connection:

    Get information about any user. "UserID" and "Username" are both valid inputs:

    Get replies from a user:

    Get hashtags in a user's tweets:

    See who a user is following:

    See who is following a user:

    Plot your friend network:

    Tweet a message:

    Tweet an image:

    Tweet multiple images:

    Get basic information about a tweet:

    Get the images of a tweet:

    Search recent tweets with a specific hashtag:

    Search recent tweets using a phrase: