Table of Contents
-
About The Project
-
Getting Started
- Usage
- Roadmap
- Contributing
- License
About The Project
A Python wrapper for the cryptocurrency exchange Gemini that offer both public and private REST APIs. Within your Gemini account settings, visit the API section to generate API keys for Account level use (Master level keys not yet supported by this wrapper).
When provisioning a session key, you have the option of marking the session as "Requires Heartbeat". When selected, if the exchange does not receive a message for 30 seconds,
then it will assume there has been an interruption in service and all outstanding orders on this session will be canceled. To maintain the session,
the you must send a heartbeat message (using the revive_heartbeat method in the 'order' endpoint) at a more frequent interval.
Public REST APIs provide market data such as:
- current order book
- recent trading activity
- trade history
Private REST APIs allow you to manage both orders and funds:
- place and cancel orders
- see your active orders
- see your trading history and trade volume
- get your available balances
In addition to the API key methods described in the private APIs, Gemini supports OAuth 2.0 flows and this is currently being developed for future implementation in this package.
Gemini's Sandbox site is an instance of the Gemini Exchange that offers exchange functionality using test funds - the Sandbox site URL is chosen for the connection
at the instantiation of the authentication class for the private API invocation.
To prevent abuse, Gemini imposes rate limits on incoming requests as described in the Gemini API Agreement.
For public API entry points, Gemini limit requests to 120 requests per minute, and recommend that you do not exceed 1 request per second.
For private API entry points, Gemini limit requests to 600 requests per minute, and recommend that you not exceed 5 requests per second.
(back to top)
Built With
(back to top)
Getting Started
The package is available on PyPI and can be installed using pip or poetry.
Installation
You'll need to have Python 3.6 or above. Package dependencies are listed in the poetry.lock file.
-
Sign in to Gemini and get API Keys https://exchange.gemini.com/
Note that this is for the real account - if you want to use the Sandbox Gemini account for testing, signup for a separate Sandbox account and create your keys there https://exchange.sandbox.gemini.com/
-
Install package
pip install gemini_api
- Stack some sats programmatically 😎
If you would like to edit the source code yourself
- Clone this repo
git clone https://github.com/eliasbenaddou/gemini_api
- Install required dependencies
poetry install
(back to top)
Usage Examples
Here is an example of creating a new order in the Sandbox test environment through the Order Placement API by instantiatng a new Authentication object with your public and private key and providing it to the Order class.
The class method 'new_order' will return an Order object and the 'order_id' attribute for the new order created is printed.
from gemini_api.endpoints.order import Order
from gemini_api.authentication import Authentication
auth = Authentication(
public_key="XXXXXXXXXX", private_key="XXXXXXXXXX", sandbox=True,
)
if __name__ == "__main__":
x = Order.new_order(
auth=auth,
symbol="btcusd",
amount="1",
price="20000",
side="buy",
options=["maker-or-cancel"],
)
print(x.order_id)
For more examples, please refer to the Documentation
(back to top)
Roadmap
(back to top)
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Don't forget to give the project a star if you found it useful! Thanks!
(back to top)
License
Distributed under the MIT License. See LICENSE.txt
for more information.
(back to top)
Disclaimer
This package connects to a live crytpcurrency exchange and the user takes full responsibility when using it. I am not liable for any costs or errors due to incorrect code or unanticipated actions. Use the Sandbox environment first to get familiar with the code and check it performs the expected actions.
If the user is not comfortable accepting the risks that come with using this program then they should not use it. It is licensed under an MIT license so you are free to dissect and use any part of this codebase as you wish.