or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-auth.mddirect-messages.mdfavorites.mdindex.mdlists.mdplaces.mdsearch.mdstreaming.mdtimelines.mdtweets.mdusers.md

users.mddocs/

0

# User Management

1

2

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

3

4

## User Information

5

6

### User Profile Access

7

8

Retrieve detailed user profile information.

9

10

```java { .api }

11

interface UsersResources {

12

/**

13

* Get user profile by screen name

14

* @param screenName User's screen name (without @)

15

* @return User profile information

16

*/

17

User showUser(String screenName) throws TwitterException;

18

19

/**

20

* Get user profile by user ID

21

* @param userId User's numeric ID

22

* @return User profile information

23

*/

24

User showUser(long userId) throws TwitterException;

25

26

/**

27

* Get multiple user profiles by IDs

28

* @param ids Array of user IDs (max 100)

29

* @return List of user profiles

30

*/

31

ResponseList<User> lookupUsers(long... ids) throws TwitterException;

32

33

/**

34

* Get multiple user profiles by screen names

35

* @param screenNames Array of screen names (max 100)

36

* @return List of user profiles

37

*/

38

ResponseList<User> lookupUsers(String... screenNames) throws TwitterException;

39

}

40

```

41

42

**Usage Examples:**

43

44

```java

45

TwitterV1 v1 = twitter.v1();

46

47

// Get user by screen name

48

User user = v1.users().showUser("twitterapi");

49

System.out.println("Name: " + user.getName());

50

System.out.println("Followers: " + user.getFollowersCount());

51

52

// Get user by ID

53

User userById = v1.users().showUser(783214L);

54

55

// Get multiple users

56

ResponseList<User> users = v1.users().lookupUsers("twitterapi", "twitter", "twittereng");

57

for (User u : users) {

58

System.out.println(u.getScreenName() + " has " + u.getFollowersCount() + " followers");

59

}

60

61

// Lookup users by IDs

62

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

63

```

64

65

### User Search

66

67

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

68

69

```java { .api }

70

interface UsersResources {

71

/**

72

* Search for users matching query

73

* @param query Search query (name, bio keywords, etc.)

74

* @param page Page number for pagination (1-indexed)

75

* @return List of matching users (max 20 per page)

76

*/

77

ResponseList<User> searchUsers(String query, int page) throws TwitterException;

78

}

79

```

80

81

**Usage Example:**

82

83

```java

84

// Search for users

85

ResponseList<User> searchResults = v1.users().searchUsers("java developer", 1);

86

for (User user : searchResults) {

87

System.out.println("@" + user.getScreenName() + ": " + user.getDescription());

88

}

89

90

// Paginate through search results

91

for (int page = 1; page <= 5; page++) {

92

ResponseList<User> pageResults = v1.users().searchUsers("twitter api", page);

93

if (pageResults.isEmpty()) break;

94

95

System.out.println("Page " + page + ":");

96

for (User user : pageResults) {

97

System.out.println(" " + user.getScreenName());

98

}

99

}

100

```

101

102

## Account Management

103

104

### Account Verification

105

106

Verify credentials and get authenticated user's information.

107

108

```java { .api }

109

interface UsersResources {

110

/**

111

* Verify credentials and get authenticated user's profile

112

* @return Authenticated user's profile

113

*/

114

User verifyCredentials() throws TwitterException;

115

}

116

```

117

118

**Usage Example:**

119

120

```java

121

// Verify credentials

122

User me = v1.users().verifyCredentials();

123

System.out.println("Logged in as: @" + me.getScreenName());

124

System.out.println("Account created: " + me.getCreatedAt());

125

System.out.println("Verified: " + me.isVerified());

126

```

127

128

### Profile Updates

129

130

Update authenticated user's profile information.

131

132

```java { .api }

133

interface UsersResources {

134

/**

135

* Update profile information

136

* @param name Display name (max 50 characters)

137

* @param url Website URL

138

* @param location Location string

139

* @param description Bio/description (max 160 characters)

140

* @return Updated user profile

141

*/

142

User updateProfile(String name, String url, String location, String description)

143

throws TwitterException;

144

145

/**

146

* Update profile image

147

* @param image Profile image file

148

* @return Updated user profile

149

*/

150

User updateProfileImage(File image) throws TwitterException;

151

152

/**

153

* Update profile image from input stream

154

* @param image Profile image data stream

155

* @return Updated user profile

156

*/

157

User updateProfileImage(InputStream image) throws TwitterException;

158

159

/**

160

* Update profile banner image

161

* @param image Banner image file

162

*/

163

void updateProfileBanner(File image) throws TwitterException;

164

165

/**

166

* Update profile banner from input stream

167

* @param image Banner image data stream

168

*/

169

void updateProfileBanner(InputStream image) throws TwitterException;

170

171

/**

172

* Remove profile banner

173

*/

174

void removeProfileBanner() throws TwitterException;

175

}

176

```

