Class TwitterV2Client

java.lang.Object
com.northconcepts.datapipeline.twitter2.TwitterV2Client

public class TwitterV2Client extends Object
Minimal Twitter API v2 client (tweet search, followers, timelines, filtered stream) used by this package's readers.
  • Field Details

  • Constructor Details

  • Method Details

    • getRecentTweets

      public Response getRecentTweets(String query, LocalDateTime startDateTime, LocalDateTime endDateTime, int maxResult, String nextToken)
      Returns filtered public Tweets posted over the last 7 days.
    • getAllTweets

      public Response getAllTweets(String query, LocalDateTime startDateTime, LocalDateTime endDateTime, int maxResult, String nextToken)
      Currently only available via the Academic Research product track https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference
    • searchUser

      public String searchUser(String username)
      Returns the unique identifier of the provided Twitter handle.
    • getFollowers

      public Response getFollowers(String username, int maxResult, String nextToken)
      Returns the Followers of a given Twitter handle.
    • getFollowing

      public Response getFollowing(String username, int maxResult, String nextToken)
      Returns the Twitter users that the provided Twitter handle is following.
    • getUserTimelineTweets

      public Response getUserTimelineTweets(String username, LocalDateTime startDateTime, LocalDateTime endDateTime, String sinceId, String untilId, int maxResult, String nextToken)
      Returns Tweets, Retweets, replies, and Quote Tweets published by a specific Twitter account.
    • getUserTimelineMentions

      public Response getUserTimelineMentions(String username, LocalDateTime startDateTime, LocalDateTime endDateTime, String sinceId, String untilId, int maxResult, String nextToken)
      Returns Tweets mentioning a specific Twitter user. Replies to Tweets by the specified user are also included.
    • startFilteredStream

      public <T> Future<Response> startFilteredStream(<any> callback)
      Streams filtered Tweets in real-time based on the added filter rules.
    • setupFilteredStreamRules

      public void setupFilteredStreamRules(Map<String,String> rules) throws Throwable
      Replaces the rules currently active on the streaming endpoint with the ones sent as parameter.
      Throws:
      Throwable
    • getFilteredStreamRules

      public List<String> getFilteredStreamRules() throws Throwable
      Returns the active rules on the streaming endpoint.
      Throws:
      Throwable