twitter_api_v2 1.0.0 copy "twitter_api_v2: ^1.0.0" to clipboard
twitter_api_v2: ^1.0.0 copied to clipboard

outdated

The lightweight and powerful wrapper library for Twitter API v2.0 written in Dart language. It works cross-platform.

twitter_api_v2

The Lightweight and Cross-Platform Wrapper for Twitter API v2.0 🐦


pub package Dart SDK Version Test Analyzer codecov Issues Pull Requests Stars Code size Last Commits License Contributor Covenant FOSSA Status

myconsciousness


1. Guide #

This library provides the easiest way to use Twitter API v2.0.

Show some ❤️ and star the repo to support the project.

1.1. Getting Started #

1.1.1. Install Library #

With Dart:

 dart pub add twitter_api_v2

Or With Flutter:

 flutter pub add twitter_api_v2

1.1.2. Import #

import 'package:twitter_api_v2/twitter_api_v2';

1.1.3. Implementation #

import 'package:twitter_api_v2/twitter_api_v2.dart' as v2;

void main() async {
  //! You need to get keys and tokens at https://developer.twitter.com
  final twitter = v2.TwitterApi(
    //! Authentication with OAuth2.0 is the default.
    //!
    //! Note that to use endpoints that require certain user permissions,
    //! such as Tweets and Likes, you need a token issued by OAuth2.0 PKCE.
    bearerToken: 'YOUR_TOKEN_HERE',

    //! Or perhaps you would prefer to use the good old OAuth1.0a method
    //! instead of OAuth2.0 PKCE method. Then you can use the following code
    //! to set the OAuth1.0a tokens.
    oauthTokens: v2.OAuthTokens(
      consumerKey: 'YOUR_CONSUMER_KEY_HERE',
      consumerSecret: 'YOUR_CONSUMER_SECRET_HERE',
      accessToken: 'YOUR_ACCESS_TOKEN_HERE',
      accessTokenSecret: 'YOUR_ACCESS_TOKEN_SECRET_HERE',
    ),
  );

  try {
    final me = await twitter.usersService.lookupMe();
    final tweets = await twitter.tweetService.searchRecent(query: '#ElonMusk');

    final response = await twitter.tweetService.createLike(
      userId: me.data.id,
      tweetId: tweets.data.first.id,
    );

    print(response);
  } on v2.TwitterException catch (e) {
    print(e.response.headers);
    print(e.response.body);
  }
}

1.2. Supported Endpoints #

  1. Tweets Service

    1. Manage Tweet
      1. DELETE /2/tweets/:id
      2. POST /2/tweets
    2. Likes
      1. DELETE /2/users/:id/likes/:tweet_id
      2. GET /2/tweets/:id/liking_users
      3. GET /2/users/:id/liked_tweets
      4. POST /2/users/:id/likes
    3. Retweets
      1. DELETE /2/users/:id/retweets/:source_tweet_id
      2. GET /2/tweets/:id/retweeted_by
      3. POST /2/users/:id/retweets
    4. Quote Tweets
      1. GET /2/tweets/:id/quote_tweets
    5. Search Tweets
      1. GET /2/tweets/search/all
      2. GET /2/tweets/search/recent
    6. Lookup Tweets
      1. GET /2/tweets
      2. GET /2/tweets/:id
  2. Users

    1. Follows
      1. DELETE /2/users/:source_user_id/following/:target_user_id
      2. GET /2/users/:id/followers
      3. GET /2/users/:id/following
      4. POST /2/users/:id/following

1.3. Contribution #

If you would like to contribute to twitter_api_v2, please create an issue or create a Pull Request.

Owner will respond to issues and review pull requests as quickly as possible.

1.4. Support #

The simplest way to show us your support is by giving the project a star at here.

And I'm always looking for sponsors to support this project.

Sponsors can be individuals or corporations, and the amount is optional.

👇 Click on the button below to see more details! 👇

myconsciousness

1.5. License #

All resources of twitter_api_v2 is provided under the BSD-3 license.

FOSSA Status

Note: License notices in the source are strictly validated based on .github/header-checker-lint.yml. Please check header-checker-lint.yml for the permitted standards.

1.6. More Information #

twitter_api_v2 was designed and implemented by Kato Shinya.

71
likes
0
pub points
84%
popularity

Publisher

verified publishershinyakato.dev

The lightweight and powerful wrapper library for Twitter API v2.0 written in Dart language. It works cross-platform.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

freezed_annotation, http, json_annotation, oauth1

More

Packages that depend on twitter_api_v2