xchange
Many cryptocurrency exchange APIs, a single and unified API client 🙌
Installation
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
Decimal('8638.10000')
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
Release files for xchange 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| xchange-0.0.6.tar.gz | 26.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xchange-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 65.8 kB
Release files / xchange-0.0.6.tar.gz
| Download URL | xchange-0.0.6.tar.gz |
|---|---|
| Size | 26.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
003bf6a43504084d4f5488fe8234a540d85d6ddd882d8f8e5962e09283eb5662
|
|
BLAKE2b-256 checksum How to use checksums |
ff69635c65f141beedc30f2b1ceffb62b68afcd5e448835425be8d0e1d3a267b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
|
Release files / xchange-0.0.6-py3-none-any.whl
| Download URL | xchange-0.0.6-py3-none-any.whl |
|---|---|
| Size | 39.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
642a7eec976b57f5637bad73b48421815f8cdcca8fed78d941c8ef6311dff526
|
|
BLAKE2b-256 checksum How to use checksums |
333c3b52f777866fe40d0d44f06a53518a31cf1d62bdda49a6321f05310db839
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
|