bybit 0.5.0 copy "bybit: ^0.5.0" to clipboard
bybit: ^0.5.0 copied to clipboard

outdated

(Unofficial) Dart library to communicate with the bybit API over REST or WebSockets

pub package BSD License PRs Welcome Watch on GitHub Star on GitHub

ByBit #

ByBit is a Dart library for an easy communication with the bybit exchange platform API. This package allows to make simple REST API calls or to subscribe to several WebSockets channels topics.

How to use #

Create a ByBit instance #

Note that all the parameters are optional, but you need a valid key and password to access private topics from bybit. You can create your own api-key on the bybit website

ByBit bybit = ByBit(
        key: 'yOuRsUpErKey',
        password: 'yOuRsUpErPaSsWoRd',
        logLevel: 'INFO',
        restUrl: 'https://api.bybit.com',
        restTimeout: 3000,
        websocketUrl: 'wss://stream.bytick.com/realtime',
        websocketTimeout: 2000);

Connect to the server #

bybit.connect();

Subscribe to topics and read the websocket stream... #

// ...
bybit.subscribeToKlines(symbol: 'ETHUSD', interval: '1');
bybit.subscribeToKlines(symbol: 'BTCUSD', interval: 'D');
bybit.subscribeToOrderBook(depth: 25);
// ...
StreamBuilder(
    stream: bybit.websocket.stream,
    builder: (context, bybitResponse) {
          print('From WebSocket: ' + bybitResponse.data.toString());
          //...
    }
),
//...

... and/or make some REST API calls #

// ...
FutureBuilder(
    future: bybit.getKLine(symbol: 'BTCUSD', from: 1581231260, interval: 'D'),
    builder: (context, bybitResponse) {
        // Handle the bybit response here
        if (bybitResponse.hasData && bybitResponse.data != null) {
          print('From REST: ' + bybitResponse.data.toString());
          //...

Example #

See the file main.dart in the example/lib/ directory for a simple Dart example. Also, the files main_flutter_stream.dart and main_flutter_future.dart show examples using FutureBuilder and StreamBuilder.

List of functions #

See the documentation for the latest avaiable functions. All function return objects of JSON type aka. Map<String, dynamic>.

8
likes
40
pub points
42%
popularity

Publisher

unverified uploader

(Unofficial) Dart library to communicate with the bybit API over REST or WebSockets

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

crypto, http, logger, meta, sortedmap, web_socket_channel

More

Packages that depend on bybit