Giter Site home page Giter Site logo

aiobittrexapi's Introduction

Python Async Bittrex API Wrapper

This package is used by the Bittrex integration of Home Assistant.

PyPI version Python Tests Upload Python Package codecov

Available functions

The following functions are available:

from aiobittrexapi import Bittrex
api = Bittrex(api_key, api_secret)

api.get_account()
api.get_balances()
api.get_closed_orders()
api.get_markets()
api.get_open_orders()
api.get_tickers()

Example

from aiobittrexapi import Bittrex
from aiobittrexapi.errors import (
    BittrexApiError,
    BittrexResponseError,
    BittrexInvalidAuthentication,
)

import asyncio
from typing import Optional

API_KEY = ""
API_SECRET = ""


async def main(api_key: Optional[str] = None, api_secret: Optional[str] = None):
    if api_key and api_secret:
        api = Bittrex(api_key, api_secret)
    else:
        api = Bittrex()

    try:
        # Get the active markets from Bittrex - works mostly without secret & key
        markets = await api.get_markets()
        print(markets)

        # Get the tickers
        tickers = await api.get_tickers()
        print(tickers)

        # Get your account data - requires secret & key
        account = await api.get_account()
    except BittrexApiError as e:
        print(e)
    except BittrexResponseError as e:
        print("Invalid response:", e)
    except BittrexInvalidAuthentication:
        print("Invalid authentication. Please provide a correct API Key and Secret")
    else:
        print(account)
    finally:
        await api.close()


if __name__ == "__main__":
    loop = asyncio.get_event_loop()

    if API_KEY and API_SECRET:
        loop.run_until_complete(main(API_KEY, API_SECRET))
    else:
        loop.run_until_complete(main())

Feedback & Pull Requests

All feedback and Pull Requests are welcome!

Development

Don't forget to create your venv

python3 -m venv venv
source venv/bin/activate

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.