CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-twitter4j--twitter4j-core

A 100% pure Java library for the Twitter API with no extra dependency

Overview
Eval results
Files

users.mddocs/

User Management

User profile access, lookup, search, and relationship management.

User Information

User Profile Access

Retrieve detailed user profile information.

interface UsersResources {
    /**
     * Get user profile by screen name
     * @param screenName User's screen name (without @)
     * @return User profile information
     */
    User showUser(String screenName) throws TwitterException;
    
    /**
     * Get user profile by user ID
     * @param userId User's numeric ID
     * @return User profile information
     */
    User showUser(long userId) throws TwitterException;
    
    /**
     * Get multiple user profiles by IDs
     * @param ids Array of user IDs (max 100)
     * @return List of user profiles
     */
    ResponseList<User> lookupUsers(long... ids) throws TwitterException;
    
    /**
     * Get multiple user profiles by screen names
     * @param screenNames Array of screen names (max 100)
     * @return List of user profiles
     */
    ResponseList<User> lookupUsers(String... screenNames) throws TwitterException;
}

Usage Examples:

TwitterV1 v1 = twitter.v1();

// Get user by screen name
User user = v1.users().showUser("twitterapi");
System.out.println("Name: " + user.getName());
System.out.println("Followers: " + user.getFollowersCount());

// Get user by ID
User userById = v1.users().showUser(783214L);

// Get multiple users
ResponseList<User> users = v1.users().lookupUsers("twitterapi", "twitter", "twittereng");
for (User u : users) {
    System.out.println(u.getScreenName() + " has " + u.getFollowersCount() + " followers");
}

// Lookup users by IDs
ResponseList<User> usersById = v1.users().lookupUsers(783214L, 17874544L, 95731L);

User Search

Search for users by name, bio, or other profile information.

interface UsersResources {
    /**
     * Search for users matching query
     * @param query Search query (name, bio keywords, etc.)
     * @param page Page number for pagination (1-indexed)
     * @return List of matching users (max 20 per page)
     */
    ResponseList<User> searchUsers(String query, int page) throws TwitterException;
}

Usage Example:

// Search for users
ResponseList<User> searchResults = v1.users().searchUsers("java developer", 1);
for (User user : searchResults) {
    System.out.println("@" + user.getScreenName() + ": " + user.getDescription());
}

// Paginate through search results
for (int page = 1; page <= 5; page++) {
    ResponseList<User> pageResults = v1.users().searchUsers("twitter api", page);
    if (pageResults.isEmpty()) break;
    
    System.out.println("Page " + page + ":");
    for (User user : pageResults) {
        System.out.println("  " + user.getScreenName());
    }
}

Account Management

Account Verification

Verify credentials and get authenticated user's information.

interface UsersResources {
    /**
     * Verify credentials and get authenticated user's profile
     * @return Authenticated user's profile
     */
    User verifyCredentials() throws TwitterException;
}

Usage Example:

// Verify credentials
User me = v1.users().verifyCredentials();
System.out.println("Logged in as: @" + me.getScreenName());
System.out.println("Account created: " + me.getCreatedAt());
System.out.println("Verified: " + me.isVerified());

Profile Updates

Update authenticated user's profile information.

interface UsersResources {
    /**
     * Update profile information
     * @param name Display name (max 50 characters)
     * @param url Website URL
     * @param location Location string
     * @param description Bio/description (max 160 characters)
     * @return Updated user profile
     */
    User updateProfile(String name, String url, String location, String description) 
        throws TwitterException;
    
    /**
     * Update profile image
     * @param image Profile image file
     * @return Updated user profile
     */
    User updateProfileImage(File image) throws TwitterException;
    
    /**
     * Update profile image from input stream
     * @param image Profile image data stream
     * @return Updated user profile
     */
    User updateProfileImage(InputStream image) throws TwitterException;
    
    /**
     * Update profile banner image
     * @param image Banner image file
     */
    void updateProfileBanner(File image) throws TwitterException;
    
    /**
     * Update profile banner from input stream
     * @param image Banner image data stream
     */
    void updateProfileBanner(InputStream image) throws TwitterException;
    
    /**
     * Remove profile banner
     */
    void removeProfileBanner() throws TwitterException;
}

