Skip to main content

Contributors Forks Stargazers Issues


CryptoStats

Cryptostats-Python

Cryptostats is a streaming cryptocurrency data and analytics service. You can read the documentation or visit the homepage.
This is a simple Python implementation of a Websocket to stream data, subscribe to and unsubscribe from channels.
Explore the docs »

View Example Web Platform · Cryptostats-Pythonrt Bug · Request Feature

About The Project

Cryptostats is a streaming analytics platform for cryptocurrencies. You can access analytics and normalized, multi-exchange data via API or web platform.

There are 25+ exchanges and over 15,000 instruments currently covered.

Check out the documentation or the homepage.

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

You will need Python 3.6+.

Installation

  1. pip install Cryptostats-Python

Usage

Subscribe to new channels using the additional subscribe and unsubscribe methods:

from CryptostatsPython.Cryptostats import Cryptostats
import time

# Configuration
API_KEY = "YOUR_API_KEY"
channels = ["deribit.BTC-PERPETUAL.trade", "BTCUSD perpetual.combined_orderbook"]

# Callbacks
def on_open(_):
    print("Opened")
    cryptostats.unsubscribe("deribit.BTC-PERPETUAL.trade")
    cryptostats.subscribe("deribit.ETH-PERPETUAL.trade")


def on_message(message):
    print(message)


def on_error(_, message):
    print(message)


# Usage of reconnect code is recommended for long-running connections
def on_close(_):
    print("Closed - reconnecting")
    cryptostats.connect()


cryptostats = Cryptostats(API_KEY, channels, on_open, on_message, on_error, on_close)

# Event loop
while True:
    time.sleep(1)

For more examples, please refer to the Documentation

Contributing

Feel free to contribute more examples or cool use cases.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Cryptostats - hello@cryptostats.dev

Project Link: https://github.com/Cryptostats/Cryptostats-Python

Dependencies

Full dependencies are provided below:

  • Dependencies

If installing from source you will need:

  pip install websocket-client
  pip install ujson

Metadata

Release files for Cryptostats-Python 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 Cryptostats-Python 1.0.0
File Size Uploaded
Cryptostats-Python-1.0.0.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Cryptostats-Python 1.0.0
File Interpreter ABI Platform
Cryptostats_Python-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / Cryptostats-Python-1.0.0.tar.gz

Download URL Cryptostats-Python-1.0.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
17c5290958bd8bba7f3485022ca3b7a1450e3b5a4b83bb5e778aabf4db705db4
BLAKE2b-256 checksum
How to use checksums
544debe1e1652c4bca753c345d79aef29f3967bf20fd66304e4dceba22662124
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release files / Cryptostats_Python-1.0.0-py3-none-any.whl

Download URL Cryptostats_Python-1.0.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aae474b93bef75b381b70a18b547869057d69d0e0282cb8dc6f7a022fa71e634
BLAKE2b-256 checksum
How to use checksums
5a62e0d633bce3373d15900a2d649161c6657877c83824f597025067a1019cd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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