177

178

**Usage Examples:**

179

180

```java

181

// Update profile information

182

User updatedProfile = v1.users().updateProfile(

183

"John Developer",

184

"https://example.com",

185

"San Francisco, CA",

186

"Software developer passionate about Java and Twitter API"

187

);

188

189

// Update profile image

190

File profileImage = new File("profile.jpg");

191

User profileWithNewImage = v1.users().updateProfileImage(profileImage);

192

193

// Update banner

194

File banner = new File("banner.jpg");

195

v1.users().updateProfileBanner(banner);

196

197

// Remove banner

198

v1.users().removeProfileBanner();

199

```

200

201

### Account Settings

202

203

Manage account preferences and settings.

204

205

```java { .api }

206

interface UsersResources {

207

/**

208

* Get current account settings

209

* @return Account settings and preferences

210

*/

211

AccountSettings getAccountSettings() throws TwitterException;

212

213

/**

214

* Update account settings

215

* @param trendLocationWoeid Where On Earth ID for trend location

216

* @param sleepTimeEnabled Enable sleep time restrictions

217

* @param startSleepTime Sleep start time (0-23)

218

* @param endSleepTime Sleep end time (0-23)

219

* @param timeZone Time zone identifier

220

* @param lang Language preference

221

* @return Updated account settings

222

*/

223

AccountSettings updateAccountSettings(Integer trendLocationWoeid,

224

Boolean sleepTimeEnabled,

225

Integer startSleepTime,

226

Integer endSleepTime,

227

String timeZone,

228

String lang) throws TwitterException;

229

230

/**

231

* Update direct message privacy settings

232

* @param allowDmsFrom "all", "following", or "none"

233

* @return Updated account settings

234

*/

235

AccountSettings updateAllowDmsFrom(String allowDmsFrom) throws TwitterException;

236

}

237

```

238

239

**Usage Example:**

240

241

```java

242

// Get current settings

243

AccountSettings settings = v1.users().getAccountSettings();

244

System.out.println("Language: " + settings.getLanguage());

245

System.out.println("Time zone: " + settings.getTimeZone().getName());

246

247

// Update settings

248

AccountSettings updated = v1.users().updateAccountSettings(

249

1, // WOEID for worldwide trends

250

true, // Enable sleep time

251

22, // Sleep from 10 PM

252

6, // Until 6 AM

253

"America/Los_Angeles",

254

"en"

255

);

256

257

// Update DM settings

258

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

259

```

260

261

## Blocking and Muting

262

263

### Block Management

264

265

Block and unblock users to prevent interactions.

266

267

```java { .api }

268

interface UsersResources {

269

/**

270

* Get list of blocked users

271

* @return Paginated list of blocked users

272

*/

273

PagableResponseList<User> getBlocksList() throws TwitterException;

274

275

/**

276

* Get list of blocked users with cursor pagination

277

* @param cursor Pagination cursor (-1 for first page)

278

* @return Paginated list of blocked users

279

*/

280

PagableResponseList<User> getBlocksList(long cursor) throws TwitterException;

281

282

/**

283

* Get blocked user IDs

284

* @return IDs of blocked users

285

*/

286

IDs getBlocksIDs() throws TwitterException;

287

288

/**

289

* Get blocked user IDs with cursor pagination

290

* @param cursor Pagination cursor (-1 for first page)

291

* @return IDs of blocked users

292

*/

293

IDs getBlocksIDs(long cursor) throws TwitterException;

294

295

/**

296

* Block a user by user ID

297

* @param userId User ID to block

298

* @return Blocked user profile

299

*/

300

User createBlock(long userId) throws TwitterException;

301

302

/**

303

* Block a user by screen name

304

* @param screenName Screen name to block

305

* @return Blocked user profile

306

*/

307

User createBlock(String screenName) throws TwitterException;

308

309

/**

310

* Unblock a user by user ID

311

* @param userId User ID to unblock

312

* @return Unblocked user profile

313

*/

314

User destroyBlock(long userId) throws TwitterException;

315

316

/**

317

* Unblock a user by screen name

318

* @param screenName Screen name to unblock

319

* @return Unblocked user profile

320

*/

321

User destroyBlock(String screenName) throws TwitterException;

322

}

323

```

324

325

**Usage Examples:**

326

327

```java

328

// Get blocked users

329

PagableResponseList<User> blocked = v1.users().getBlocksList();

330

for (User user : blocked) {

331

System.out.println("Blocked: @" + user.getScreenName());

332

}

333

334

// Block a user

335

User blockedUser = v1.users().createBlock("spamaccount");

336

System.out.println("Blocked @" + blockedUser.getScreenName());

337

338

// Unblock a user

339

User unblockedUser = v1.users().destroyBlock("spamaccount");

340

System.out.println("Unblocked @" + unblockedUser.getScreenName());

341

342

// Get blocked user IDs only (more efficient for large lists)

343

IDs blockedIds = v1.users().getBlocksIDs();

344

System.out.println("Blocked " + blockedIds.getIDs().length + " users");

345

```

