twitch_api 0.0.1 twitch_api: ^0.0.1 copied to clipboard
A wrapper in pure Dart to connect to Twitch.tv using OAuth implicit authentication.
twitch_api #
A wrapper in pure Dart to connect to Twitch.tv using OAuth implicit authentication.
Getting started #
NOTE: This package is in its early stage, please be patient until more methods are implemented or do not hesitate to open a merge request if you added support for an endpoint.
To use this package you will need to register an application on the Twitch developer console to get a client ID.
After registering your application you will need to instantiate the TwitchClient
class from the package with your clientId
and your redirectUri
.
import 'package:twitch_api/twitch_api.dart';
final _twitchClient = TwitchClient(clientId: clientId, redirectUri: redirectUri);
Now that you have initialized the client the last step before using the method will be to manage the first connection with your twitch account. You can find a complete example of an implementation using the package flutter_webview_plugin.
const clientId = "<YOUR_CLIENT_ID>";
const redirectUri = "<YOUR_REDIRECT_URL>"; // ex: "http://localhost/"
void _urlListener(String url) {
if (url.startsWith(redirectUri)) {
_twitchClient.initializeToken(TwitchToken.fromUrl(url));
_flutterWebviewPlugin.close();
}
}
// First authentication through a webview
Future<TwitchToken> _openConnectionPage({List<TwitchApiScope> scopes = const []}) {
_flutterWebviewPlugin.onUrlChanged.listen(_urlListener);
_flutterWebviewPlugin.onDestroy.listen((_) => Navigator.pop(context));
// Get authorization URL for the connection with the webview.
final url = _twitchClient.authorizeUri(scopes);
return Navigator.push(
context,
MaterialPageRoute(
builder: (context) => WebViewPage(url.toString()),
),
).then((_) => _twitchClient.validateToken());
}
Now you are ready to use the methods implemented in Supported Features section.
Supported Features #
Ads #
- ✅ Start Commercial
Analytics #
- ✅ Get Extension Analytics
- ✅ Get Game Analytics (Documentation in progress)
Bits #
- ❌ Get Bits Leaderboard
- ❌ Get Cheermotes
- ❌ Get Extension Transactions
Channels #
- ❌ Get Channel Information
- ❌ Modify Channel Information
- ❌ Get Channel Editors
Channel Points #
- ❌ Create Custom Rewards
- ❌ Delete Custom Reward
- ❌ Get Custom Reward
- ❌ Get Custom Reward Redemption
- ❌ Update Custom Reward
- ❌ Update Redemption Status
Clips #
- ❌ Create Clip
- ❌ Get Clips
Entitlements #
- ❌ Create Entitlement Grants Upload URL
- ❌ Get Code Status
- ❌ Get Drops Entitlements
- ❌ Redeem Code
EventSub #
- ❌ Create EventSub Subscription
- ❌ Delete EventSub Subscription
- ❌ Get EventSub Subscriptions
Games #
- ❌ Get Top Games
- ❌ Get Games
Hype Train #
- ❌ Get Hype Train Events
Moderation #
- ❌ Check AutoMod Status
- ❌ Get Banned Events
- ❌ Get Banned Users
- ❌ Get Moderators
- ❌ Get Moderator Events