coinbase_exchange 2.0.10 copy "coinbase_exchange: ^2.0.10" to clipboard
coinbase_exchange: ^2.0.10 copied to clipboard

An unoffical coinbase exchange sdk to get real time pricing data and historical pricing data. The sdk also allows users to make trades on the coinbase platform.

coinbase_exchange #

An unofficial sdk for the coinbase cloud exchange.

Gif

Getting Started #

This project is a Dart sdk the coinbase exchange api. This sdk allows for the retrieval of real time pricing data using the coinbase websocket feed and information about individual profiles on coinbase and coinbase pro. It also allows for the trading of cryptocurrencies on the coinbase pro platform. This package uses api keys which must be generated from coinbase pro or the coinbase pro sandbox.

To test to make sure you have generated your keys correctly, create a file test/secrets.dart with the contents:

class Secrets {
  static const String apiKey = '';
  static const String secretKey = '';
  static const String passphrase = '';
}

Put in your apiKey, secretKey and passphrase. In the coinbase_exchange_test.dart file. Then run:

pub run test --chain-stack-traces test/coinbase_exchange_test.dart

This will by default execute the tests in the coinbase pro sandbox so make sure you have used the appropriate keys. The tests are currently incomplete and only test Accounts, Coinbase Accounts, Conversions and Currencies.

Websocket Feed #

// Make sure to import the package as something so you dont polute your environment.
import 'package:coinbase_exchange/coinbase_exchange.dart' as cb;

cb.WebsocketClient wsClient = cb.WebsocketClient(sandbox: false);

var stream = wsClient.subscribe(
  productIds: ['BTC-USD'],
  channels: [
    cb.ChannelEnum.heartBeat,
  ],
);

// The first event is always a subscriptions event which tells you which channels you 
// have subscribed to. After the first event it is up to you to manually sort events 
// from the stream.
stream.listen((event) {
  print(event.toJson().toString());
  wsClient.close();
});

API #

// Make sure to import the package as something so you dont polute your environment.
import 'package:coinbase_exchange/coinbase_exchange.dart' as cb;

var accounts = await cb.accountsClient.listAccounts();

for (cb.Account account in accounts) {
  print(account.currency);
}
5
likes
110
pub points
20%
popularity

Publisher

unverified uploader

An unoffical coinbase exchange sdk to get real time pricing data and historical pricing data. The sdk also allows users to make trades on the coinbase platform.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

crypto, http, json_annotation, json_serializable, logger, tuple, web_socket_channel

More

Packages that depend on coinbase_exchange