346

347

### Mute Management

348

349

Mute and unmute users to hide their tweets without blocking.

350

351

```java { .api }

352

interface UsersResources {

353

/**

354

* Get list of muted users with cursor pagination

355

* @param cursor Pagination cursor (-1 for first page)

356

* @return Paginated list of muted users

357

*/

358

PagableResponseList<User> getMutesList(long cursor) throws TwitterException;

359

360

/**

361

* Get muted user IDs with cursor pagination

362

* @param cursor Pagination cursor (-1 for first page)

363

* @return IDs of muted users

364

*/

365

IDs getMutesIDs(long cursor) throws TwitterException;

366

367

/**

368

* Mute a user by user ID

369

* @param userId User ID to mute

370

* @return Muted user profile

371

*/

372

User createMute(long userId) throws TwitterException;

373

374

/**

375

* Mute a user by screen name

376

* @param screenName Screen name to mute

377

* @return Muted user profile

378

*/

379

User createMute(String screenName) throws TwitterException;

380

381

/**

382

* Unmute a user by user ID

383

* @param userId User ID to unmute

384

* @return Unmuted user profile

385

*/

386

User destroyMute(long userId) throws TwitterException;

387

388

/**

389

* Unmute a user by screen name

390

* @param screenName Screen name to unmute

391

* @return Unmuted user profile

392

*/

393

User destroyMute(String screenName) throws TwitterException;

394

}

395

```

396

397

**Usage Examples:**

398

399

```java

400

// Get muted users

401

PagableResponseList<User> muted = v1.users().getMutesList(-1);

402

for (User user : muted) {

403

System.out.println("Muted: @" + user.getScreenName());

404

}

405

406

// Mute a user

407

User mutedUser = v1.users().createMute("noisyaccount");

408

System.out.println("Muted @" + mutedUser.getScreenName());

409

410

// Unmute a user

411

User unmutedUser = v1.users().destroyMute("noisyaccount");

412

System.out.println("Unmuted @" + unmutedUser.getScreenName());

413

```

414

415

## Contributors and Contributees

416

417

### Contributor Management

418

419

Manage contributor relationships for team accounts.

420

421

```java { .api }

422

interface UsersResources {

423

/**

424

* Get users that the specified user contributes to

425

* @param userId User ID

426

* @return List of contributee accounts

427

*/

428

ResponseList<User> getContributees(long userId) throws TwitterException;

429

430

/**

431

* Get users that the specified user contributes to by screen name

432

* @param screenName Screen name

433

* @return List of contributee accounts

434

*/

435

ResponseList<User> getContributees(String screenName) throws TwitterException;

436

437

/**

438

* Get users that contribute to the specified account

439

* @param userId User ID

440

* @return List of contributor accounts

441

*/

442

ResponseList<User> getContributors(long userId) throws TwitterException;

443

444

/**

445

* Get users that contribute to the specified account by screen name

446

* @param screenName Screen name

447

* @return List of contributor accounts

448

*/

449

ResponseList<User> getContributors(String screenName) throws TwitterException;

450

}

451

```

452

453

**Usage Examples:**

454

455

```java

456

// Get accounts this user contributes to

457

ResponseList<User> contributees = v1.users().getContributees("teamaccount");

458

for (User account : contributees) {

459

System.out.println("Contributes to: @" + account.getScreenName());

460

}

461

462

// Get contributors to this account

463

ResponseList<User> contributors = v1.users().getContributors("teamaccount");

464

for (User contributor : contributors) {

465

System.out.println("Contributor: @" + contributor.getScreenName());

466

}

467

```

468

469

## User Data Model

470

471

### User Profile Information

472

473

Complete user profile data structure.

474

475

