Exchange/Pro Java Client

I’ve searched everywhere for a decent java client for the API’s provided by Coinbase and could find nothing close to what I was interested in. Everyone seems to think that just having a REST architecture is sufficient enough and doesn’t develop any further.

I just spent the last few months studying these API’s, their WebSockets, subscription and REST responses. And I believe I’ve put together a really good Java SE client, complete with automated subscriptions, Level2 and Level3 order books built autonomously according to whatever products and channels are subscribed, and simplified REST request methods.

Anyone interested in collaboration on a project with this client or if you are interested in obtaining a copy feel free to message me. I will post the readme only here on the forum.

1 Like

/* ********** OBJECT USAGE NOTES README BEFORE ATTEMPTING ANYTHING! **********

// AUTOMATED WEBSOCKET SUBSCRIPTIONS WITH LEVEL2 AND LEVEL3 ORDER BOOK MAINTAINED LOCALLY
// REST REQUESTS AND AUTHENTICATION BUILT IN

// ALL COINBASE PRO SERVER RESPONSES DESERIALIZED AND MAPPED FOR ALL YOUR CRYPTOCURRENCY NEEDS
// SHOULD WORK JUST FINE FOR EXCHANGE API SERVER, HOWEVER I DO NOT HAVE ACCESS FOR TESTING
// FOR ANY ASSISTANCE WITH THIS CLIENT API FEEL FREE TO CONTACT ME @ CLEGGFREDRICK@GMAIL.COM

// CONSTRUCTION USAGE:
// CoinbaseProClient(String baseURL, String wsFeedURL, String secretKey, String apiKey, String passphrase)
// FAIRLY STRAIGHT FORWARD:
// baseURL (COINBASE PRO URL: “https://api.pro.coinbase.com”)
// wsFeedURL (COINBASE PRO URL: “wss://ws-feed.pro.coinbase.com”)
// REMAINING VARIABLES ARE PROVIDED TO YOU BY COINBASE
// I DID NOT HARD CODE THE URLS BECAUSE OF THE MANY API SERVERS COINBASE HAS
// HOWEVER THESE ARE THE ONES THAT I USE
// PLEASE DON’T ADD THE “/” AFTER THE DOMAIN
// CALLING THE CONSTRUCTOR WITHOUT API SECURITY CREDENTIALS IS POSSIBLE HOWEVER WITHOUT SETTING THESE KEYS
// SERVER RESPONSES ARE LIMITED
// IF YOU CHOOSE TO SET CREDENTIALS AFTER INSTANCIATION YOU CAN DO TO BY CALLING THEIR RESPECTIVE SETTERS
// THIS WILL ENABLE FULL SERVER RESPONSES FROM ALL FUTURE SUBSCRIPTIONS AND REST CALLS
// setAPIKey(), setAPISecretKey(), and setAPIPassphrase()

// SUBSCRIPTION RESPONSES ARE MAPPED BY EITHER CURRENCY ID OR PRODUCT ID FOR RETREIVAL AT YOUR CONVENIENCE
// PRELIMINARY STATUS SUBSCRIPTION STARTED AT OBJECT CONSTRUCTION (YOU DON’T NEED TO DO THIS)
// ALL NEW SUBSCRIPTIONS INVOKED BY subscribe() PASS BACK WebSocketClient FOR YOU TO unsubscribe(WebSocketClient)
// THESE WebSocketClients ARE ALSO MAPPED TO subscriptionMap (SEE DATA RETRIEVAL BELOW)
// unsubscribe() ALSO CLOSES AND DESTROYS WebSocketClient (YOU DON’T NEED TO WORRY ABOUT THIS)
// unsubscribeAll() CLOSES ALL WEBSOCKETS

// subscribe() USAGE:
// String identifier (WHATEVER YOU CHOOSE TO NAME THIS SUBSCRIPTION)
// String productIDList (JUST A LIST OF PRODUCT IDS)
// THE FOLLOWING BOOLEANS WILL ENABLE OR DISABLE USE OF VARYING CHANNELS:
// Boolean useStatus (ALREADY CREATED FOR YOU)
// Boolean useHeartbeat
// Boolean useLevel2
// Boolean useFull
// Boolean useUser
// Boolean useTicker
// Boolean useMatches
// Boolean useAuction

// REST REQUESTS STRINGS ARE ENTIRELY IN YOUR CONTROL
// REST REQUESTS endpoint ARE PREFIXED WITH “/” DO NOT FORGET TO ADD THIS TO YOUR STRING
// REST REQUESTS pathParams SERIALIZED REQUEST PARAMETERS
// REST REQUESTS requestBody POST JSON BODY AS STRING

// REST REQUEST METHODS (ALL RETURN A CoinbaseAPIResponse CONTAINING DESERIALIZED SERVER RESPONSE)
// *** IF YOU ARE NOT PASSING PATH PARAMETERS PASS A EMPTY STRING “” NOT A null ***
// Array SUFFIXES REFER TO THE RETURN TYPE CoinbaseAPIResponse (SOME SERVER RESPONSES REQUIRE ARRAYS)
// getRequest(String endpoint, String pathParams)
// getRequestArray(String endpoint, String pathParams)
// postRequest(String endpoint, String requestBody)
// postRequestArray(String endpoint, String requestBody)
// deleteRequest(String endpoint, String pathParams)
// deleteRequestArray(String endpoint, String pathParams)
// putRequest(String endpoint, String pathParams, String requestBody)
// putRequestArray(String endpoint, String pathParams, String requestBody)

// DATA RETRIEVAL METHODS (LEVEL2 ORDER BOOK getPriceMap(), LEVEL3 ORDER BOOK getOrderBook())
// getCurrencyMap() CONTAINS ALL THE DETAILS OF INDIVIDUAL CURRENCIES
// getProductMap() CONTAINS ALL THE DETAILS OF ALL COINBASE PRODUCTS
// ALL DATA MAPPING HASHMAPS ARE RETRIEVABLE BUY CALLING THEIR RESPECTIVE RETRIEVAL METHODS
// getCurrencyMap() → KEYED BY CURRENCY ID (CURRENCY PROPERTIES FROM STATUS CHANNEL)
// getProductMap() → KEYED BY PRODUCT ID (PRODUCT PROPERTIES FROM STATUS CHANNEL)
// getSubscriptionMap() → KEYED BY PARTIAL SUBSCRIPTION JSON MESSAGE (NO SIGNATURE)
// getSubscriptionIdentifierMap() → KEYED THE SAME AS subscriptionMap (MAPS OF YOUR SUBSCIPTION CLIENTS)
// getPriceMap() → KEYED BY PRODUCT ID (CURRENT PRICING FOR ALL SUBSCIBED PRODUCTS, MAY CONTAIN OTHER RELEVANT INFO)
// getOrderBook() → KEYED BY ORDER ID (LEVEL3 ORDER BOOK CREATED UPON APPLICABLE SUBSCRIPTIONS)

// SIMPLE LOGGING SYSTEM TO System.out.println() ENABLING AND DISABLING OF MESSAGING LEVELS AS FOLLOWS:
// enableLogger() or disableLogger() (FULL MESSAGING SYSTEM)
// enableDataMessages() or disableDataMessages() (FULL DATA RECEIPT MESSAGES OUTPUT) ANNOYANCE - FOR DEBUGGING
// enablePulseCheck() or disablePulseCheck() (INDIVIDUAL TICKER, HEARTBEAT, AND LEVEL2 MESSAGES) ANNOYANCE - FOR DEBUGGING
// enableDeserializationIgnoreExeceptions() or disableDeserializationIgnoreExeceptions() (DESERIALIZATION IGNORE UNKNOWNS)
// MAY BE REQUIRED IF THERE HAS BEEN NEW SERVER RESPONSES THAT HAVE NOT BEEN PROCESSED (ENABLED BY DEFAULT BY JUSTIN CASE)

// WHATEVER YOU DO DON’T FORGET TO .start() THE THREAD IT WILL MONITOR YOUR SUBSCRIPTIONS FOR CONNECTION
// AND RESUBSCRIBE ON CLOSE IF YOU HAVEN’T unsubscribe()ED
// TO END THE THREAD AND SUBSCRIPTIONS ALL AT ONCE JUST CALL .end() // */

Hello Fred, I am very interested in collaboration of your project as well as obtaining a copy. My email is RussellWKelly@gmail.com
Look forward to our future communications!

1 Like

Love seeing the collaboration @cleggink and @Ruskel5070 !

1 Like

@cleggink I know the pain! I’ve had to build something similar (no where near complete). I would be interested in taking a look and collaborating. My email is emi_emi@hotmail.co.uk

Welcome to the forum @FL3X