Skip to main content

A Python wrapper for the Gemini cryptocurrency exchange API

Project description

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Gemini API Wrapper

A Python wrapper for the cyrptocurrency exchange Gemini.
Explore the docs »
View Blog Post · Report Bug/Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. 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

  • Python 3.8.11
  • Pyenv
  • Poetry

(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.

  1. 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/

  2. Install package

pip install gemini_api
  1. Stack some sats programmatically 😎

If you would like to edit the source code yourself

  1. Clone this repo
    git clone https://github.com/eliasbenaddou/gemini_api
    
  2. 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

  • Public APIs
    • Symbol Details
    • Ticker
    • Ticker V2
    • Candles
    • Current Order Book
    • Auction History
    • Price Feed
  • Order Placement APIs
    • New Order
    • Cancel Order
    • Wrap Order
    • Cancel All Session Orders
    • Cancel All Active Orders
  • Order Status APIs
    • Order Status
    • Get Active Orders
    • Get Past Orders
  • Fee and Volume APIs
    • Get Notional Volume
    • Get Trade Volume
  • FX Rate API
  • Fund Management APIs
    • Get Available Balances
    • Get Notional Balances
    • Custody Account Fees
    • Get Deposit Addresses
    • New Deposit Address
    • Withdraw Crypto Funds
    • Gas Fee Estimation
    • Internal Transfers (Requires Master level key)
    • Add Bank
    • Add A Bank CAD
    • Payment Methods
    • SEN Withdrawals
  • Approved Addresses APIs
  • Account Administration APIs
  • OAuth 2.0 Authentication
  • Websocket APIs
  • Gemini Clearing

(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".

  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

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.

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

gemini_api-0.1.6.tar.gz (24.1 kB view hashes)

Uploaded Source

Built Distribution

gemini_api-0.1.6-py3-none-any.whl (23.7 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