```java { .api }

476

interface User extends TwitterResponse {

477

/**

478

* User's unique identifier

479

*/

480

long getId();

481

482

/**

483

* User's display name

484

*/

485

String getName();

486

487

/**

488

* User's email address (whitelisted apps only)

489

*/

490

String getEmail();

491

492

/**

493

* User's screen name/handle (without @)

494

*/

495

String getScreenName();

496

497

/**

498

* User's location

499

*/

500

String getLocation();

501

502

/**

503

* User's bio/description

504

*/

505

String getDescription();

506

507

/**

508

* Whether user allows contributors

509

*/

510

boolean isContributorsEnabled();

511

512

/**

513

* User's website URL

514

*/

515

String getURL();

516

517

/**

518

* Whether user's tweets are protected

519

*/

520

boolean isProtected();

521

522

/**

523

* Number of followers

524

*/

525

int getFollowersCount();

526

527

/**

528

* Number of accounts being followed

529

*/

530

int getFriendsCount();

531

532

/**

533

* Number of lists user is member of

534

*/

535

int getListedCount();

536

537

/**

538

* Account creation date

539

*/

540

LocalDateTime getCreatedAt();

541

542

/**

543

* Number of tweets favorited by user

544

*/

545

int getFavouritesCount();

546

547

/**

548

* User's UTC offset in seconds

549

*/

550

int getUtcOffset();

551

552

/**

553

* User's time zone

554

*/

555

String getTimeZone();

556

557

/**

558

* Whether user has geo-tagging enabled

559

*/

560

boolean isGeoEnabled();

561

562

/**

563

* Whether user account is verified

564

*/

565

boolean isVerified();

566

567

/**

568

* Total number of tweets posted by user

569

*/

570

int getStatusesCount();

571

572

/**

573

* User's language preference

574

*/

575

String getLang();

576

577

/**

578

* User's most recent tweet (if available)

579

*/

580

Status getStatus();

581

582

/**

583

* Whether authenticated user is following this user

584

*/

585

boolean isFollowing();

586

587

/**

588

* Whether authenticated user has follow requests enabled for this user

589

*/

590

boolean isFollowRequestSent();

591

592

/**

593

* Whether notifications are enabled for this user's tweets

594

*/

595

boolean isNotifications();

596

597

/**

598

* Whether authenticated user has blocked this user

599

*/

600

boolean isBlocking();

601

602

/**

603

* Whether authenticated user has muted this user

604

*/

605

boolean isMuting();

606

607

/**

608

* User's profile image URL (normal size)

609

*/

610

String getProfileImageURL();

611

612

/**

613

* User's profile image URL (bigger size)

614

*/

615

String getBiggerProfileImageURL();

616

617

/**

618

* User's profile image URL (mini size)

619

*/

620

String getMiniProfileImageURL();

621

622

/**

623

* User's profile image URL (original size)

624

*/

625

String getOriginalProfileImageURL();

626

627

/**

628

* User's profile image URL over HTTPS

629

*/

630

String getProfileImageURLHttps();

631

632

/**

633

* User's profile banner URL

634

*/

635

String getProfileBannerURL();

636

637

/**

638

* User's profile banner URL (mobile size)

639

*/

640

String getProfileBannerMobileURL();

641

642

/**

643

* User's profile banner URL (iPad size)

644

*/

645

String getProfileBannerIPadURL();

646

647

/**

648

* User's profile banner URL (web size)

649

*/

650

String getProfileBannerWebURL();

651

652

/**

653

* User's profile banner URL (300x100 size)

654

*/

655

String getProfileBanner300x100URL();

656

657

/**

658

* User's profile banner URL (600x200 size)

659

*/

660

String getProfileBanner600x200URL();

661

662

/**

663

* User's profile banner URL (1500x500 size)

664

*/

665

String getProfileBanner1500x500URL();

666

667

/**

668

* Whether user uses default profile image

669

*/

670

boolean isDefaultProfileImage();

671

672

/**

673

* Whether user uses default profile

674

*/

675

boolean isDefaultProfile();

676

677

/**

678

* Whether user account is a translator

679

*/

680

boolean isTranslator();

681

682

/**

683

* Whether tweets from this user should be withheld

684

*/

685

String[] getWithheldInCountries();

686

}

687

```

688

689

### Account Settings Data

690

691

Account configuration and preferences.

692

693

```java { .api }

694

interface AccountSettings {

695

/**

696

* Whether sleep time is enabled

697

*/

698

boolean isSleepTimeEnabled();

699

700

/**

701

* Sleep start time (hour of day)

702

*/

703

String getStartSleepTime();

704

705

/**

706

* Sleep end time (hour of day)

707

*/

708

String getEndSleepTime();

709

710

/**

711

* User's time zone information

712

*/

713

TimeZone getTimeZone();

714

715

/**

716

* Whether location information is enabled

717

*/

718

boolean isGeoEnabled();

719

720

/**

721

* User's language preference

722

*/

723

String getLanguage();

724

725

/**

726

* Whether account is discoverable by email

727

*/

728

boolean isDiscoverableByEmail();

729

730

/**

731

* Whether account is discoverable by mobile phone

732

*/

733

boolean isDiscoverableByMobilePhone();

734

735

/**

736

* Display settings

737

*/

738

boolean isDisplaySensitiveMedia();

739

740

/**

741

* Trend location (Where On Earth ID)

742

*/

743

Location[] getTrendLocation();

744

745

/**

746

* Whether to always use HTTPS

747

*/

748

boolean isAlwaysUseHttps();

749

}

750

```