Package: anyex
A JavaScript / Python / PHP library for cryptocurrency trading and e-commerce with support for many bitcoin/ether/altcoin exchange markets and merchant APIs.Theanyexlibrary is used to connect and trade with cryptocurrency / altcoin exchanges and payment processing services worldwide. It provides quick access to market data for storage, analysis, visualization, indicator development, algorithmic trading, strategy backtesting, bot programming, webshop integration and related software engineering.It is intended to be used bycoders, developers, technically-skilled traders, data-scientists and financial analystsfor building trading algorithms on top of it.Current feature list:support for many exchange markets, even more upcoming soonfully implemented public and private APIs for all exchangesall currencies, altcoins and symbols, prices, order books, trades, tickers, etc…optional normalized data for cross-exchange or cross-currency analytics and arbitragean out-of-the box unified all-in-one API extremely easy to integrateworks in Node 7.6+, Python 2 and 3, PHP 5.3+, web browsersanyex on GitHub| Install | Usage |Manual|Examples|Changelog|ContributingSupported Cryptocurrency Exchange MarketsThe anyex library currently supports the following 114 cryptocurrency exchange markets and trading APIs:idnameverdoccountries_1broker1Broker2APIUS_1btcxe1BTCXE*APIPanamaacxACX2APIAustraliaallcoinAllcoin1APICanadaanxproANXPro2APIJapan, Singapore, Hong Kong, New ZealandbiboxBibox1APIChina, US, South KoreabinanceBinance*APIJapanbit2cBit2C*APIIsraelbitbankbitbank1APIJapanbitbayBitBay*APIPoland, EUbitfinexBitfinex1APIBritish Virgin Islandsbitfinex2Bitfinex v22APIBritish Virgin IslandsbitflyerbitFlyer1APIJapanbithumbBithumb*APISouth Koreabitkkbitkk1APIChinabitlishBitlish1APIUK, EU, RussiabitmarketBitMarket*APIPoland, EUbitmexBitMEX1APISeychellesbitsoBitso3APIMexicobitstampBitstamp2APIUKbitstamp1Bitstamp v11APIUKbittrexBittrex1.1APIUSbitzBit-Z1APIHong Kongbl3pBL3P1APINetherlands, EUbleutradeBleutrade2APIBrazilbraziliexBraziliex*APIBrazilbtcboxBtcBox1APIJapanbtcchinaBTCChina1APIChinabtcexchangeBTCExchange*APIPhilippinesbtcmarketsBTC Markets*APIAustraliabtctradeimBtcTrade.im*APIHong KongbtctradeuaBTC Trade UA*APIUkrainebtcturkBTCTurk*APITurkeybtcxBTCX1APIIceland, US, EUbxinthBX.in.th*APIThailandccexC-CEX*APIGermany, EUcexCEX.IO*APIUK, EU, Cyprus, RussiachbtcCHBTC1APIChinachilebitChileBit1APIChilecobinhoodCOBINHOOD*APITaiwancoincheckcoincheck*APIJapan, IndonesiacoineggCoinEgg*APIChina, UKcoinexCoinEx1APIChinacoinexchangeCoinExchange*APIIndia, Japan, South Korea, Vietnam, UScoinfloorcoinfloor*APIUKcoingiCoingi*APIPanama, Bulgaria, China, UScoinmarketcapCoinMarketCap1APIUScoinmateCoinMate*APIUK, Czech Republic, EUcoinnestcoinnest*APISouth KoreacoinoneCoinOne2APISouth KoreacoinsecureCoinsecure1APIIndiacoinspotCoinSpot*APIAustraliacoolcoinCoolCoin*APIHong KongcryptopiaCryptopia*APINew ZealanddsxDSX3APIUKethfinexEthfinex1APIBritish Virgin IslandsexmoEXMO1APISpain, RussiaexxEXX*APIChinaflowbtcflowBTC1APIBrazilfoxbitFoxBit1APIBrazilfybseFYB-SE*APISwedenfybsgFYB-SG*APISingaporegatecoinGatecoin*APIHong KonggateioGate.io2APIChinagdaxGDAX*APIUSgeminiGemini1APIUSgetbtcGetBTC*APISt. Vincent & Grenadines, RussiahadaxHADAX1APIChinahitbtcHitBTC1APIUKhitbtc2HitBTC v22APIUKhuobiHuobi3APIChinahuobicnyHuobi CNY1APIChinahuobiproHuobi Pro1APIChinaice3xICE3X*APISouth AfricaindependentreserveIndependent Reserve*APIAustralia, New ZealandindodaxINDODAX1.7APIIndonesiaitbititBit1APIUSjubijubi.com1APIChinakrakenKraken0APIUSkucoinKucoin1APIHong KongkunaKuna2APIUkrainelakebtcLakeBTC2APIUSlbankLBank1APIChinaliquiLiqui3APIUkrainelivecoinLiveCoin*APIUS, UK, Russialunoluno1APIUK, Singapore, South AfricalykkeLykke1APISwitzerlandmercadoMercado Bitcoin3APIBrazilmixcoinsMixCoins1APIUK, Hong KongnegociecoinsNegocieCoins3APIBrazilnovaNovaexchange2APITanzaniaokcoincnyOKCoin CNY1APIChinaokcoinusdOKCoin USD1APIChina, USokexOKEX1APIChina, USpaymiumPaymium1APIFrance, EUpoloniexPoloniex*APIUSqryptosQRYPTOS2APIChina, TaiwanquadrigacxQuadrigaCX2APICanadaquoinexQUOINEX2APIJapan, Singapore, VietnamsouthxchangeSouthXchange*APIArgentinasurbitcoinSurBitcoin1APIVenezuelatherockTheRockTrading1APIMaltatidebitTideBit2APIHong KongtidexTidex3APIUKurdubitUrduBit1APIPakistanvaultoroVaultoro1APISwitzerlandvbtcVBTC1APIVietnamvirwoxVirWoX*APIAustria, EUwexWEX3APINew ZealandxbtcexBTCe1APIRussiayobitYoBit3APIRussiayunbiYUNBI2APIChinazaifZaif1APIJapanzbZB1APIChinaThe list above is updated frequently, new crypto markets, altcoin exchanges, bug fixes, API endpoints are introduced and added on a regular basis. See theManualfor details. If you don’t find a cryptocurrency exchange market in the list above and/or want another exchange to be added, post or send us a link to it by opening an issue here on GitHub or via email.The library is underMIT license, that means it’s absolutely free for any developer to build commercial and opensource software on top of it, but use it at your own risk with no warranties, as is.InstallThe easiest way to install the anyex library is to use builtin package managers:anyex in **NPM**(JavaScript / Node v7.6+)anyex in **PyPI**(Python 2 and 3.5.3+)anyex in **Packagist/Composer**(PHP 5.3+)This library is shipped as an all-in-one module implementation with minimalistic dependencies and requirements:`js/<https://github.com/anyex/anyex/blob/master/js/>`__ in JavaScript`python/<https://github.com/anyex/anyex/blob/master/python/>`__ in Python (generated from JS)`php/<https://github.com/anyex/anyex/blob/master/php/>`__ in PHP (generated from JS)You can also clone it into your project directory fromanyex GitHub repository:gitclonehttps://github.com/anyex/anyex.gitAn alternative way of installing this library into your code is to copy a single file manually into your working directory with language extension appropriate for your environment.JavaScript (NPM)JavaScript version of anyex works both in Node and web browsers. Requires ES6 andasync/awaitsyntax support (Node 7.6.0+). When compiling with Webpack and Babel, make sure it isnot excludedin yourbabel-loaderconfig.anyex in **NPM**npminstallanyexvaranyex=require('anyex')console.log(anyex.exchanges)// print all available exchangesJavaScript (for use with the<script>tag):All-in-one browser bundle(dependencies included), served fromunpkg CDN, which is a fast, global content delivery network for everything on NPM.<scripttype="text/javascript"src="https://unpkg.com/anyex"></script>Creates a globalanyexobject:console.log(anyex.exchanges)// print all available exchangesPythonanyex in **PyPI**pipinstallanyeximportanyexprint(anyex.exchanges)# print a list of all available exchange classesThe library supports concurrent asynchronous mode with asyncio and async/await in Python 3.5.3+importanyex.asyncasanyex# link against the asynchronous version of anyexPHPThe anyex library in PHP:**``anyex.php``**It requires common PHP modules:cURLmbstring (using UTF-8 is highly recommended)PCREiconvinclude "anyex.php";
var_dump (\anyex\Exchange::$exchanges); // print a list of all available exchange classesDocumentationRead theManualfor more details.UsageIntroThe anyex library consists of a public part and a private part. Anyone can use the public part out-of-the-box immediately after installation. Public APIs open access to public information from all exchange markets without registering user accounts and without having API keys.Public APIs include the following:market datainstruments/trading pairsprice feeds (exchange rates)order bookstrade historytickersOHLC(V) for chartingother public endpointsFor trading with private APIs you need to obtain API keys from/to exchange markets. It often means registering with exchanges and creating API keys with your account. Most exchanges require personal info or identification. Some kind of verification may be necessary as well. If you want to trade you need to register yourself, this library will not create accounts or API keys for you. Some exchange APIs expose interface methods for registering an account from within the code itself, but most of exchanges don’t. You have to sign up and create API keys with their websites.Private APIs allow the following:manage personal account infoquery account balancestrade by making market and limit ordersdeposit and withdraw fiat and crypto fundsquery personal ordersget ledger historytransfer funds between accountsuse merchant servicesThis library implements full public and private REST APIs for all exchanges. WebSocket and FIX implementations in JavaScript, PHP, Python and other languages coming soon.The anyex library supports both camelcase notation (preferred in JavaScript) and underscore notation (preferred in Python and PHP), therefore all methods can be called in either notation or coding style in any language.// both of these notations work in JavaScript/Python/PHP
exchange.methodName ()  // camelcase pseudocode
exchange.method_name () // underscore pseudocodeRead theManualfor more details.JavaScript'use strict';constanyex=require('anyex');(asyncfunction(){letkraken=newanyex.kraken()letbitfinex=newanyex.bitfinex({verbose:true})lethuobi=newanyex.huobi()letokcoinusd=newanyex.okcoinusd({apiKey:'YOUR_PUBLIC_API_KEY',secret:'YOUR_SECRET_PRIVATE_KEY',})console.log(kraken.id,awaitkraken.loadMarkets())console.log(bitfinex.id,awaitbitfinex.loadMarkets())console.log(huobi.id,awaithuobi.loadMarkets())console.log(kraken.id,awaitkraken.fetchOrderBook(kraken.symbols[0]))console.log(bitfinex.id,awaitbitfinex.fetchTicker('BTC/USD'))console.log(huobi.id,awaithuobi.fetchTrades('ETH/CNY'))console.log(okcoinusd.id,awaitokcoinusd.fetchBalance())// sell 1 BTC/USD for market price, sell a bitcoin for dollars immediatelyconsole.log(okcoinusd.id,awaitokcoinusd.createMarketSellOrder('BTC/USD',1))// buy 1 BTC/USD for $2500, you pay $2500 and receive ฿1 when the order is closedconsole.log(okcoinusd.id,awaitokcoinusd.createLimitBuyOrder('BTC/USD',1,2500.00))// pass/redefine custom exchange-specific order params: type, amount, price or whatever// use a custom order typebitfinex.createLimitSellOrder('BTC/USD',1,10,{'type':'trailing-stop'})})();Python# coding=utf-8importanyexhitbtc=anyex.hitbtc({'verbose':True})bitmex=anyex.bitmex()huobi=anyex.huobi()exmo=anyex.exmo({'apiKey':'YOUR_PUBLIC_API_KEY','secret':'YOUR_SECRET_PRIVATE_KEY',})hitbtc_markets=hitbtc.load_markets()print(hitbtc.id,hitbtc_markets)print(bitmex.id,bitmex.load_markets())print(huobi.id,huobi.load_markets())print(hitbtc.fetch_order_book(hitbtc.symbols[0]))print(bitmex.fetch_ticker('BTC/USD'))print(huobi.fetch_trades('LTC/CNY'))print(exmo.fetch_balance())# sell one ฿ for market price and receive $ right nowprint(exmo.id,exmo.create_market_sell_order('BTC/USD',1))# limit buy BTC/EUR, you pay €2500 and receive ฿1  when the order is closedprint(exmo.id,exmo.create_limit_buy_order('BTC/EUR',1,2500.00))# pass/redefine custom exchange-specific order params: type, amount, price, flags, etc...kraken.create_market_buy_order('BTC/USD',1,{'trading_agreement':'agree'})PHPinclude 'anyex.php';

