coinbase-pro-client

Coinbase pro Client library

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.github.dubasdey
ArtifactId

ArtifactId

coinbase-pro-client
Last Version

Last Version

0.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

coinbase-pro-client
Coinbase pro Client library
Project URL

Project URL

https://github.com/dubasdey/coinbase-pro-client
Source Code Management

Source Code Management

https://github.com/dubasdey/coinbase-pro-client

Download coinbase-pro-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.dubasdey/coinbase-pro-client/ -->
<dependency>
    <groupId>com.github.dubasdey</groupId>
    <artifactId>coinbase-pro-client</artifactId>
    <version>0.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.dubasdey/coinbase-pro-client/
implementation 'com.github.dubasdey:coinbase-pro-client:0.0.5'
// https://jarcasting.com/artifacts/com.github.dubasdey/coinbase-pro-client/
implementation ("com.github.dubasdey:coinbase-pro-client:0.0.5")
'com.github.dubasdey:coinbase-pro-client:jar:0.0.5'
<dependency org="com.github.dubasdey" name="coinbase-pro-client" rev="0.0.5">
  <artifact name="coinbase-pro-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.dubasdey', module='coinbase-pro-client', version='0.0.5')
)
libraryDependencies += "com.github.dubasdey" % "coinbase-pro-client" % "0.0.5"
[com.github.dubasdey/coinbase-pro-client "0.0.5"]

Dependencies

compile (2)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar [2.9.8,)
org.apache.httpcomponents : httpclient jar 4.5.6

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.20

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

coinbase-pro-client

Java 7 Coinbase pro client. Using API spec: https://docs.pro.coinbase.com/

Build Status License: LGPL v3

Features

  • Object oriented requests and responses
  • Proxy Support (Using Java configuration or HTTPClient configuration)
  • Custom exceptions
  • Logging API

Dependencies

Maven project

Include the dependency in the maven dependencies. All requirements will be downloaded by maven for you.

		<dependency>
			<groupId>com.github.dubasdey</groupId>
			<artifactId>coinbase-pro-client</artifactId>
			<version>0.0.4</version>
		</dependency>

I recommend to use the last version published in maven central.

Java project

Dependencies are not included with jar. The client requires the following dependencies (or upper compatible version):

  • Commons Logging
    • commons-logging-1.2.jar
  • Commons Codec
    • commons-codec-1.10.jar
  • Jackson
    • jackson-core-2.9.1.jar
    • jackson-annotations-2.9.0-jar
    • jacksing-databind-2.9.1.jar
  • Apache HTTP Client
    • httpclient-4.5.6.jar
    • httpcore-4.4.10.jar

Client

The project provides a REST Client but the clients structure allows the posibility of other future clients (maybe Websocket?)

All clients use the common interface Client and the same model objets

REST API Client

Instance the Client class at org.erc.coinbase.pro.rest.Client to create a new API Client.

Instance the client

The client required connection parameters to build the object using a ClientConfig object

    ClientConfig config = new ClientConfig();
	 config.setBaseUrl( baseUrl );
		config.setPublicKey( publicKey );
		config.setSecretKey( secretKey );
		config.setPassphrase( passphrase );
    

Example

Get and list accounts example

import java.util.List;
import org.erc.coinbase.pro.exceptions.CoinbaseException;
import org.erc.coinbase.pro.model.Account;
import org.erc.coinbase.pro.rest.RESTClient;
import org.erc.coinbase.pro.Client;
import org.erc.coinbase.pro.rest.ClientConfig;
import org.erc.coinbase.pro.rest.ProxyConfig;

public class Start {

	public static void main(String[] args) throws CoinbaseException {
		
		ClientConfig config = new ClientConfig();
		config.setBaseUrl("https://api.pro.coinbase.com");
		config.setPublicKey(< your public key >);
		config.setSecretKey(< your secret >);
		config.setPassphrase(< your passphrase >);
		
		ProxyConfig proxyConfig = new ProxyConfig();
		proxyConfig.setHost("127.0.0.1");
		proxyConfig.setPort(8080);
		proxyConfig.setUser("myuser");
		proxyConfig.setPass("mypassword");
		config.setProxy(proxyConfig);
		
		Client client = new RESTClient(config);
		List<Account> accounts = client.getAccounts(null);
		for (Account account: accounts){
			System.out.println(account.toString());
		}
	}
}
		

Client Usage

Working with exceptions

The API converts some HTTP error codes in different exceptions that a developer can use. All the exceptions contains the original JSON data and have CoinbaseException as parent

  • SignatureException: The signature is not correct when building
  • InvalidRequestException: The request is invalid. HTTP error 400 (See JSON for more information)
  • InvalidAPIKeyException: The request API is not valid when calling. HTTP error 401
  • ForbiddenException: The request is not allowed. HTTP error 403
  • NotFoundException: The endpoint not exists. HTTP error 404
  • TooManyRequestException: Too many request to the server. HTTP error 429
  • ServerException: Any other exception

Versions

Version
0.0.5
0.0.3