twitter_api_v2
4.9.4, released 4 years ago by shinyakato.dev
Dart and Flutter client library for the Twitter API v2.0.
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.
85Compare - atproto
Comprehensive client library for the AT Protocol supporting records, identity, and the firehose.
81Compare - metadata_fetch
Extracts metadata such as OpenGraph, Twitter Cards, and JSON-LD from web pages.
50Compare - dart_twitter_api
A Dart wrapper for Twitter API v1.1 with typed models and endpoint methods.
46Compare
Works with
Packages commonly used together with twitter_api_v2: ones it builds on, ones built on it, and its own family.
- mimetwitter_api_v2 depends on itUtilities to resolve MIME types from file names, magic bytes, and to parse multipart streams.
- json_annotationtwitter_api_v2 depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- freezed_annotationtwitter_api_v2 depends on itAnnotations for the freezed code-generator.
- universal_iotwitter_api_v2 depends on itCross-platform dart:io implementation with browser support for HttpClient and other APIs
- oauth1twitter_api_v2 depends on itOAuth 1.0 client implementation for Dart