irufus / gdax-java

Java based wrapper for Coinbase Pro (Formerly known as GDAX API and Coinbase Exchange API)
MIT License
177 stars 131 forks source link

Coinbase Pro

Join the chat at https://gitter.im/irufus/gdax-java

Java based wrapper for the Coinbase Pro API

Notes:

Coinbase Pro primary data sources and servers run in the Amazon US East data center. To minimize latency for API access, we recommend making requests from servers located near the US East data center. Some of the methods do not yet have tests and so may not work as expected until someone tries them and fixes them at a later date. Please raise an issue in github if you want something in particular as a priority. This codebase is maintained independently of Coinbase. We are not in any way affiliated with coinbase or coinbase pro.

Functions supported:

In Development

Check the issues on the repo for open items to work on. Please join the gitter channel if you have any questions. Support always welcome. Note the channel uses the legacy name of 'gdax-java' rather than 'coinbase-pro-java'

Contributing

Please see CONTRIBUTE.md if your interested in getting involved.

Usage


If you commit your secure keys, passphrase or secrete, disable/delete them from Coinbase Pro immediately.

  1. tests can be run with ./gradlew test, and ./gradlew integrationTest.
    1. unit tests have file/class names ending Test and run locally
    2. integration tests have file/class names ending IntegrationTest and should run against the sandbox api

Examples

To make use of this library you only need a reference to the Service that you want.

Examples


At present the Services and Data objects returned should match the interface specified in the Coinbase Pro api here: https://docs.pro.coinbase.com/#api

Each Service class requires the CoinbaseExchange object (see CONTRIBUTING.md for examples of how to create this) so that methods calling the REST endpoints can be made, using a RestTemplate that has the correct headers and signatures is used.

API


This library is as set up as follows: (Note: this section is likely to change over time)

WebsocketFeed API


The WebsocketFeed is implemented and works. However, there are techniques to using it successfully for production use - e.g. monitoring for 'heartbeats'.

To use the WSF check out the API documentation and look at usages of websocketFeed.subscribe(String) as an example that already works.

Updates - v 0.11.0


Updates - v 0.9.1


Updates


TODO


From the GDAX API documentation the Websocket implementation follows the following implementation: Send a subscribe message for the product(s) of interest and the full channel. Queue any messages received over the websocket stream. Make a REST request for the order book snapshot from the REST feed. Playback queued messages, discarding sequence numbers before or equal to the snapshot sequence number. Apply playback messages to the snapshot as needed (see below). After playback is complete, apply real-time stream messages in sequential order, queuing any that arrive out of order for later processing. Discard messages once they've been processed.