Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cryptoexchange

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cryptoexchange

  • 0.27.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

Cryptoexchange

Cryptoexchange is a rubygem for ruby developers to interact with over 200+ cryptocurrency exchange market data APIs in a single library.

Installation

Add this line to your application's Gemfile:

gem 'cryptoexchange'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cryptoexchange

Exchanges Supported

ExchangeTickerOrder BookTradeAccountMarket ListPair URLslug
58CoinYYYYYfifty_eight_coin
AbccYNNYYabcc
AbucoinsYYYYabucoins
ACXYYYYYacx
AEXYYYYaex
AirswapYairswap
AllbitYNNYYallbit
AllcoinYYYYallcoin
AllumaYNNYNalluma
AlterdiceYYYalterdice
AltillyYYYYYaltilly
AltmarketsYYYYYaltmarkets
ANXYUser-Definedanx
AphelionYYYaphelion
AXNETYYYYYaxnet
B2BXYYYb2bx
BancorYNNYbancor
BankeraYYYYYbankera
BcexYYYYYbcex
BcoinYYYbcoin
BgogoYYYYYbgogo
BiboxYYYYYbibox
BigONEYYYYYbigone
BilaxyYYYYYbilaxy
BinanceYYYYbinance
BishangYYbishang
BisqYYYbisq
Bit2CYYYUser-DefinedYbit2c
Bit-ZYYbit_z
BitbankYYYUser-DefinedYbitbank
BitbayYUser-Definedbitbay
BitbeginYNNYYbitbegin
BitBNSYYbitbns
Bitbox (Auth)YUser-DefinedYbitbox
Bitbox (Public)YYYbitbox
BitconnectYYbitconnect
BitebtcYYYYYbitebtc
Bitex.laYYYbitex
BitexliveYNNYYbitexlive
BitFex.TradeYYYbitfex
BitfinexYYbitfinex
BitflyerYYbitflyer
BitforexYNNYbitforex
BithashYYYYYbithash
BithumbYYbithumb
BitibuYYYYYbitibu
BitinfiYYYbitinfi
BitinkaYYYbitinka
BitkerYYYbitker
BitkonanYUser-Definedbitkonan
BitkubYYYYYbitkub
BitlishYYYYbitlish
BitmartYYYYbitmart
BitmaxYYYYYbitmax
BitmexYYYYbitmex
BitOnBayYYbitonbay
BitpactionYYYYbitpaction
BitrabbitYNNYYbitrabbit
BitrueYNNYYbitrue
Bits BlockchainYYYbits_blockchain
BitsaneYYYbitsane
BitsoYYbitso
BitstampYYYUser-Definedbitstamp
BitstenYYNYYbitsten
BittrexYYYbittrex
BkexYNNYYbkex
BleutradeYYbleutrade
BlockonixYYYYblockonix
BlokmyYYYYYblokmy
BraziliexYYYYbraziliex
BTC38
BTC-e
BtcAlphaYYYYYbtc_alpha
BTC ExchangeYYYYYbtc_exchange
BtcTradeUaYYYYYbtc_trade_ua
BTCBoxYYUser-DefinedYbtcbox
BTCCYUser-Definedbtcc
BTCChina
BTCMarketsYYYYbtcmarkets
BtcsquareYYUnstableYYbtcsquare
BTCTurkYYYbtcturk
BTERYYbter
BuyucoinYNNYbuyucoin
BX ThailandYYbx_thailand
BWYYYbw
BytexYNNYNbytex
C2CXYYNYc2cx
CPatexYYYYc_patex
CCexYYccex
CexYYYYcex
CfinexYYYYYcfinex
ChainceYYYchaince
ChainriftYYYYchainrift
ChainEXYYYYchainex
ChaoexYYYYNchaoex
CHBTCYUser-Definedchbtc
CobinhoodYYYYcobinhood
Coin2001YYYYcoin2001
CoinallYYYYcoinall
Coin AssetYYYYcoinasset
CoinchangexYNNYYcoinchangex
CoinEggYYYUser-DefinedYcoin_egg
CoinExchangeYYcoin_exchange
CoinbeYYcoinbe
CoinbeneYYYYYcoinbene
CoincheckYUser-Definedcoincheck
CoindealYYYcoindeal
CoindirectYNNYYcoindirect
CoinealYYYYcoineal
CoinexYYYYYcoinex
CoinfalconYYYYcoinfalcon
CoinfieldYNNYYcoinfield
CoingiYYYYYcoingi
CoinhouseYYYcoinhouse
CoinhubYYYYYcoinhub
CoinJarYYYYYcoinjar
CoinmateYYUser-Definedcoinmate
CoinmexYYYYcoinmex
CoinnestYYYUser-DefinedYcoinnest
CoinnoxYYYYcoinnox
CoinoneYYYYYcoinone
CoinparkYYYYYcoinpark
CoinplaceYYcoinplace
CoinrailYYYYYcoinrail
CoinroomYYcoinroom
CoinsMarketsYYcoin_markets
CoinsbankYYcoinsbank
CoinsbitYYcoinsbit
CoinstockYYYYcoinstock
CoinsuperYYYcoinsuper
CointigerYYYYcointiger
Coinut (Auth)YYYYYcoinut
CoinzestYYYcoinzest
COSSYYYcoss
CpdaxYYYYcpdax
CredoExYYcredoex
Crex24YYYYYcrex24
CRXZoneYYYYYcrxzone
CryptagioYYYYYcryptagio
CryptaldashYYYYcryptaldash
CryptexYYYUser-DefinedYcryptex
CryptoBridgeYYYcrypto_bridge
CryptoHubYNNYcrypto_hub
CryptobullsYNNYcryptobulls
CryptologyYYcryptology
CryptonitYYYYYcryptonit
CryptopiaYYYYcryptopia
CrytrexYYYYcrytrex
CybexYYYYcybex
DakuceYYYYdakuce
DcoinYNNYYdcoin
DdexYYYYYddex
DEEXYYdeex
DEx.topYYYYdextop
DigifinexYYdigifinex
DobitradeYYNYYdobitrade
DragonexYYNYYdragonex
DsxYYYYdsx
ErcdexYYYerxdex
EscodexYYYescodex
EtherDeltaYYether_delta
EtherflyerYYNYYetherflyer
EthexYNNYNethex
EthfinexYYYYYethfinex
EverbloomYYeverbloom
ExmoYYYYYexmo
ExratesYNNYYexrates
ExtstockYYYYYextstock
ExxYYYYYexx
F1cxYYYYYf1cx
FatBTCYYYYfatbtc
FcoinYYYYYfcoin
FexYNNYfex
FiscoYYYYYfisco
ForkdeltaYNNYYforkdelta
FreiexchangeYYUser-DefinedYfreiexchange
FinexBoxYYYYfinexbox
GateYYYYYgate
GatecoinYYgatecoin
GDAX(Coinbase Pro)YYYgdax
GeminiYYYYgemini
GetBTCYYYUser-DefinedYgetbtc
GibraltarYNNYYgbx
GobabaYYgobaba
golix (API Failed)YYYgolix
GOPAXYYYYYgopax
GraviexYNNYgraviex
HadaxYNNYYhadax
Hb.topYNNYNhb_top
HikenexYNNYNhikenex
HitBTCYYYYYhitbtc
HotbitYNNYYhotbit
HPXYYYYhpx
HuobiYYYhuobi
Ice3xYYYYice3x
IdaxYNNYYidax
IdcmYYYidcm
IdexYUnstableYYYidex
IncorexYYYYYincorex
IndodaxYYYUser-DefinedNindodax
InfinityCoinYYYinfinity_coin
InstantBitexYYYYinstantbitex
IqfinexYYYYY
IronexYYironex
ItbitYYYUser-Defineditbit
JexYNNYjex
JoysoYYYjoyso
JubiYYjubi
KairexYYYkairex
KKexYYYYYk_kex
KkcoinYYYYYkkcoin
KoinexYYkoinex
KoinokYYYkoinok
KorbitYUser-DefinedYkorbit
KrakenYYYkraken
KryptonoYYYUser-DefinedYkryptono
KucoinYYYYYkucoin
KunaYYYUser-DefinedYkuna
KyberNetworkYNNYYkyber_network
LakeBTCYYYlakebtc
LatokenYYYlatoken
LbankYYYYYlbank
LetsdocoinzYYletsdocoinz
LiquiYYliqui
LiteBit.euYYlitebiteu
LivecoinYYlivecoin
LunoYYYluno
LykkeYYNYlykke
MaplechangeYYYYmaplechange
MaxMaicoinYYYYYmax_maicoin
MercadoBitcoinYUser-Definedmercado_bitcoin
MercatoxYNNNYmercatox
MyspeedtradeYYYmyspeedtrade
NanexYNNNYnanex
Nanu.ExchangeYYYYnanu_exchange
NebulaYNYYnebula
NegociecoinsYYYUser-Definednegociecoins
NeraexYYYYYneraex
NewdexYNNYYnewdex
NinecoinYYninecoin
NLexchYYYnlexch
NovadexYNNYYnovadex
NovadaxYNYUser-DefinedNnovadax
NusaxYYYnusax
Nova ExchangeYYnovaexchange
OasisDEXYYoasisdex
OAXYYoax
OctaexYYYYoctaex
OKCoinYUser-Definedokcoin
OKExYYYYYokex
OmniTradeYYYYYomnitrade
OoobtcYYYYYooobtc
OpenledgerYYYYYopenledger
OrderBookYYYYYorderbook
Ore BzYYYYYore_bz
OTCBTCYYYYotcbtc
P2pb2bYYYYp2pb2b
ParibuYYparibu
Paro ExchangeYYparoexchange
PaymiumYYYUser-Definedpaymium
PoloniexYYYpoloniex
PurcowYYYpurcow
QBTCYYYYqbtc
QryptosYYqryptos
QuadrigaCXYUser-Definedquadrigacx
QuoineYYYquoine
RadarRelayYYYradar_relay
RaisexYYraisex
RfinexYYYYrfinex
RightBTCYYYYrightbtc
SafeTradeYNNYsafe_trade
SecondbtcYNNYYsecondbtc
SigenYYYsigen
SimexYNNYYsimex
SingularxYNNYsingularx
SistemkoinYYsistemkoin
SouthXchangeYYYYYsouth_xchange
Stocks ExchangeYYYstocks_exchange
SwiftexYYYYswiftex
SwitcheoYNNYYswitcheo
SyexYNNYYsyex
SZZCYYszzc
TdaxYNNYYtdax
The Rock TradingYYtherocktrading
The Token StoreYYYYYthetokenstore
ThinkbitYYYYthinkbit
TidealYYYYtideal
TidebitYYYYtidebit
TidexYYtidex
TokenjarYYtokenjar
TokenomyYYYYYtokenomy
TokensNetYYYYNtokens_net
TokokYYYYtokok
TopbtcYNNYYtopbtc
TradeOgreYYYYYtrade_ogre
Trade SatoshiYYYtrade_satoshi
Trade.ioYYtradeio
Trade.mnYYYYtrademn
TrocaNinjaYNNYtroca_ninja
TrustDex **YYtrust_dex
TuxExchangeYYtux_exchange
UEXYYuex
Unocoinunocoin
UpbitYYYYYupbit
VaultmexYYYYYvaultmex
VbitexYNNYYvbitex
VebitcoinYNNYNvebitcoin
VertpigYYNYYvertpig
ViabtcYUser-Definedviabtc
WavesYNYYwaves
WazirXYYwazirx
WcxYYYYwcx
WexYYYYYwex
WorldcoreYYYYYworldcore
YobitYYYyobit
YuanbaoYUser-Definedyuanbao
YunbiYYyunbi
ZaifYYYYYzaif
ZBYYYYYzb
ZBGYYYYzbg
ZebpayYYZebpay
ZeniexYYYYzeniex
ZG.TOPYYYYzgtop

