R API client for twitter

Twitter API v2 available endpoints

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI spec from a remote server, you can easily generate an API client.

  • API version: 2.49
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.RClientCodegen For more information, please visit https://developer.twitter.com/

Installation

Prerequisites

Install the dependencies

install.packages("jsonlite")
install.packages("httr")
install.packages("base64enc")

Build the package

git clone https://github.com/wing328/r-twitter
cd r-twitter
R CMD build .
R CMD check twitter_1.0.0.tar.gz --no-manual
R CMD INSTALL --preclean twitter_1.0.0.tar.gz

Install the package

install.packages("twitter")

To install directly from Github, use devtools:

install.packages("devtools")
library(devtools)
install_github("wing328/r-twitter")

To install the package from a local file:

install.packages("twitter_1.0.0.tar.gz", repos = NULL, type = "source")

Usage

library(twitter)

Reformat code

To reformat code using styler, please run the following in the R console:

install.packages("remotes")
remotes::install_github("r-lib/styler@v1.7.0.9003")
library("styler")
style_dir()

Documentation for API Endpoints

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

Class Method HTTP request Description
BookmarksApi get_users_id_bookmarks GET /2/users/{id}/bookmarks Bookmarks by User
BookmarksApi post_users_id_bookmarks POST /2/users/{id}/bookmarks Add Tweet to Bookmarks
BookmarksApi users_id_bookmarks_delete DELETE /2/users/{id}/bookmarks/{tweet_id} Remove a bookmarked Tweet
ComplianceApi create_batch_compliance_job POST /2/compliance/jobs Create compliance job
ComplianceApi get_batch_compliance_job GET /2/compliance/jobs/{id} Get Compliance Job
ComplianceApi get_tweets_compliance_stream GET /2/tweets/compliance/stream Tweets Compliance stream
ComplianceApi get_users_compliance_stream GET /2/users/compliance/stream Users Compliance stream
ComplianceApi list_batch_compliance_jobs GET /2/compliance/jobs List Compliance Jobs
GeneralApi get_open_api_spec GET /2/openapi.json Returns the OpenAPI Specification document.
ListsApi get_user_list_memberships GET /2/users/{id}/list_memberships Get a User's List Memberships
ListsApi list_add_member POST /2/lists/{id}/members Add a List member
ListsApi list_id_create POST /2/lists Create List
ListsApi list_id_delete DELETE /2/lists/{id} Delete List
ListsApi list_id_get GET /2/lists/{id} List lookup by List ID.
ListsApi list_id_update PUT /2/lists/{id} Update List.
ListsApi list_remove_member DELETE /2/lists/{id}/members/{user_id} Remove a List member
ListsApi list_user_follow POST /2/users/{id}/followed_lists Follow a List
ListsApi list_user_owned_lists GET /2/users/{id}/owned_lists Get a User's Owned Lists.
ListsApi list_user_pin POST /2/users/{id}/pinned_lists Pin a List
ListsApi list_user_pinned_lists GET /2/users/{id}/pinned_lists Get a User's Pinned Lists
ListsApi list_user_unfollow DELETE /2/users/{id}/followed_lists/{list_id} Unfollow a List
ListsApi list_user_unpin DELETE /2/users/{id}/pinned_lists/{list_id} Unpin a List
ListsApi user_followed_lists GET /2/users/{id}/followed_lists Get User's Followed Lists
SpacesApi find_space_by_id GET /2/spaces/{id} Space lookup by Space ID
SpacesApi find_spaces_by_creator_ids GET /2/spaces/by/creator_ids Space lookup by their creators
SpacesApi find_spaces_by_ids GET /2/spaces Space lookup up Space IDs
SpacesApi search_spaces GET /2/spaces/search Search for Spaces
SpacesApi space_buyers GET /2/spaces/{id}/buyers Retrieve the list of Users who purchased a ticket to the given space
SpacesApi space_tweets GET /2/spaces/{id}/tweets Retrieve Tweets from a Space.
TweetsApi add_or_delete_rules POST /2/tweets/search/stream/rules Add/Delete rules
TweetsApi create_tweet POST /2/tweets Creation of a Tweet
TweetsApi delete_tweet_by_id DELETE /2/tweets/{id} Tweet delete by Tweet ID
TweetsApi find_tweet_by_id GET /2/tweets/{id} Tweet lookup by Tweet ID
TweetsApi find_tweets_by_id GET /2/tweets Tweet lookup by Tweet IDs
TweetsApi find_tweets_that_quote_a_tweet GET /2/tweets/{id}/quote_tweets Retrieve Tweets that quote a Tweet.
TweetsApi get_rules GET /2/tweets/search/stream/rules Rules lookup
TweetsApi get_tweets_firehose_stream GET /2/tweets/firehose/stream Firehose stream
TweetsApi get_tweets_sample10_stream GET /2/tweets/sample10/stream Sample 10% stream
TweetsApi hide_reply_by_id PUT /2/tweets/{tweet_id}/hidden Hide replies
TweetsApi lists_id_tweets GET /2/lists/{id}/tweets List Tweets timeline by List ID.
TweetsApi sample_stream GET /2/tweets/sample/stream Sample stream
TweetsApi search_stream GET /2/tweets/search/stream Filtered stream
TweetsApi space_buyers GET /2/spaces/{id}/buyers Retrieve the list of Users who purchased a ticket to the given space
TweetsApi space_tweets GET /2/spaces/{id}/tweets Retrieve Tweets from a Space.
TweetsApi tweet_counts_full_archive_search GET /2/tweets/counts/all Full archive search counts
TweetsApi tweet_counts_recent_search GET /2/tweets/counts/recent Recent search counts
TweetsApi tweets_fullarchive_search GET /2/tweets/search/all Full-archive search
TweetsApi tweets_recent_search GET /2/tweets/search/recent Recent search
TweetsApi users_id_like POST /2/users/{id}/likes Causes the User (in the path) to like the specified Tweet
TweetsApi users_id_liked_tweets GET /2/users/{id}/liked_tweets Returns Tweet objects liked by the provided User ID
TweetsApi users_id_mentions GET /2/users/{id}/mentions User mention timeline by User ID
TweetsApi users_id_retweets POST /2/users/{id}/retweets Causes the User (in the path) to retweet the specified Tweet.
TweetsApi users_id_timeline GET /2/users/{id}/timelines/reverse_chronological User home timeline by User ID
TweetsApi users_id_tweets GET /2/users/{id}/tweets User Tweets timeline by User ID
TweetsApi users_id_unlike DELETE /2/users/{id}/likes/{tweet_id} Causes the User (in the path) to unlike the specified Tweet
TweetsApi users_id_unretweets DELETE /2/users/{id}/retweets/{source_tweet_id} Causes the User (in the path) to unretweet the specified Tweet
UsersApi find_my_user GET /2/users/me User lookup me
UsersApi find_user_by_id GET /2/users/{id} User lookup by ID
UsersApi find_user_by_username GET /2/users/by/username/{username} User lookup by username
UsersApi find_users_by_id GET /2/users User lookup by IDs
UsersApi find_users_by_username GET /2/users/by User lookup by usernames
UsersApi list_get_followers GET /2/lists/{id}/followers Returns User objects that follow a List by the provided List ID
UsersApi list_get_members GET /2/lists/{id}/members Returns User objects that are members of a List by the provided List ID.
UsersApi tweets_id_liking_users GET /2/tweets/{id}/liking_users Returns User objects that have liked the provided Tweet ID
UsersApi tweets_id_retweeting_users GET /2/tweets/{id}/retweeted_by Returns User objects that have retweeted the provided Tweet ID
UsersApi users_id_block POST /2/users/{id}/blocking Block User by User ID
UsersApi users_id_blocking GET /2/users/{id}/blocking Returns User objects that are blocked by provided User ID
UsersApi users_id_follow POST /2/users/{id}/following Follow User
UsersApi users_id_followers GET /2/users/{id}/followers Followers by User ID
UsersApi users_id_following GET /2/users/{id}/following Following by User ID
UsersApi users_id_mute POST /2/users/{id}/muting Mute User by User ID.
UsersApi users_id_muting GET /2/users/{id}/muting Returns User objects that are muted by the provided User ID
UsersApi users_id_unblock DELETE /2/users/{source_user_id}/blocking/{target_user_id} Unblock User by User ID
UsersApi users_id_unfollow DELETE /2/users/{source_user_id}/following/{target_user_id} Unfollow User
UsersApi users_id_unmute DELETE /2/users/{source_user_id}/muting/{target_user_id} Unmute User by User ID