Usage Examples:

// Update profile information
User updatedProfile = v1.users().updateProfile(
    "John Developer",
    "https://example.com",
    "San Francisco, CA", 
    "Software developer passionate about Java and Twitter API"
);

// Update profile image
File profileImage = new File("profile.jpg");
User profileWithNewImage = v1.users().updateProfileImage(profileImage);

// Update banner
File banner = new File("banner.jpg");
v1.users().updateProfileBanner(banner);

// Remove banner
v1.users().removeProfileBanner();

Account Settings

Manage account preferences and settings.

interface UsersResources {
    /**
     * Get current account settings
     * @return Account settings and preferences
     */
    AccountSettings getAccountSettings() throws TwitterException;
    
    /**
     * Update account settings
     * @param trendLocationWoeid Where On Earth ID for trend location
     * @param sleepTimeEnabled Enable sleep time restrictions
     * @param startSleepTime Sleep start time (0-23)
     * @param endSleepTime Sleep end time (0-23)
     * @param timeZone Time zone identifier
     * @param lang Language preference
     * @return Updated account settings
     */
    AccountSettings updateAccountSettings(Integer trendLocationWoeid, 
                                        Boolean sleepTimeEnabled, 
                                        Integer startSleepTime, 
                                        Integer endSleepTime, 
                                        String timeZone, 
                                        String lang) throws TwitterException;
    
    /**
     * Update direct message privacy settings
     * @param allowDmsFrom "all", "following", or "none"
     * @return Updated account settings
     */
    AccountSettings updateAllowDmsFrom(String allowDmsFrom) throws TwitterException;
}

Usage Example:

// Get current settings
AccountSettings settings = v1.users().getAccountSettings();
System.out.println("Language: " + settings.getLanguage());
System.out.println("Time zone: " + settings.getTimeZone().getName());

// Update settings
AccountSettings updated = v1.users().updateAccountSettings(
    1, // WOEID for worldwide trends
    true, // Enable sleep time
    22, // Sleep from 10 PM
    6,  // Until 6 AM
    "America/Los_Angeles",
    "en"
);

// Update DM settings
v1.users().updateAllowDmsFrom("following"); // Only allow DMs from people you follow

Blocking and Muting

Block Management

Block and unblock users to prevent interactions.

interface UsersResources {
    /**
     * Get list of blocked users
     * @return Paginated list of blocked users
     */
    PagableResponseList<User> getBlocksList() throws TwitterException;
    
    /**
     * Get list of blocked users with cursor pagination
     * @param cursor Pagination cursor (-1 for first page)
     * @return Paginated list of blocked users
     */
    PagableResponseList<User> getBlocksList(long cursor) throws TwitterException;
    
    /**
     * Get blocked user IDs
     * @return IDs of blocked users
     */
    IDs getBlocksIDs() throws TwitterException;
    
    /**
     * Get blocked user IDs with cursor pagination
     * @param cursor Pagination cursor (-1 for first page)
     * @return IDs of blocked users
     */
    IDs getBlocksIDs(long cursor) throws TwitterException;
    
    /**
     * Block a user by user ID
     * @param userId User ID to block
     * @return Blocked user profile
     */
    User createBlock(long userId) throws TwitterException;
    
    /**
     * Block a user by screen name
     * @param screenName Screen name to block
     * @return Blocked user profile
     */
    User createBlock(String screenName) throws TwitterException;
    
    /**
     * Unblock a user by user ID
     * @param userId User ID to unblock
     * @return Unblocked user profile
     */
    User destroyBlock(long userId) throws TwitterException;
    
    /**
     * Unblock a user by screen name
     * @param screenName Screen name to unblock
     * @return Unblocked user profile
     */
    User destroyBlock(String screenName) throws TwitterException;
}

Usage Examples:

// Get blocked users
PagableResponseList<User> blocked = v1.users().getBlocksList();
for (User user : blocked) {
    System.out.println("Blocked: @" + user.getScreenName());
}

// Block a user
User blockedUser = v1.users().createBlock("spamaccount");
System.out.println("Blocked @" + blockedUser.getScreenName());

// Unblock a user
User unblockedUser = v1.users().destroyBlock("spamaccount");
System.out.println("Unblocked @" + unblockedUser.getScreenName());

