binance 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

binance-dart #

This is a Dart wrapper for the Binance API. It has serialized data classes and supports all un-authenticated endpoints.

Example #

import 'package:binance/binance.dart';

main() async {
  final _binance = Binance();

  _binance.aggTrade("BTCUSDT").listen(_printTrade);
  _binance.aggTrade("ETHUSDT").listen(_printTrade);
  _binance.aggTrade("LTCUSDT").listen(_printTrade);
}

_printTrade(WebsocketAggregatedTrade t) => print(
    "${t.symbol} [${t.id}] ${t.price.toStringAsFixed(2)} USDT, ${t.qty.toStringAsFixed(3)}");

BTCUSDT [90983841] 3582.32 USDT, 0.551
LTCUSDT [13275542] 41.80 USDT, 9.000
BTCUSDT [90983846] 3582.35 USDT, 0.467
ETHUSDT [54910796] 121.08 USDT, 0.000
BTCUSDT [90983847] 3582.03 USDT, 0.003
ETHUSDT [54910798] 121.06 USDT, 10.280

Roadmap #

  • Support authenticated endpoints
  • <symbol>@trade
  • <symbol>@kline_<interval>
  • Book class that properly aggregates a live order book

Contributing #

Contributions are welcome. Please try to emulate the structure of this repo. If your contribution is not on the roadmap please create an issue so we can discuss the best way forward.

1.0.1 - Documentation updates #

  • Updated documentation

1.0.0 - Initial release #

  • All non-authenticated methods and endpoints.

example/example.dart

import 'package:binance/binance.dart';

main() async {
  final _binance = Binance();

  _binance.aggTrade("BTCUSDT").listen(_printTrade);
  _binance.aggTrade("ETHUSDT").listen(_printTrade);
  _binance.aggTrade("LTCUSDT").listen(_printTrade);
}

_printTrade(WsAggregatedTrade t) => print(
    "${t.symbol} [${t.id}] ${t.price.toStringAsFixed(2)} USDT, ${t.qty.toStringAsFixed(3)}");

Use this package as a library

1. Depend on it

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


dependencies:
  binance: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:binance/binance.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
40
Health:
Code health derived from static analysis. [more]
88
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

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

Health suggestions

Fix lib/src/rest.dart. (-9.08 points)

Analysis of lib/src/rest.dart reported 19 hints, including:

line 10 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 20 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 25 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 31 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 37 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix lib/src/websocket.dart. (-3.45 points)

Analysis of lib/src/websocket.dart reported 7 hints, including:

line 18 col 3: The class 'Stream' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 29 col 3: The class 'Stream' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 41 col 3: The class 'Stream' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 51 col 3: The class 'Stream' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 63 col 3: The class 'Stream' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Maintenance suggestions

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
http ^0.12.0 0.12.0+2
web_socket_channel ^1.0.9 1.1.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
http_parser 3.1.3
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.5.1+1