Skip to content

Latest commit

 

History

History
291 lines (233 loc) · 12.9 KB

BookmarksApi.md

File metadata and controls

291 lines (233 loc) · 12.9 KB

BookmarksApi

All URIs are relative to https://api.twitter.com

Method HTTP request Description
getUsersIdBookmarks GET /2/users/{id}/bookmarks Bookmarks by User
postUsersIdBookmarks POST /2/users/{id}/bookmarks Add Tweet to Bookmarks
usersIdBookmarksDelete DELETE /2/users/{id}/bookmarks/{tweet_id} Remove a bookmarked Tweet

getUsersIdBookmarks

Get2UsersIdBookmarksResponse getUsersIdBookmarks(id).maxResults(maxResults).paginationToken(paginationToken).tweetFields(tweetFields).expansions(expansions).mediaFields(mediaFields).pollFields(pollFields).userFields(userFields).placeFields(placeFields).execute();

Bookmarks by User

Returns Tweet objects that have been bookmarked by 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.BookmarksApi;
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 the next 'page' of results.
    Set<String> tweetFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Tweet fields to display.
    Set<String> expansions = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of fields to expand.
    Set<String> mediaFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Media fields to display.
    Set<String> pollFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Poll fields to display.
    Set<String> userFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of User fields to display.
    Set<String> placeFields = new HashSet<>(Arrays.asList()); // Set<String> | A comma separated list of Place fields to display.
    try {
           Get2UsersIdBookmarksResponse result = apiInstance.bookmarks().getUsersIdBookmarks(id)
            .maxResults(maxResults)
            .paginationToken(paginationToken)
            .tweetFields(tweetFields)
            .expansions(expansions)
            .mediaFields(mediaFields)
            .pollFields(pollFields)
            .userFields(userFields)
            .placeFields(placeFields)
            .execute();
            System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling BookmarksApi#getUsersIdBookmarks");
      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 the next 'page' of results. [optional]
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]
expansions Set<String> A comma separated list of fields to expand. [optional] [enum: attachments.media_keys, attachments.poll_ids, author_id, edit_history_tweet_ids, entities.mentions.username, geo.place_id, in_reply_to_user_id, referenced_tweets.id, referenced_tweets.id.author_id]
mediaFields Set<String> A comma separated list of Media fields to display. [optional] [enum: alt_text, duration_ms, height, media_key, non_public_metrics, organic_metrics, preview_image_url, promoted_metrics, public_metrics, type, url, variants, width]
pollFields Set<String> A comma separated list of Poll fields to display. [optional] [enum: duration_minutes, end_datetime, id, options, voting_status]
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]
placeFields Set<String> A comma separated list of Place fields to display. [optional] [enum: contained_within, country, country_code, full_name, geo, id, name, place_type]

Return type

Get2UsersIdBookmarksResponse

Authorization

OAuth2UserToken

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. -

postUsersIdBookmarks

BookmarkMutationResponse postUsersIdBookmarks(bookmarkAddRequest, id).execute();

Add Tweet to Bookmarks

Adds a Tweet (ID in the body) to the requesting User's (in the path) bookmarks

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.BookmarksApi;
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
    BookmarkAddRequest bookmarkAddRequest = new BookmarkAddRequest(); // BookmarkAddRequest | 
    String id = "id_example"; // String | The ID of the authenticated source User for whom to add bookmarks.
    try {
           BookmarkMutationResponse result = apiInstance.bookmarks().postUsersIdBookmarks(bookmarkAddRequest, id)
            .execute();
            System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling BookmarksApi#postUsersIdBookmarks");
      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
bookmarkAddRequest BookmarkAddRequest
id String The ID of the authenticated source User for whom to add bookmarks.

Return type

BookmarkMutationResponse

Authorization

OAuth2UserToken

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. -

usersIdBookmarksDelete

BookmarkMutationResponse usersIdBookmarksDelete(id, tweetId).execute();

Remove a bookmarked Tweet

Removes a Tweet from the requesting User's bookmarked Tweets.

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.BookmarksApi;
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 whose bookmark is to be removed.
    String tweetId = "tweetId_example"; // String | The ID of the Tweet that the source User is removing from bookmarks.
    try {
           BookmarkMutationResponse result = apiInstance.bookmarks().usersIdBookmarksDelete(id, tweetId)
            .execute();
            System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling BookmarksApi#usersIdBookmarksDelete");
      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 whose bookmark is to be removed.
tweetId String The ID of the Tweet that the source User is removing from bookmarks.

Return type

BookmarkMutationResponse

Authorization

OAuth2UserToken

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. -