twitch 0.3.2 copy "twitch: ^0.3.2" to clipboard
twitch: ^0.3.2 copied to clipboard

Dart 1 only

Unofficial Twitch API for Dart and Flutter.

twitch #

Unofficial Twitch API for Dart and Flutter.

pub package Build Status Coverage Status

NOTE: This is not an official Google or Dart project.

Installation #

Simply add twitch to your pubspec.yaml file:

dependencies:
  twitch: ^0.3.0

You'll need a Twitch API token (called a "client ID") for this to be useful. Visit the twitch developer site to signup - it just takes a minute or two.

WARNING: The default implementation only works in the command-line VM and Flutter, and may not be loaded in the browser at all in Dart versions older than 1.23.0. Starting at 1.23.0 it's trivial to implement a browser version of TwitchHttp, but this has not been yet. Consider contributing!

Usage #

This API is incomplete, and currently supports a high-level Twitch class (with a strongly-typed idiomatic Dart API) and a lower-level TwitchHttp class that allows making any call to the Twitch API server, provided you know the URL endpoints (see the API documentation).

For example, how to get the top played games on Twitch:

import 'dart:async';

import 'package:twitch/twitch.dart';

/// With a pre-authorized client ID, prints the top games on Twitch.
/// 
/// Assumes the environment variable `TWITCH_CLIENT_ID` to be set.
main() async {
  var http = new TwitchHttp.fromEnv();
  var twitch = new Twitch(http); 
  
  // Calls and decodes GET https://api.twitch.tv/kraken/games/top
  final result = await twitch.getTopGames();
   
  print('The top game on Twitch is currently: ${result.first.name}');
  http.close();
}

Contributing #

We welcome a diverse set of contributions, including, but not limited to:

For the stability of the API and existing users, consider opening an issue first before implementing a large new feature or breaking an API. For smaller changes (like documentation, bug fixes), just send a pull request.

1
likes
20
pub points
0%
popularity

Publisher

unverified uploader

Unofficial Twitch API for Dart and Flutter.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

meta

More

Packages that depend on twitch