geminex

Geminex is an Elixir client for Gemini's API, providing streamlined access to trading, account management, and market data. It simplifies integration with Gemini’s REST API, handling authentication, requests, and responses for both public and private endpoints.


License
Apache-2.0

Documentation

Geminex

Geminex is an Elixir client for the Gemini API, offering easy access to trading, account management, and market data. With both public and private endpoints, it supports order placement, balance checks, market data retrieval, and more, all while abstracting the complexities of API interaction.

Table of Contents

Features

  • Access to public API endpoints for market data and trading symbols
  • Private API for order placement, trades, account management, staking, and more
  • Built-in middleware for authentication and environment switching
  • Simplified error handling for cleaner code integration

Installation

Add geminex to your list of dependencies in mix.exs:

def deps do
  [
    {:geminex, "~> 0.0.1"}
  ]
end

Then, run:

mix deps.get

Configuration

Configure Geminex in your application’s configuration file. Set the environment and provide your Gemini API credentials. You can choose between sandbox and production environments.

config/config.exs:

import Config

config :geminex,
       environment: :sandbox,             # Options: :sandbox or :production
       api_key:     System.get_env("GEMINI_API_KEY"),
       api_secret:  System.get_env("GEMINI_API_SECRET")

Replace <api_key> and <api_secret> with your Gemini API credentials.

Usage

Geminex offers both public and private APIs for interacting with Gemini's exchange.

Public API

The public API allows access to trading symbols, order books, and market data. These endpoints do not require authentication.

# Retrieve all available trading symbols
{:ok, symbols} = Geminex.API.Public.symbols()

# Fetch ticker data for a specific symbol
{:ok, ticker_data} = Geminex.API.Public.ticker("btcusd")

Private API

The private API enables management of orders, trades, account settings, staking, and more. These endpoints require valid API credentials and are restricted by Gemini’s account access policies.

# Place a new order
{:ok, order_response} = Geminex.API.Private.new_order("btcusd", "0.1", "50000", "buy", "exchange limit", client_order_id: "order_12345")

# Retrieve account balance
{:ok, balances} = Geminex.API.Private.available_balances()

Error Handling

All functions return {:ok, result} on success and {:error, reason} on failure. You can use pattern matching to handle these responses effectively:

case Geminex.API.Public.symbols() do
  {:ok, symbols} ->
    IO.inspect(symbols)

  {:error, reason} ->
    IO.puts("Failed to retrieve symbols: #{inspect(reason)}")
end

Running Tests

To run tests:

mix test

Running Dialyzer

For static analysis with Dialyzer, make sure PLTs are built:

mix dialyzer --plt
mix dialyzer

Contributing

Feel free to open issues or submit PRs to enhance the functionality. Contributions are welcome!

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.