UsersApi
October 3, 2022 ยท View on GitHub
All URIs are relative to https://api.twitter.com
| Method | HTTP request | Description |
|---|---|---|
| findMyUser | GET /2/users/me | User lookup me |
| findUserById | GET /2/users/{id} | User lookup by ID |
| findUserByUsername | GET /2/users/by/username/{username} | User lookup by username |
| findUsersById | GET /2/users | User lookup by IDs |
| findUsersByUsername | GET /2/users/by | User lookup by usernames |
| listGetFollowers | GET /2/lists/{id}/followers | Returns User objects that follow a List by the provided List ID |
| listGetMembers | GET /2/lists/{id}/members | Returns User objects that are members of a List by the provided List ID. |
| tweetsIdLikingUsers | GET /2/tweets/{id}/liking_users | Returns User objects that have liked the provided Tweet ID |
| tweetsIdRetweetingUsers | GET /2/tweets/{id}/retweeted_by | Returns User objects that have retweeted the provided Tweet ID |
| usersIdBlock | POST /2/users/{id}/blocking | Block User by User ID |
| usersIdBlocking | GET /2/users/{id}/blocking | Returns User objects that are blocked by provided User ID |
| usersIdFollow | POST /2/users/{id}/following | Follow User |
| usersIdFollowers | GET /2/users/{id}/followers | Followers by User ID |
| usersIdFollowing | GET /2/users/{id}/following | Following by User ID |
| usersIdMute | POST /2/users/{id}/muting | Mute User by User ID. |
| usersIdMuting | GET /2/users/{id}/muting | Returns User objects that are muted by the provided User ID |
| usersIdUnblock | DELETE /2/users/{source_user_id}/blocking/{target_user_id} | Unblock User by User ID |
| usersIdUnfollow | DELETE /2/users/{source_user_id}/following/{target_user_id} | Unfollow User |
| usersIdUnmute | DELETE /2/users/{source_user_id}/muting/{target_user_id} | Unmute User by User ID |
findMyUser
Get2UsersMeResponse findMyUser().userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
User lookup me
This endpoint returns information about the requesting User.
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersMeResponse result = apiInstance.users().findMyUser()
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#findMyUser");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
findUserById
Get2UsersIdResponse findUserById(id).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
User lookup by ID
This endpoint returns information about a User. Specify User by ID.
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "2244994945"; // String | The ID of the User to lookup.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersIdResponse result = apiInstance.users().findUserById(id)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#findUserById");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The ID of the User to lookup. | |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
findUserByUsername
Get2UsersByUsernameUsernameResponse findUserByUsername(username).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
User lookup by username
This endpoint returns information about a User. Specify User by username.
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String username = "TwitterDev"; // String | A username.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersByUsernameUsernameResponse result = apiInstance.users().findUserByUsername(username)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#findUserByUsername");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| username | String | A username. | |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Get2UsersByUsernameUsernameResponse
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
findUsersById
Get2UsersResponse findUsersById(ids).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
User lookup by IDs
This endpoint returns information about Users. Specify Users by their ID.
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
List<String> ids = Arrays.asList(); // List<String> | A list of User IDs, comma-separated. You can specify up to 100 IDs.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersResponse result = apiInstance.users().findUsersById(ids)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#findUsersById");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| ids | List<String> | A list of User IDs, comma-separated. You can specify up to 100 IDs. | |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
findUsersByUsername
Get2UsersByResponse findUsersByUsername(usernames).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
User lookup by usernames
This endpoint returns information about Users. Specify Users by their username.
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
List<String> usernames = Arrays.asList(); // List<String> | A list of usernames, comma-separated.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersByResponse result = apiInstance.users().findUsersByUsername(usernames)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#findUsersByUsername");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| usernames | List<String> | A list of usernames, comma-separated. | |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
listGetFollowers
Get2ListsIdFollowersResponse listGetFollowers(id).maxResults(maxResults).paginationToken(paginationToken).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
Returns User objects that follow a List by the provided List ID
Returns a list of Users that follow a List by the provided List ID
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "id_example"; // String | The ID of the List.
Integer maxResults = 100; // Integer | The maximum number of results.
String paginationToken = "paginationToken_example"; // String | This parameter is used to get a specified 'page' of results.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2ListsIdFollowersResponse result = apiInstance.users().listGetFollowers(id)
.maxResults(maxResults)
.paginationToken(paginationToken)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#listGetFollowers");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The ID of the List. | |
| maxResults | Integer | The maximum number of results. | [optional] [default to 100] |
| paginationToken | String | This parameter is used to get a specified 'page' of results. | [optional] |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
listGetMembers
Get2ListsIdMembersResponse listGetMembers(id).maxResults(maxResults).paginationToken(paginationToken).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
Returns User objects that are members of a List by the provided List ID.
Returns a list of Users that are members of a List by the provided List ID.
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "id_example"; // String | The ID of the List.
Integer maxResults = 100; // Integer | The maximum number of results.
String paginationToken = "paginationToken_example"; // String | This parameter is used to get a specified 'page' of results.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2ListsIdMembersResponse result = apiInstance.users().listGetMembers(id)
.maxResults(maxResults)
.paginationToken(paginationToken)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#listGetMembers");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The ID of the List. | |
| maxResults | Integer | The maximum number of results. | [optional] [default to 100] |
| paginationToken | String | This parameter is used to get a specified 'page' of results. | [optional] |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
tweetsIdLikingUsers
Get2TweetsIdLikingUsersResponse tweetsIdLikingUsers(id).maxResults(maxResults).paginationToken(paginationToken).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
Returns User objects that have liked the provided Tweet ID
Returns a list of Users that have liked the provided Tweet ID
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "id_example"; // String | A single Tweet ID.
Integer maxResults = 100; // Integer | The maximum number of results.
String paginationToken = "paginationToken_example"; // String | This parameter is used to get the next 'page' of results.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2TweetsIdLikingUsersResponse result = apiInstance.users().tweetsIdLikingUsers(id)
.maxResults(maxResults)
.paginationToken(paginationToken)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#tweetsIdLikingUsers");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | A single Tweet ID. | |
| maxResults | Integer | The maximum number of results. | [optional] [default to 100] |
| paginationToken | String | This parameter is used to get the next 'page' of results. | [optional] |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Get2TweetsIdLikingUsersResponse
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
tweetsIdRetweetingUsers
Get2TweetsIdRetweetedByResponse tweetsIdRetweetingUsers(id).maxResults(maxResults).paginationToken(paginationToken).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
Returns User objects that have retweeted the provided Tweet ID
Returns a list of Users that have retweeted the provided Tweet ID
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "id_example"; // String | A single Tweet ID.
Integer maxResults = 100; // Integer | The maximum number of results.
String paginationToken = "paginationToken_example"; // String | This parameter is used to get the next 'page' of results.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2TweetsIdRetweetedByResponse result = apiInstance.users().tweetsIdRetweetingUsers(id)
.maxResults(maxResults)
.paginationToken(paginationToken)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#tweetsIdRetweetingUsers");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | A single Tweet ID. | |
| maxResults | Integer | The maximum number of results. | [optional] [default to 100] |
| paginationToken | String | This parameter is used to get the next 'page' of results. | [optional] |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Get2TweetsIdRetweetedByResponse
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdBlock
BlockUserMutationResponse usersIdBlock(blockUserRequest, id).execute();
Block User by User ID
Causes the User (in the path) to block the target User. The User (in the path) must match the User context authorizing the request
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
BlockUserRequest blockUserRequest = new BlockUserRequest(); // BlockUserRequest |
String id = "id_example"; // String | The ID of the authenticated source User that is requesting to block the target User.
try {
BlockUserMutationResponse result = apiInstance.users().usersIdBlock(blockUserRequest, id)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdBlock");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| blockUserRequest | BlockUserRequest | ||
| id | String | The ID of the authenticated source User that is requesting to block the target User. |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdBlocking
Get2UsersIdBlockingResponse usersIdBlocking(id).maxResults(maxResults).paginationToken(paginationToken).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
Returns User objects that are blocked by provided User ID
Returns a list of Users that are blocked by the provided User ID
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "id_example"; // String | The ID of the authenticated source User for whom to return results.
Integer maxResults = 56; // Integer | The maximum number of results.
String paginationToken = "paginationToken_example"; // String | This parameter is used to get a specified 'page' of results.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersIdBlockingResponse result = apiInstance.users().usersIdBlocking(id)
.maxResults(maxResults)
.paginationToken(paginationToken)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdBlocking");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The ID of the authenticated source User for whom to return results. | |
| maxResults | Integer | The maximum number of results. | [optional] |
| paginationToken | String | This parameter is used to get a specified 'page' of results. | [optional] |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdFollow
UsersFollowingCreateResponse usersIdFollow(id).usersFollowingCreateRequest(usersFollowingCreateRequest).execute();
Follow User
Causes the User(in the path) to follow, or โrequest to followโ for protected Users, the target User. The User(in the path) must match the User context authorizing the request
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
UsersFollowingCreateRequest usersFollowingCreateRequest = new UsersFollowingCreateRequest(); // UsersFollowingCreateRequest |
String id = "id_example"; // String | The ID of the authenticated source User that is requesting to follow the target User.
try {
UsersFollowingCreateResponse result = apiInstance.users().usersIdFollow(id)
.usersFollowingCreateRequest(usersFollowingCreateRequest)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdFollow");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| usersFollowingCreateRequest | UsersFollowingCreateRequest | [optional] | |
| id | String | The ID of the authenticated source User that is requesting to follow the target User. |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdFollowers
Get2UsersIdFollowersResponse usersIdFollowers(id).maxResults(maxResults).paginationToken(paginationToken).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
Followers by User ID
Returns a list of Users who are followers of the specified User ID.
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "2244994945"; // String | The ID of the User to lookup.
Integer maxResults = 56; // Integer | The maximum number of results.
String paginationToken = "paginationToken_example"; // String | This parameter is used to get a specified 'page' of results.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersIdFollowersResponse result = apiInstance.users().usersIdFollowers(id)
.maxResults(maxResults)
.paginationToken(paginationToken)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdFollowers");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The ID of the User to lookup. | |
| maxResults | Integer | The maximum number of results. | [optional] |
| paginationToken | String | This parameter is used to get a specified 'page' of results. | [optional] |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdFollowing
Get2UsersIdFollowingResponse usersIdFollowing(id).maxResults(maxResults).paginationToken(paginationToken).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
Following by User ID
Returns a list of Users that are being followed by the provided User ID
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure HTTP bearer authorization:
// TwitterCredentialsBearer credentials = new TwitterCredentialsBearer(System.getenv("TWITTER_BEARER_TOKEN"));
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "2244994945"; // String | The ID of the User to lookup.
Integer maxResults = 56; // Integer | The maximum number of results.
String paginationToken = "paginationToken_example"; // String | This parameter is used to get a specified 'page' of results.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersIdFollowingResponse result = apiInstance.users().usersIdFollowing(id)
.maxResults(maxResults)
.paginationToken(paginationToken)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdFollowing");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The ID of the User to lookup. | |
| maxResults | Integer | The maximum number of results. | [optional] |
| paginationToken | String | This parameter is used to get a specified 'page' of results. | [optional] |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
BearerToken, OAuth2UserToken, UserToken
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdMute
MuteUserMutationResponse usersIdMute(id).muteUserRequest(muteUserRequest).execute();
Mute User by User ID.
Causes the User (in the path) to mute the target User. The User (in the path) must match the User context authorizing the request.
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
MuteUserRequest muteUserRequest = new MuteUserRequest(); // MuteUserRequest |
String id = "id_example"; // String | The ID of the authenticated source User that is requesting to mute the target User.
try {
MuteUserMutationResponse result = apiInstance.users().usersIdMute(id)
.muteUserRequest(muteUserRequest)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdMute");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| muteUserRequest | MuteUserRequest | [optional] | |
| id | String | The ID of the authenticated source User that is requesting to mute the target User. |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdMuting
Get2UsersIdMutingResponse usersIdMuting(id).maxResults(maxResults).paginationToken(paginationToken).userFields(userFields).expansions(expansions).tweetFields(tweetFields).execute();
Returns User objects that are muted by the provided User ID
Returns a list of Users that are muted by the provided User ID
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String id = "id_example"; // String | The ID of the authenticated source User for whom to return results.
Integer maxResults = 100; // Integer | The maximum number of results.
String paginationToken = "paginationToken_example"; // String | This parameter is used to get the next 'page' of results.
Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
try {
Get2UsersIdMutingResponse result = apiInstance.users().usersIdMuting(id)
.maxResults(maxResults)
.paginationToken(paginationToken)
.userFields(userFields)
.expansions(expansions)
.tweetFields(tweetFields)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdMuting");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The ID of the authenticated source User for whom to return results. | |
| maxResults | Integer | The maximum number of results. | [optional] [default to 100] |
| paginationToken | String | This parameter is used to get the next 'page' of results. | [optional] |
| userFields | Set<String> | A comma separated list of User fields to display. | [optional] [enum: created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld] |
| expansions | Set<String> | A comma separated list of fields to expand. | [optional] [enum: pinned_tweet_id] |
| tweetFields | Set<String> | A comma separated list of Tweet fields to display. | [optional] [enum: attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, edit_history_tweet_ids, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, organic_metrics, possibly_sensitive, promoted_metrics, public_metrics, referenced_tweets, reply_settings, source, text, withheld] |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdUnblock
BlockUserMutationResponse usersIdUnblock(sourceUserId, targetUserId).execute();
Unblock User by User ID
Causes the source User to unblock the target User. The source User must match the User context authorizing the request
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String sourceUserId = "sourceUserId_example"; // String | The ID of the authenticated source User that is requesting to unblock the target User.
String targetUserId = "targetUserId_example"; // String | The ID of the User that the source User is requesting to unblock.
try {
BlockUserMutationResponse result = apiInstance.users().usersIdUnblock(sourceUserId, targetUserId)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdUnblock");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| sourceUserId | String | The ID of the authenticated source User that is requesting to unblock the target User. | |
| targetUserId | String | The ID of the User that the source User is requesting to unblock. |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdUnfollow
UsersFollowingDeleteResponse usersIdUnfollow(sourceUserId, targetUserId).execute();
Unfollow User
Causes the source User to unfollow the target User. The source User must match the User context authorizing the request
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String sourceUserId = "sourceUserId_example"; // String | The ID of the authenticated source User that is requesting to unfollow the target User.
String targetUserId = "targetUserId_example"; // String | The ID of the User that the source User is requesting to unfollow.
try {
UsersFollowingDeleteResponse result = apiInstance.users().usersIdUnfollow(sourceUserId, targetUserId)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdUnfollow");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| sourceUserId | String | The ID of the authenticated source User that is requesting to unfollow the target User. | |
| targetUserId | String | The ID of the User that the source User is requesting to unfollow. |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |
usersIdUnmute
MuteUserMutationResponse usersIdUnmute(sourceUserId, targetUserId).execute();
Unmute User by User ID
Causes the source User to unmute the target User. The source User must match the User context authorizing the request
Example
// Import classes:
import com.twitter.clientlib.ApiClient;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.Configuration;
import com.twitter.clientlib.auth.*;
import com.twitter.clientlib.model.*;
import com.twitter.clientlib.TwitterCredentialsOAuth2;
import com.twitter.clientlib.TwitterCredentialsBearer;
import com.twitter.clientlib.api.TwitterApi;
import com.twitter.clientlib.api.UsersApi;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
// Set the credentials based on the API's "security" tag values.
// Check the API definition in https://api.twitter.com/2/openapi.json
// When multiple options exist, the SDK supports only "OAuth2UserToken" or "BearerToken"
// Uncomment and set the credentials configuration
// Configure OAuth2 access token for authorization:
// TwitterCredentialsOAuth2 credentials = new TwitterCredentialsOAuth2(System.getenv("TWITTER_OAUTH2_CLIENT_ID"),
// System.getenv("TWITTER_OAUTH2_CLIENT_SECRET"),
// System.getenv("TWITTER_OAUTH2_ACCESS_TOKEN"),
// System.getenv("TWITTER_OAUTH2_REFRESH_TOKEN"));
TwitterApi apiInstance = new TwitterApi(credentials);
// Set the params values
String sourceUserId = "sourceUserId_example"; // String | The ID of the authenticated source User that is requesting to unmute the target User.
String targetUserId = "targetUserId_example"; // String | The ID of the User that the source User is requesting to unmute.
try {
MuteUserMutationResponse result = apiInstance.users().usersIdUnmute(sourceUserId, targetUserId)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsersApi#usersIdUnmute");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| sourceUserId | String | The ID of the authenticated source User that is requesting to unmute the target User. | |
| targetUserId | String | The ID of the User that the source User is requesting to unmute. |
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json, application/problem+json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | The request has succeeded. | - |
| 0 | The request has failed. | - |