$poloniex = new \anyex\poloniex ();
$bittrex  = new \anyex\bittrex  (array ('verbose' => true));
$quoinex  = new \anyex\quoinex   ();
$zaif     = new \anyex\zaif     (array (
    'apiKey' => 'YOUR_PUBLIC_API_KEY',
    'secret' => 'YOUR_SECRET_PRIVATE_KEY',
));

$poloniex_markets = $poloniex->load_markets ();

var_dump ($poloniex_markets);
var_dump ($bittrex->load_markets ());
var_dump ($quoinex->load_markets ());

var_dump ($poloniex->fetch_order_book ($poloniex->symbols[0]));
var_dump ($bittrex->fetch_trades ('BTC/USD'));
var_dump ($quoinex->fetch_ticker ('ETH/EUR'));
var_dump ($zaif->fetch_ticker ('BTC/JPY'));

var_dump ($zaif->fetch_balance ());

// sell 1 BTC/JPY for market price, you pay ¥ and receive ฿ immediately
var_dump ($zaif->id, $zaif->create_market_sell_order ('BTC/JPY', 1));

// buy BTC/JPY, you receive ฿1 for ¥285000 when the order closes
var_dump ($zaif->id, $zaif->create_limit_buy_order ('BTC/JPY', 1, 285000));

// set a custom user-defined id to your order
$hitbtc->create_order ('BTC/USD', 'limit', 'buy', 1, 3000, array ('clientOrderId' => '123'));ContributingPlease read theCONTRIBUTINGdocument before making changes that you would like adopted in the code. Also, read theManualfor more details.Support Developer TeamWe are investing a significant amount of time into the development of this library. If anyex made your life easier and you like it and want to help us improve it further or if you want to speed up new features and exchanges, please, support us with a tip. We appreciate all contributions!SponsorsSupport this project by becoming a sponsor. Your logo will show up here with a link to your website.[Become a sponsor]BackersThank you to all our backers! [Become a backer]CryptoETH 0xa7c2b18b7c8b86984560cad3b1bc3224b388ded0
BTC 33RmVRfhK2WZVQR1R83h2e9yXoqRNDvJva
BCH 1GN9p233TvNcNQFthCgfiHUnj5JRKEc2Ze
LTC LbT8mkAqQBphc4yxLXEDgYDfEax74et3bPThank you!