eitchtee / pyCelsiusNetwork

Unofficial Python Wrapper for the Celcius Network API

Home Page:https://pypi.org/project/pycelsiusnetwork/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyCelsiusNetwork

Unofficial Python Wrapper for the Celcius Network API

PyPI - License PyPI PyPI - Python Version PyPI - Downloads

🚧 Under development: Things will break and change abruptly. 🚧

What is this? | Requirements | Installation | Usage and Examples | Roadmap | Contributing | License


What is this?

pyCelsiusNetwork is a Python API Wrapper for Celsius Network public API. This package also offers a short-and-sweet abstraction layer, with functions like depagination of API Results, reversing, and filtering, but the raw JSON response is always one paramether away.

Requirements

You will need:

  • a Omnibus Treasury Partner Token, you can read on how to get one here.
  • a Celsius Account API Key, you can read on how to generate one here
  • a computer with Python 3.5+ and pip installed

Installation

With pip

$ pip install pycelsiusnetwork

Manual

  1. Clone this repository
  2. Run python setup.py install

Usage and Examples

Docs

Additional documentation is provided through the __doc__ attribute.

>> from pycelsiusnetwork import CelsiusNetwork

>> print(CelsiusNetwork.get_deposit_adress_for_coin.__doc__)

Initialization

from pycelsiusnetwork import CelsiusNetwork, Env

api = CelsiusNetwork(partner_token="PARTNER_TOKEN",
                     api_key="USER_API_KEY",
                     enviroment=Env.PRODUCTION)

Filtering transactions

You don't neet to set all filtering options, only the ones you want.

dt_from and dt_to also accepts datetime objects and other ISO compliant strings.

filtered_transactions = api.get_transactions(dt_from="2020-01-01",
                                             dt_to="2020-05-01",
                                             state="confirmed",
                                             nature="interest",
                                             amount_lower_than=2,
                                             amount_bigger_than=0.1)

Silence errors

By passing silent=True to any function or the API object itself, you can mute package exceptions, A.K.A. AbstractionFailure and CelsiusNetworkHTTPError, by doing so, None will be returned in the presence of an error instead of raising an Exception.

api = CelsiusNetwork("PARTNER_TOKEN",
                     "USER_API_KEY",
                     silent=True)

or

api.get_deposit_adress_for_coin('BTC', silent=True)

Also, if you pass silent=True to the API initialization, you can override it for any function by passing silent=False to it.

api = CelsiusNetwork("PARTNER_TOKEN",
                     "USER_API_KEY",
                     silent=True)

api.get_deposit_adress_for_coin('BTC', silent=False)

Getting the raw response

If you want to ignore the abstraction layer and get access to that juicy JSON directly, you can pass raw=True to any function, doing so, will make the function return the full response JSON.

api.get_supported_coins(raw=True)

Roadmap

  • GET Balance summary
  • GET Balance for coin
  • GET Transactions summary
  • GET Transactions for coin
  • GET Get deposit address
  • GET Interest Rates
  • GET KYC

Abstraction Layer

  • Option for returning raw JSON
  • Depagination for Transactions summary and Transactions for coin
  • Filtering for Transactions summary and Transactions for coin

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

Unofficial Python Wrapper for the Celcius Network API

https://pypi.org/project/pycelsiusnetwork/

License:MIT License


Languages

Language:Python 100.0%