twitch 0.3.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 90

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.

0.3.2

  • Added Twitch#searchChannels|searchGames|getChannelVideos.
  • Also significant API additions to Channel.

Special thanks to @brianegan for this release!

0.3.1

Added Twitch#getTopVideos, returning videos sorted by current viewers:

abstract class Video {
 String get id;
 String get description;
 Channel get channel;
 String get game;
 String get title;
 String get url;
 TwitchCdnImage get preview;
}

Special thanks to @brianegan for this release!

0.3.0

This should be the minimum amount of features implemented to easily create some UI for AngularDart or Flutter. If you like this package and want to see it grow, consider filing feature requests or even better, contributing.

  • Added TopGame; see games.
  • Added a TwitchCdnImage, wrapper around Twitch's URL locations for an image.
  • Added a Response<T>, which is an Iterable<T> with a int total field.
  • Experimental Twitch#getTopGames stable, returns Future<Response<TopGame>:
abstract class TopGame {
  int get channels;
  int get viewers;
  int get popularity;
  int get id;
  String get name;

  TwitchCdnImage get box;
  TwitchCdnImage get logo;
}

0.2.0

  • Remove the json (decoder) property from the TwitchHttp client.
  • Added an authorized factory to TwitchHttp:
  • Additionally, all of the parameters to TwitchHttp are now named parameters:
new TwitchHttp(
  clientID: '...',
)

new TwitchHttp.authorized(
  accessToken: '...',
  clientID: '...',
)
  • Added a Twitch class for a high-level set of APIs on top of TwitchHttp:
final result = await twitch.getTopGames();

0.1.0+1

  • A few fixes in documentation and the README.

0.1.0

  • Initial commit.

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  twitch: "^0.3.2"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:twitch/twitch.dart';
        
Version Uploaded Documentation Archive
0.3.2 Jun 25, 2017 Go to the documentation of twitch 0.3.2 Download twitch 0.3.2 archive
0.3.1 Jun 4, 2017 Go to the documentation of twitch 0.3.1 Download twitch 0.3.1 archive
0.3.0 May 28, 2017 Go to the documentation of twitch 0.3.0 Download twitch 0.3.0 archive
0.2.0 May 28, 2017 Go to the documentation of twitch 0.2.0 Download twitch 0.2.0 archive
0.1.0+1 May 28, 2017 Go to the documentation of twitch 0.1.0+1 Download twitch 0.1.0+1 archive
0.1.0 May 28, 2017 Go to the documentation of twitch 0.1.0 Download twitch 0.1.0 archive

Analysis

We analyzed this package on Apr 9, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.46.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
81 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
90
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:twitch/twitch.dart with components: io.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 7 hints.

    Strong-mode analysis of lib/src/http.dart gave the following hint:

    line: 116 col: 17
    'UTF8' is deprecated and shouldn't be used.

    Strong-mode analysis of lib/src/specs/search_channels.dart gave the following hint:

    line: 4 col: 34
    The member 'JsonResultsSpec' can only be used within 'spec.dart' or a test.

    Similar analysis of the following files failed:

    • lib/src/specs/search_games.dart (hint)
    • lib/src/specs/top_games.dart (hint)
    • lib/src/specs/top_videos.dart (hint)
    • lib/src/specs/videos.dart (hint)
  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use twitch.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.22.0 <2.0.0
meta ^1.0.5 1.1.2
Dev dependencies
stack_trace ^1.3.2
test ^0.12.20+12