** Mapping and data may be incorrect (Cannot determine correctness)

*** User-Defined requires pair id

Usage

List market pairs supported by an exchange

  client = Cryptoexchange::Client.new
  pairs = client.pairs('bitflyer')

List exchange services for certain currency

  client.exchange_for('btc')

  # ['anx', 'binance', ...]

Query the Ticker API

  pair = client.pairs('bitflyer').first
  ticker = client.ticker(pair)
  ticker.base
  ticker.target
  ticker.last

Query the Ticker stream API

  pair = client.pairs('bitfinex').first
  thread = client.ticker_stream(
    market_pair: pair,
    onopen: Proc.new { puts 'Opened!' },
    onmessage: Proc.new do |ticker|
                 puts ticker.base
                 puts ticker.target
                 puts ticker.last
                 # ...
               end,
    onclose: Proc.new { puts 'Closed!' },
  )

  thread.kill

Query the OrderBook API

  # Check if exchange has support for OrderBook
  pair = client.pairs('bitbank').first
  order_book = client.order_book(pair)
  order_book.base
  order_book.target
  order_book.bids
  order_book.asks

Query the OrderBook stream API

  pair = client.pairs('bitfinex').first
  thread = client.order_book_stream(
    market_pair: pair,
    onopen: Proc.new { puts 'Opened!' },
    onmessage: Proc.new do |order_book|
                 puts order_book.asks[0].price if order_book.asks[0]
                 puts order_book.bids[0].price if order_book.bids[0]
                 # ...
               end,
    onclose: Proc.new { puts 'Closed!' },
  )

  thread.kill

