Giter Club home page Giter Club logo

bitstamp_java_lib's Introduction

API client of BitStamp in Java

BitStamp API client logo

Query the BitStamp API in Java 17. No external libraries used. And It is compatible with android.

How to use

It is a maven project, to create the JAR package only execute mvn clean package -DskipTests and it will be in the target folder.

Example

Login

import com.diego_hernando.bitStamp_java_lib.BitStampAPI;
...
BitStampApi api=new BitStampAPI();
api.setId("id");
api.setKey("key");
api.setSecret("secret");

Operations

import com.diego_hernando.bitStamp_java_lib.BitStampCurrencyPairs;
...

//Get the balance of ETH and EUR from your account.
String ethEurBalance=api.getBalance(BitStampCurrencyPairs.ETHEUR);

//Get all transactions that you have done in BitStamp.
String transactions=api.getMyTransactions();

//Get your open orders in BitStamp.
String openOrders=api.getOpenOrders();

All operations of the API are available except all relating to depositing and withdrawing operations.

** All operations return a String with the JSON response of the server, It is responsability of the user parse and check the JSON.**

Use real time transactions websocket

import com.diego_hernando.bitStamp_java_lib.BitStampCurrencyPairs;
import com.diego_hernando.bitStamp_java_lib.ApiWebsocketTransactions;
import com.diego_hernando.bitStamp_java_lib.WebsocketErrorListener;
import com.diego_hernando.bitStamp_java_lib.WebsocketTradeDoneListener;
...

//Implementation of listener for errors produced in websocket.
WebsocketErrorListener wbErrListener=new WebsocketErrorListener() {

	@Override
	public void onError(String error, String errorCode, ApiWebsocketTransactions webSocket) {
		//Your code

	}
};

//Implementation of listener for transactions, that are received by websocket.
WebsocketTradeDoneListener wbTradeDoneListener=new WebsocketTradeDoneListener() {

	@Override
	public void onTradeDone(String jsonTrade, BitStampCurrencyPairs tradingPair) {
		//Your code
	}
};

ApiWebsocketTransactions wbs=new BitStampAPI().getWebSocketOfTransactions(wbErrListener,wbTradeDoneListener);

//The method openChannel, only opens a chanel to receive data of the BitStamp currency pair passed by argument.
wbs.openChannel(BitStampCurrencyPairs.ETHEUR);
//The method openAllChannels opens chanels to receive data of all BitStamp currency pairs.
//wbs.openAllChannels();

//Connect websocket
wbs.connect();
....

//Disconnect websocket
wbs.disconnect();

This implementation recconect automatically. Unless it suffers a irrecoverable error, in that case It executes the method onError of WebsocketErrorListener.

Test execution

If you want to run the test, you will need a BitStamp account and create an access to the API, and complete with your access data the fields of ApiLoginDataTest.java before to execute BitStampAPITest.java.

If you want to execute test with maven input this in the console: mvn test

API definition

https://www.bitstamp.net/api/

Development status

Now this project is in beta, the buying and selling operations need to be tested in depth.

And in a future implement public open data operations with the websocket API.

Contributors

Any contributions are highly appreciated. The best way to contribute code is to open a pull request on GitHub.

License

MIT License.

bitstamp_java_lib's People

Contributors

diegohr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bitstamp_java_lib's Issues

maven fails when installing due to test erros

mvn clean install yields

Results :

Failed tests: signatureTest(com.diego_hernando.bitStamp_java_lib.tests.BitStampAPITest): expected:<[signature]> but was:<[55D1CC9CC666ED204520273A044599EFDF1780DBEB5D76CE51CBA77F237BFD44]>

Tests in error:
getBalanceEthEurTest(com.diego_hernando.bitStamp_java_lib.tests.BitStampAPITest): Status code 403
getAllOpenOrdersTest(com.diego_hernando.bitStamp_java_lib.tests.BitStampAPITest): Status code 403
getBalanceTest(com.diego_hernando.bitStamp_java_lib.tests.BitStampAPITest): Status code 403
getMyTransactionsEthEurTest(com.diego_hernando.bitStamp_java_lib.tests.BitStampAPITest): Status code 403
getOpenOrdersEthEurTest(com.diego_hernando.bitStamp_java_lib.tests.BitStampAPITest): Status code 403
getAllMyTransactionsTest(com.diego_hernando.bitStamp_java_lib.tests.BitStampAPITest): Status code 403

Tests run: 13, Failures: 1, Errors: 6, Skipped: 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.