/gemini-python-wrapper

A python client for the Gemini API

Primary LanguagePythonMIT LicenseMIT

gemini-python-wrapper

A python client for the gemini API

Getting Started

PublicClient

This endpoint doesn't require an api-key and can be used without having a gemini account. This README will document some of the methods and features of the class.

import gemini
r = gemini.PublicClient()

PublicClient Methods

r.symbols()
r.get_ticker("BTCUSD")
r.get_current_order_book("BTCUSD")
# Will get the latest 500 trades
r.get_trade_history("BTCUSD")
# Alternatively, it can be specified for a specific date
r.get_trade_history("BTCUSD", since="17/06/2017")
# Note: 'since' is a keyword argument!
# Will get the latest 500 auctions
r.get_auction_history("BTCUSD")
# Alternatively, it can be specified for a specific date
r.get_auction_history("BTCUSD", since="17/06/2017")
# Note: 'since' is again a keyword argument!

PrivateClient

This endpoint requires both a public and private key to access the API. Hence, one must have an account with gemini and register an application. So far, if the 'heartbeat' option is enabled for the API, the user must manually revive the heartbeat. Further options will be added in the future in order to avoid doing this manually.

The payload of the requests will be a JSON object. Rather than being sent as the body of the POST request, gemini requires it to be base-64 encoded and stored as a header in the request. Adding a 'nonce' is optional for the API but is highly recommended. That's why the class will always send each request with a unique 'nonce'. An important point to note is that every argument for the methods of PrivateClient must be strings with the exception of 'options'.

import gemini
r = gemini.PrivateClient("EXAMPLE_PUBLIC_KEY", "EXAMPLE_PRIVATE_KEY")

PrivateClient Methods

r.new_order("BTCUSD", "200", "6000", "buy", ["immediate-or-cancel"])
r.cancel_order("866403510")
r.cancel_session_orders()
r.cancel_all_orders()
r.status_of_order("866403510")
r.active_orders()
# Will get the last 500 past trades
r.get_past_trades("BTCUSD")
# Alternatively, you can set the limit_trades number to your liking
r.get_past_trades("BTCUSD", limit_trades="200")
r.get_trade_volume()
r.get_balance()
# This will create a new currency address
r.create_deposit_address("BTCUSD")
# Alternatively, you can specify the label
r.create_deposit_address("BTCUSD", label="Main Bitcoin Address")
r.withdraw_to_address("ETH", "0x0287b1B0032Dc42c16640F71BA06F1A87C3a7101", "20")
r.revive_hearbeat()

Under Development