Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Get started

Bad_Pop edited this page Apr 5, 2021 · 5 revisions

Maven

<dependency>
    <groupId>com.github.bad-pop</groupId>
    <artifactId>jcoinbase</artifactId>
    <version>0.2.0</version>
</dependency>

Gradle

compile 'com.github.bad-pop:jcoinbase:0.2.0'

Usage

To make requests to the Coinbase API using JCoinbase, simply instantiate a new JcoinbaseClient via the JCoinbaseClientFactory

JCoinbaseClient client = JCoinbaseClientFactory
    .build(
        yourApiKey,
        yourSecret,
        apiVersion,
        desiredTimoutInSecond,
        threadSafeSingleton
    );  
  • Api key : Your api key generated by Coinbase in your profile settings.
  • Secret : Your secret generated by Coinbase in your profile settings.
  • Api Version : Your api version generated by Coinbase in your profile settings.
  • desiredTimeoutInSeconds : A long value that defines the timeout in seconds for http requests. Recommended value is 3.
  • threadSafeSingleton : A boolean defining if the JCoinbaseClient should be build as a thread safe singleton.

Notice that, if you pass null for the api key and the secret, you won't be able to access non-public data : user, account, addresses, transactions, buy, sell, deposit, withdrawals and payment methods.

Then, you can simply call Coinbase resources like that :

CallResult<Seq<CoinbaseError>, User> currentUser = client.user().getCurrentUser();  

For further information on the CallResult class, please take a look at : the CallResult documentation

Please note that, by default, returned values use Vavr data types for objects like Collections or Option.
So if you don't want to use Vavr, you can always get java objects via the api.

For example :

CallResult<io.vavr.collection.Seq<CoinbaseError>, User> currentUser = client.user().getCurrentUser();
CallResult<java.util.List<CoinbaseError>, User> currentUser = client.user().getCurrentUserAsJava();

For further information on Vavr, please take a look at : https://www.vavr.io/

Clone this wiki locally