A unified framework to connect to different Crypto Exchange websites.
I am NOT associated, I repeat NOT associated to any Exchange website. Please use at your OWN risk.
Want to help me? You can tip me :)
- BTC: 1B27qUNVjKSMwfnQ2oq9viDY1hE3JY6XmQ
-
Bittrex (https://www.bittrex.com/) Official API documentation: https://bittrex.com/home/api
-
Cryptopia (https://www.cryptopia.co.nz/) Official Public API documentation: https://www.cryptopia.co.nz/Forum/Thread/255
Official Private API documentation: https://www.cryptopia.co.nz/Forum/Thread/256
- Coinexchange (https://www.coinexchange.io/) NOTE, Coinexchange only has public api.
All the exchanges uses API keys. Each API key consists of a public and a private key. NEVER and I repeat NEVER expose your api keys to anybody! If somebody has your API keys, this person can sell/buy/withdraw from you account!
If you do suspect somebody has your api keys DELETE your api keys at once!!!
Also, a lot of exchanges have the option to make you api keys more secure with the option to sell/buy/withdra option. So if you can have an api key with only read rights and no sell/buy/withdraw right. But that depends on the exchange.
One more time: NEVER EXPOSE YOUR API KEYS TO ANYBODY!!!!
fetch the project via git:
$ git clone https://github.com/fransyozef/cryptofyer
Each exchange sits in its own folder and there you'll find 'config.example.inc.php'.
- Rename 'config.example.inc.php' to config.inc.php.
- Edit your key and secret in config.inc.php.
The exchange classes have some required functions to implement:
- buy() -> place a buy order
- sell() -> place a sell order
- getOrders() -> get open orders
- getOrder() -> get order
- cancel() -> cancel order
- getTicker() -> get currency information
- getCurrencyUrl() -> get the exchange currency detail url
- getMarketHistory() -> get market history
- getBalance() -> get balance
When I started with this unified api platform, I used Bittrex's API as a model. Bittrex's string literal for the marketpair is [market]-[currency] for example : BTC-ETH.
After Bittrex I implemented Cryptopia's API. Cryptopia's string literal for the marketpair is [currency]-[market] for example : ETH-BTC.
In order to normalize the market literal string you can use the getMarketPair() function.
$_market = "USDT";
$_currency = "BTC";
$exchange = new BittrexApi($apiKey , $apiSecret );
$market = $exchange->getMarketPair($_market , $_currency);
Here you see $market
has the value 'USDT-BTC'.
$_market = "USDT";
$_currency = "BTC";
$exchange = new CryptopiaApi($apiKey , $apiSecret );
$market = $exchange->getMarketPair($_market , $_currency);
Here you see $market
has the value 'BTC-USDT'.
In the future, each exchange api class has a getMarketPair()
function to retrieve the right pair notation.
Some functions requires the market string literal as argument. For example Bittrex's ticker:
$result = $exchange->getTicker(array("market" => "BTC-ETH"));
debug($result);
or Cryptopia's ticker :
$result = $exchange->getTicker(array("market" => "ETH-BTC"));
debug($result);
As you can see, the market
value is different. To normalize, I added 2 special arguments :
_market
_currency
for example :
$result = $exchange->getTicker(array("_market" => "BTC" , "_currency" => "ETH"));
debug($result);
The function will resolve the market pair with the getMarketPair()
function.
In the tests
folder you will find some examples where you can see the normalization of functions.
- More Exchanges Api
- Better unified functions/notations
- Cleanup code
- Better documentation