Query the Trades API

  # Check if exchange has support for Trades
  # returns array

  pair = client.pairs('neraex').first
  trades = client.trades(pair)
  trades[0].base
  trades[0].target
  trades[0].price
  trades[0].amount

Query the Trade stream API

  pair = client.pairs('bitfinex').first
  thread = client.trade_stream(
    market_pair: pair,
    onopen: Proc.new { puts 'Opened!' },
    onmessage: Proc.new do |trade|
                 puts trade.trade_id
                 puts trade.price
                 puts trade.amount
                 # ...
               end,
    onclose: Proc.new { puts 'Closed!' },
  )

  thread.kill

Get Exchange Trade URL (Work in Progress)

  client.trade_page_url 'binance', base: 'BTC', target: 'USDT'

Market List

Some exchange API do not support market pair listings. For those exchanges, we included a custom YML file to define the list of market pairs supported by that exchange. That configuration works out of the box, however if that exchange adds new market pairs, you as the user of Cryptoexchange can explicitly add those pairs instead of waiting for this library to be updated.

In the table above, look for the User-Defined under the Market List column.

The format of the yaml file should look like below. Name the file <exchange_name>.yml and place it under the config/cryptoexchange directory.

  :pairs:
    - :base: BTC
      :target: KRW
    - :base: ETH
      :target: KRW
    - :base: ETC
      :target: KRW

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/coingecko/cryptoexchange. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

When implementing a new exchange for HTTP API, refer to this guide. For Websocket API, refer to this guide

The contributing guide may also be useful to you.

You can chat with the core team member or other participating in this repository chat on https://gitter.im/cryptoexchange-api/Lobby/~chat#

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 14 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc