Skip to main content

BitEx Framework - Bitcoin Exchange REST APIs

CI Status Documentation Status

Bitex is a python3 library for making requests to crypto currency exchanges a breeze. With the ever increasing number of exchanges setting up shop, it becomes increasingly more difficult to acquire data in a convenient way. This is mostly due to the fact that each exchange cooks up their own API spec, with no general consensus on HTTP methods, input format or authentication method.

Bitex aims to abstract the gritty details of exchange APIs away, by supplying extensions to the popular requests library.

Under the hood, BitEx is powered by Bitex-Framework, as lightweight framework laying the foundation for its features.

Features

  • Easy to use: Bitex is an extension to the requests library, adding

    under-the-hood magic to take care of formatting and authenticating requests to exchanges.

  • Extensible: Bitex uses requests and a simple hook system to allow developers

    to create their own API wrappers. Can’t find an extension for the exchange of your choice? Simply write your own!

  • Sensible set of default methods: Our BitexSession object supplies a robust set

    of common API operations, ranging from requesting market data to order modification, as well as withdrawal and deposit methods.

Installation

Installation is simple, as it should be:

pip install bitex-framework

bitex-framework, being the core module, does not come with any extensions. But fret not! Plugins for exchanges are available via pip as well, under the bitex namespace like so:

pip install bitex-${EXCHANGE_NAME}

If you’d like to install the full suite of bells and whistles, try:

pip install bitex

to install all of bitex’s verified REST API plugins along with the core framework module.

Qickstart

After installing, requesting data is easy:

>>>from bitex import BitexSession
>>>session = BitexSession()
# bitex.BitexSession provides a set of methods to execute the most common queries
>>>r = session.ticker("kraken", "BTCUSD")
# The response objects returned are bitex.BitexResponses, which behave like regular requests.Response objects.
>>>r
<KrakenResponse [200]>
>>>r.json()
{
    "error":[],
    "result": {
        "XXBTZUSD":{
            "a":["3809.10000","1","1.000"],
            "b":["3809.00000","1","1.000"],
            "c":["3809.60000","0.11007700"],
            "v":["1378.29558699","4120.69226171"],
            "p":["3798.72908","3797.90051"],
            "t":[1960,5958],
            "l":["3776.90000","3775.80000"],
            "h":["3817.60000","3819.30000"],
            "o":"3796.20000"
        }
    }
}
# Additionally, plugins may supply improved data formats for consumptions by other libraries, such as pandas:
>>>r.key_value_dict()
{
    "ts": 12432153,
    "error": [],
    "pair": "XXBTZUSD",
    "ask": "3809.10000",
    "ask_whole_lot": "1",
    "ask_lot": "1.000",
    "bid":"3809.00000",
    "bid_whole_lot": "1",
    "bid_lot": "1.000",
    "last_closed": "3809.60000",
    "last_closed_lot": "0.11007700",
    "vol_today": "1378.29558699",
    "vol_24h": "4120.69226171",
    "vwap_today": "3798.72908",
    "vwap_24h": "3797.90051",
    "trades_today": 1960,
    "trades_24h": 5958,
    "low_today": "3776.90000",
    "low_24h": "3775.80000",
    "high_today": "3817.60000",
    "high_24h": "3819.30000",
    "open":"3796.20000"
}
# Or for storing them as timestamp-label-value triples
>>>r.triples()
[
    (12432153, "error", []),
    (12432153, "pair", "XXBTZUSD"),
    (12432153, "ask", "3809.10000"),
    (12432153, "ask_whole_lot", "1"),
    (12432153, "ask_lot", "1.000"),
    (12432153, "bid":"3809.00000"),
    (12432153, "bid_whole_lot", "1"),
    (12432153, "bid_lot", "1.000"),
    (12432153, "last_closed", "3809.60000"),
    (12432153, "last_closed_lot", "0.11007700"),
    (12432153, "vol_today", "1378.29558699"),
    (12432153, "vol_24h", "4120.69226171"),
    (12432153, "vwap_today", "3798.72908"),
    (12432153, "vwap_24h", "3797.90051"),
    (12432153, "trades_today", 1960,
    (12432153, "trades_24h", 5958,
    (12432153, "low_today", "3776.90000"),
    (12432153, "low_24h", "3775.80000"),
    (12432153, "high_today", "3817.60000"),
    (12432153, "high_24h", "3819.30000"),
    (12432153, "open", "3796.20000"),
]

Development

If you’re looking to work on or with bitex-framework, you’ll want the development environment setup. We’ve supplied a few make targets to make your life easier:

# Install bitex and its development requirements
make development

We also supply targets to run code formatters, linters and tests:

# Run code formatters
make pretty

# Verify code style
make style-check

# Run tests via tox
tox -e testenv

If you’d like to contribute to the project, please have a look at CONTRIBUTING.rst on some general pointers about how development takes place, what the expected steps of you are and what requirements we have to merge a PR.

Metadata

Release files for bitex-framework 1.0.0

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

Source distribution (sdist)

Source distribution for bitex-framework 1.0.0
File Size Uploaded
bitex-framework-1.0.0.tar.gz 16.6 kB Details

Release files / bitex-framework-1.0.0.tar.gz

Download URL bitex-framework-1.0.0.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
43df7b09c058540111a55a5f66b80583f378622209b67b0f9a3b84a4d79f646e
BLAKE2b-256 checksum
How to use checksums
951292dbac74db46d88fd7d54291fa547b7f58cc1a5e856cec0cd7a39322f911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.5

Release history Release notifications | RSS feed

1.2.3

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.1

1 release file

This release

1.0.0 This release

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