Skip to main content

Stream cryptocurrency data and analytics for 15,000+ instruments with a single websocket.

Project description

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

Project details


Download files

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

Source Distribution

Cryptostats-Python-1.0.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

Cryptostats_Python-1.0.0-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page