Skip to content
pubscout

twitter_api_v2

4.9.4, released 4 years ago by shinyakato.dev

Dart and Flutter client library for the Twitter API v2.0.

$ flutter pub add twitter_api_v2
Source repository

What it does

Provides a comprehensive wrapper for Twitter API v2.0 endpoints supporting tweets, users, spaces, lists, media uploads, and streaming. Handles authentication, automatic retries, and rate limiting natively.

AI-written summary of version 4.9.4, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to integrate Twitter API v2 endpoints into a Dart or Flutter application.
  • You want built-in support for streaming, media uploads, and safe pagination.

Skip it when

  • You are building an app for a social media platform other than Twitter.
  • You only require a generic HTTP client and do not need Twitter-specific models.

Strengths

  • Supports all Twitter API v2 endpoints, expansions, and fields.
  • Built-in automatic retry with exponential backoff and jitter.
  • Supports high-performance streaming and large media uploads with progress tracking.

Weaknesses

  • Tightly coupled to the Twitter API, making it useless if Twitter changes its API terms or pricing.
  • Requires external packages like twitter_oauth2_pkce for complete user authentication flows.

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
6

Requires developer credentials and API keys obtained from the Twitter Developer Portal.

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

Future<void> main() async {
  final twitter = v2.TwitterApi(
    bearerToken: 'YOUR_TOKEN_HERE',
  );

  final me = await twitter.users.lookupMe();
  print(me.data.name);
}

Alternatives

Packages that do the same job and could replace twitter_api_v2.

  • bluesky

    A Dart and Flutter library for Bluesky Social and the AT Protocol.

  • atproto

    Comprehensive client library for the AT Protocol supporting records, identity, and the firehose.

  • metadata_fetch

    Extracts metadata such as OpenGraph, Twitter Cards, and JSON-LD from web pages.

  • dart_twitter_api

    A Dart wrapper for Twitter API v1.1 with typed models and endpoint methods.

Works with

Packages commonly used together with twitter_api_v2: ones it builds on, ones built on it, and its own family.