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.
- Features
- Installation
- Configuration
- Usage
- Error Handling
- Running Tests
- Running Dialyzer
- Contributing
- License
- 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
Add geminex
to your list of dependencies in mix.exs
:
def deps do
[
{:geminex, "~> 0.0.1"}
]
end
Then, run:
mix deps.get
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.
Geminex offers both public and private APIs for interacting with Gemini's exchange.
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")
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()
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
To run tests:
mix test
For static analysis with Dialyzer, make sure PLTs are built:
mix dialyzer --plt
mix dialyzer
Feel free to open issues or submit PRs to enhance the functionality. Contributions are welcome!
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.