Documentation for Models

Documentation for Authorization

BearerToken

  • Type: Bearer authentication

OAuth2UserToken

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://api.twitter.com/2/oauth2/authorize
  • Token URL: https://api.twitter.com/2/oauth2/token
  • Scopes:
    • block.read: Accounts you’ve blocked.
    • block.write: Block and unblock accounts for you.
    • bookmark.read: Allows an app to read bookmarked Tweets
    • bookmark.write: Allows an app to create and delete bookmarks
    • follows.read: People who follow you and people who you follow.
    • follows.write: Follow and unfollow people for you.
    • like.read: Tweets you’ve liked and likes you can view.
    • like.write: Like and un-like Tweets for you.
    • list.read: Lists, list members, and list followers of lists you’ve created or are a member of, including private lists.
    • list.write: Create and manage Lists for you.
    • mute.read: Accounts you’ve muted.
    • mute.write: Mute and unmute accounts for you.
    • offline.access: App can request refresh token.
    • space.read: Access all of the Spaces you can see.
    • tweet.moderate.write: Hide and unhide replies to your Tweets.
    • tweet.read: All the Tweets you can see, including Tweets from protected accounts.
    • tweet.write: Tweet and retweet for you.
    • users.read: Any account you can see, including protected accounts. Any account you can see, including protected accounts.

UserToken