// Get blocked user IDs only (more efficient for large lists)
IDs blockedIds = v1.users().getBlocksIDs();
System.out.println("Blocked " + blockedIds.getIDs().length + " users");

Mute Management

Mute and unmute users to hide their tweets without blocking.

interface UsersResources {
    /**
     * Get list of muted users with cursor pagination
     * @param cursor Pagination cursor (-1 for first page)
     * @return Paginated list of muted users
     */
    PagableResponseList<User> getMutesList(long cursor) throws TwitterException;
    
    /**
     * Get muted user IDs with cursor pagination
     * @param cursor Pagination cursor (-1 for first page)
     * @return IDs of muted users
     */
    IDs getMutesIDs(long cursor) throws TwitterException;
    
    /**
     * Mute a user by user ID
     * @param userId User ID to mute
     * @return Muted user profile
     */
    User createMute(long userId) throws TwitterException;
    
    /**
     * Mute a user by screen name
     * @param screenName Screen name to mute
     * @return Muted user profile
     */
    User createMute(String screenName) throws TwitterException;
    
    /**
     * Unmute a user by user ID
     * @param userId User ID to unmute
     * @return Unmuted user profile
     */
    User destroyMute(long userId) throws TwitterException;
    
    /**
     * Unmute a user by screen name
     * @param screenName Screen name to unmute
     * @return Unmuted user profile
     */
    User destroyMute(String screenName) throws TwitterException;
}

Usage Examples:

// Get muted users
PagableResponseList<User> muted = v1.users().getMutesList(-1);
for (User user : muted) {
    System.out.println("Muted: @" + user.getScreenName());
}

// Mute a user
User mutedUser = v1.users().createMute("noisyaccount");
System.out.println("Muted @" + mutedUser.getScreenName());

// Unmute a user
User unmutedUser = v1.users().destroyMute("noisyaccount");
System.out.println("Unmuted @" + unmutedUser.getScreenName());

Contributors and Contributees

Contributor Management

Manage contributor relationships for team accounts.

interface UsersResources {
    /**
     * Get users that the specified user contributes to
     * @param userId User ID
     * @return List of contributee accounts
     */
    ResponseList<User> getContributees(long userId) throws TwitterException;
    
    /**
     * Get users that the specified user contributes to by screen name
     * @param screenName Screen name
     * @return List of contributee accounts
     */
    ResponseList<User> getContributees(String screenName) throws TwitterException;
    
    /**
     * Get users that contribute to the specified account
     * @param userId User ID
     * @return List of contributor accounts
     */
    ResponseList<User> getContributors(long userId) throws TwitterException;
    
    /**
     * Get users that contribute to the specified account by screen name
     * @param screenName Screen name
     * @return List of contributor accounts
     */
    ResponseList<User> getContributors(String screenName) throws TwitterException;
}

Usage Examples:

// Get accounts this user contributes to
ResponseList<User> contributees = v1.users().getContributees("teamaccount");
for (User account : contributees) {
    System.out.println("Contributes to: @" + account.getScreenName());
}

// Get contributors to this account
ResponseList<User> contributors = v1.users().getContributors("teamaccount");
for (User contributor : contributors) {
    System.out.println("Contributor: @" + contributor.getScreenName());
}

User Data Model

User Profile Information

Complete user profile data structure.

interface User extends TwitterResponse {
    /**
     * User's unique identifier
     */
    long getId();
    
    /**
     * User's display name
     */
    String getName();
    
    /**
     * User's email address (whitelisted apps only)
     */
    String getEmail();
    
    /**
     * User's screen name/handle (without @)
     */
    String getScreenName();
    
    /**
     * User's location
     */
    String getLocation();
    
    /**
     * User's bio/description
     */
    String getDescription();
    
    /**
     * Whether user allows contributors
     */
    boolean isContributorsEnabled();
    
    /**
     * User's website URL
     */
    String getURL();
    
    /**
     * Whether user's tweets are protected
     */
    boolean isProtected();
    
    /**
     * Number of followers
     */
    int getFollowersCount();
    
    /**
     * Number of accounts being followed
     */
    int getFriendsCount();
    
