Skip to main content

CryptoWrapper

Python 3.7+

PEP8

Async support (without cache)

Handles configurable requests cache, retries and general request errors.


Installation:

pip install xnr-cryptowrapper

Functions:

Build around raw API commands, in order to allow users to more freely implement their own logic.
Each APIs endpoints are made directly available by the CryptoWrapper class.
More detailed informations contained in the docs below:

Description
CoinMarketCap.md Wrapper for the CoinMarketCap API
CryptoCompare.md Wrapper for the CryptoCompare API
BitMEX.md Wrapper for the BitMEX REST API
Binance.md Wrapper for the Binance APIs
BinanceDEX.md Wrapper for the Binance DEX API
Bitfinex.md Wrapper for the Bitfinex API
Deribit.md Wrapper for the Deribit API

Examples:

If unspecified, result will not be cached.
Retries avoided for errors (400, 401, 403, 404, 429, 500).
Rate limits informations generally present in responses to simplify the implementation of back off strategies.

CoinMarketCap.global_aggregate_metrics_latest_GET()

>>> from cryptowrapper import CryptoWrapper
>>> api_key = "Declare you API key"
>>> cmc = CryptoWrapper(api="CMC", api_key=api_key, cache_expire=240)
>>> cmc_wrapper = cmc.wrapper
>>> cmc_wrapper.global_aggregate_metrics_latest_GET(convert="GBP")
{
  'status': {
      'timestamp': '2019-02-02T10:36:40.928Z',
      'error_code': 0,
      'error_message': None,
      'elapsed': 6,
      'credit_count': 1
  },
  'data': {
      'active_cryptocurrencies': 2104,
      'active_market_pairs': 15817,
      'active_exchanges': 235,
      'eth_dominance': 9.87368,
      'btc_dominance': 53.2881,
      'quote': {
          'GBP': {
              'total_market_cap': 87645952771.31316,
              'total_volume_24h': 12135287028.006516,
              'last_updated': '2019-02-02T10:36:00.000Z'
          }
      },
      'last_updated': '2019-02-02T10:27:00.000Z'
  },
  'cached': False
}

BitMEX.chat_GET()

>>> from cryptowrapper import CryptoWrapper
>>> api_key = "Declare you API key"
>>> api_secret = "Declare you API secret"
>>> bitmex = CryptoWrapper(api="BitMEX", api_key=api_key, api_secret=api_secret)
>>> bitmex_wrapper = bitmex.wrapper
>>> bitmex_wrapper.chat_GET(count=2)
[
    {
        'id': 1,
        'date': '2014-11-24T12:00:21.539Z',
        'user': 'BitMEX_Sam',
        'message': 'Welcome to BitMEX! We are live.',
        'html': 'Welcome to BitMEX! We are live.',
        'fromBot': False,
        'channelID': 1,
        'cached': False
    },
    {
        'id': 2,
        'date': '2014-11-24T12:20:29.073Z',
        'user': 'BitMEX_Arthur',
        'message': 'Hello World',
        'html': 'Hello World',
        'fromBot': False,
        'channelID': 1,
        'cached': False
    },
    {
        'ratelimit': {
            'limit': '150',
            'remaining': '149',
            'reset': '1549626408'
        }
    }
]

Binance.ping_GET()

>>> from cryptowrapper import CryptoWrapper
>>> binance = CryptoWrapper(api="Binance")
>>> binance_wrapper = binance.wrapper
>>> binance_wrapper.ping_GET()
{
    'cached': False
}

BinanceDEX.getfunctions()

>>> from cryptowrapper import CryptoWrapper
>>> binance_dex = CryptoWrapper(api="BinanceDEX")
>>> binance_dex_wrapper = binance_dex.wrapper
>>> binance_dex_wrapper.__getfunctions__()
[
    'account_GET',
    'account_sequence_GET',
    'block_exchange_fee_GET',
    'broadcast_POST',
    'depth_GET',
    'fees_GET',
    'klines_GET',
    'markets_GET',
    'node_info_GET',
    'orders_closed_GET',
    'orders_id_GET',
    'orders_open_GET',
    'peers_GET',
    'ticker_24h_GET',
    'time_GET',
    'tokens_GET',
    'trades_GET',
    'transaction_GET',
    'transactions_GET',
    'transactions_in_block_GET',
    'validators_GET'
]

For a quick combined example see: example.py
For the async version see: async_example.py


Feedback:

Constructive feedback & bug reports are welcome.
Contact informations:

Metadata

Release files for xnr-cryptowrapper 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for xnr-cryptowrapper 0.1.1
File Interpreter ABI Platform
xnr_cryptowrapper-0.1.1-py3-none-any.whl Python 3 none any Details

Release files / xnr_cryptowrapper-0.1.1-py3-none-any.whl

Download URL xnr_cryptowrapper-0.1.1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c44904b1a4f675346621c74e94f543181e4a2e1f53cc64c7519b8f968c7494e
BLAKE2b-256 checksum
How to use checksums
423f7cd7b7eb17a0b54daa26a9bc9936e81a72a104c16e11b0ee8f6e15ef50d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page