Skip to main content

Many cryptocurrency exchange APIs, a single and unified API client

Project description


Travis status Coverage

Many cryptocurrency exchange APIs, a single and unified API client 🙌


The project is hosted in PyPi, and you can install it using pip or pip3:

pip3 install xchange

Example of usage

>>> import os
>>> from xchange.factories import ExchangeClientFactory
>>> from xchange.constants import exchanges, currencies

# construct your API client
>>> ClientClass = ExchangeClientFactory.get_client(exchanges.KRAKEN)
>>> client = ClientClass(**{
...     "api_key": os.environ.get('KRAKEN_KEY'),
...     "api_secret": os.environ.get('KRAKEN_SECRET')
... })

# request API resources in an unified way
>>> ticker = client.get_ticker(currencies.BTC_USD)

>>> ticker
{'ask': Decimal('8590.00000'),
 'bid': Decimal('8589.90000'),
 'low': Decimal('8317.90000'),
 'high': Decimal('8610.00000'),
 'last': Decimal('8590.00000'),
 'volume': Decimal('1856.51064490')}

# API responses are wrapped into normalized models
>>> type(ticker)
<class 'xchange.models.kraken.KrakenTicker'>

# dynamic attribute assignation of response fields
>>> ticker.last

Polymorphic requests

>>> for exchange in exchanges.EXCHANGES:
...     client = ExchangeClientFactory.get_client(exchange)(**{
...         "api_key": "YOUR_KEY",
...         "api_secret": "YOUR_SECRET"
...     })
...     ticker = client.get_ticker(currencies.BTC_USD)
...     print("%s: $%d" % (exchange, ticker.last))

bitfinex: $8633
okex: $8749
kraken: $8633

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for xchange, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size xchange-0.0.6-py3-none-any.whl (39.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size xchange-0.0.6.tar.gz (26.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page