    /**
     * Number of lists user is member of
     */
    int getListedCount();
    
    /**
     * Account creation date
     */
    LocalDateTime getCreatedAt();
    
    /**
     * Number of tweets favorited by user
     */
    int getFavouritesCount();
    
    /**
     * User's UTC offset in seconds
     */
    int getUtcOffset();
    
    /**
     * User's time zone
     */
    String getTimeZone();
    
    /**
     * Whether user has geo-tagging enabled
     */
    boolean isGeoEnabled();
    
    /**
     * Whether user account is verified
     */
    boolean isVerified();
    
    /**
     * Total number of tweets posted by user
     */
    int getStatusesCount();
    
    /**
     * User's language preference
     */
    String getLang();
    
    /**
     * User's most recent tweet (if available)
     */
    Status getStatus();
    
    /**
     * Whether authenticated user is following this user
     */
    boolean isFollowing();
    
    /**
     * Whether authenticated user has follow requests enabled for this user
     */
    boolean isFollowRequestSent();
    
    /**
     * Whether notifications are enabled for this user's tweets
     */
    boolean isNotifications();
    
    /**
     * Whether authenticated user has blocked this user
     */
    boolean isBlocking();
    
    /**
     * Whether authenticated user has muted this user
     */
    boolean isMuting();
    
    /**
     * User's profile image URL (normal size)
     */
    String getProfileImageURL();
    
    /**
     * User's profile image URL (bigger size)
     */
    String getBiggerProfileImageURL();
    
    /**
     * User's profile image URL (mini size)
     */
    String getMiniProfileImageURL();
    
    /**
     * User's profile image URL (original size)
     */
    String getOriginalProfileImageURL();
    
    /**
     * User's profile image URL over HTTPS
     */
    String getProfileImageURLHttps();
    
    /**
     * User's profile banner URL
     */
    String getProfileBannerURL();
    
    /**
     * User's profile banner URL (mobile size)
     */
    String getProfileBannerMobileURL();
    
    /**
     * User's profile banner URL (iPad size)
     */
    String getProfileBannerIPadURL();
    
    /**
     * User's profile banner URL (web size)
     */
    String getProfileBannerWebURL();
    
    /**
     * User's profile banner URL (300x100 size)
     */
    String getProfileBanner300x100URL();
    
    /**
     * User's profile banner URL (600x200 size)
     */
    String getProfileBanner600x200URL();
    
    /**
     * User's profile banner URL (1500x500 size)
     */
    String getProfileBanner1500x500URL();
    
    /**
     * Whether user uses default profile image
     */
    boolean isDefaultProfileImage();
    
    /**
     * Whether user uses default profile
     */
    boolean isDefaultProfile();
    
    /**
     * Whether user account is a translator
     */
    boolean isTranslator();
    
    /**
     * Whether tweets from this user should be withheld
     */
    String[] getWithheldInCountries();
}

Account Settings Data

Account configuration and preferences.

interface AccountSettings {
    /**
     * Whether sleep time is enabled
     */
    boolean isSleepTimeEnabled();
    
    /**
     * Sleep start time (hour of day)
     */
    String getStartSleepTime();
    
    /**
     * Sleep end time (hour of day)
     */
    String getEndSleepTime();
    
    /**
     * User's time zone information
     */
    TimeZone getTimeZone();
    
    /**
     * Whether location information is enabled
     */
    boolean isGeoEnabled();
    
    /**
     * User's language preference
     */
    String getLanguage();
    
    /**
     * Whether account is discoverable by email
     */
    boolean isDiscoverableByEmail();
    
    /**
     * Whether account is discoverable by mobile phone
     */
    boolean isDiscoverableByMobilePhone();
    
    /**
     * Display settings
     */
    boolean isDisplaySensitiveMedia();
    
    /**
     * Trend location (Where On Earth ID)
     */
    Location[] getTrendLocation();
    
    /**
     * Whether to always use HTTPS
     */
    boolean isAlwaysUseHttps();
}

Install with Tessl CLI

npx tessl i tessl/maven-org-twitter4j--twitter4j-core

docs

core-auth.md

direct-messages.md

favorites.md

index.md

lists.md

places.md

search.md

streaming.md

timelines.md

tweets.md

users.md

tile.json