SDKs overview
Gemini offers a suite of official SDKs designed to streamline the integration of its cryptocurrency exchange and custody services into various applications. These SDKs encapsulate the complexities of interacting with the Gemini REST API and WebSocket API, providing language-specific interfaces for common operations such as placing orders, retrieving market data, and managing account balances. By abstracting HTTP requests, authentication, and response parsing, the SDKs aim to reduce development time and potential errors for developers building on the Gemini platform.
The official SDKs are maintained by Gemini and are generally recommended for their stability, security, and alignment with the latest API features and best practices. They support key functionalities for both individual and institutional clients, including access to ActiveTrader features, Gemini Earn, and custody services, subject to API permissions and account configurations. For detailed information on API endpoints and data structures, developers can refer to the Gemini REST API reference.
Official SDKs by language
Gemini provides official SDKs for several programming languages, enabling developers to choose the environment that best fits their project requirements. These SDKs are typically available through standard package managers for each respective language.
| Language | Package Name | Installation Command | Maturity / Status |
|---|---|---|---|
| Python | gemini-python |
pip install gemini-python |
Actively maintained |
| Node.js | gemini-api |
npm install gemini-api |
Actively maintained |
| Java | gemini-java |
Maven/Gradle dependency (see Gemini API documentation for specifics) | Actively maintained |
| Ruby | gemini-ruby |
gem install gemini-ruby |
Actively maintained |
| C# | Gemini.Api |
dotnet add package Gemini.Api |
Actively maintained |
Installation
Installing Gemini's official SDKs typically involves using the standard package manager for the chosen programming language. The following provides general installation instructions; always refer to the official Gemini documentation for the most up-to-date and language-specific instructions.
Python
The Python SDK can be installed using pip, the Python package installer:
pip install gemini-python
For virtual environments, activate your environment before running the installation command.
Node.js
The Node.js SDK is available via npm, the Node Package Manager:
npm install gemini-api
This command will add the gemini-api package to your project's dependencies.
Java
For Java projects, the Gemini SDK is typically integrated using build tools like Maven or Gradle. You would add the appropriate dependency to your pom.xml (Maven) or build.gradle (Gradle) file. An example Maven dependency might look like this (version numbers may vary):
<dependency>
<groupId>com.gemini</groupId>
<artifactId>gemini-java</artifactId>
<version>1.0.0</version>
</dependency>
Consult the Gemini Java SDK documentation for the exact dependency coordinates.
Ruby
The Ruby SDK can be installed using the gem command:
gem install gemini-ruby
After installation, you can require the gem in your Ruby scripts.
C#
For C# projects, the SDK is available as a NuGet package and can be installed using the .NET CLI or Visual Studio's NuGet Package Manager:
dotnet add package Gemini.Api
Alternatively, in Visual Studio, search for "Gemini.Api" in the NuGet Package Manager.
Quickstart example
This Python example demonstrates how to initialize the Gemini API client and fetch the current ticker price for a specific trading pair. Before running, ensure you have installed the gemini-python SDK and replaced the placeholder API key and secret with your actual Gemini API credentials, which can be generated from your Gemini account settings.
import gemini
# Replace with your actual API key and secret
API_KEY = "YOUR_API_KEY"
API_SECRET = "YOUR_API_SECRET"
# Initialize the Gemini client
# For live trading, use 'livenet=True'
# For sandbox testing, use 'livenet=False' (default)
symbol = "btcusd"
client = gemini.GeminiClient(API_KEY, API_SECRET, livenet=False)
try:
# Get the current ticker information for BTCUSD
ticker = client.get_ticker(symbol)
print(f"Ticker for {symbol.upper()}:")
print(f" Bid: {ticker['bid']}")
print(f" Ask: {ticker['ask']}")
print(f" Last: {ticker['last']}")
print(f" Volume (24h): {ticker['volume']['USD']}")
# Example: Get your available balances (requires authentication)
# balances = client.get_balances()
# print("\nYour Balances:")
# for balance in balances:
# print(f" {balance['currency']}: {balance['available']} available, {balance['amount']} total")
except Exception as e:
print(f"An error occurred: {e}")
This snippet demonstrates basic market data retrieval. For authenticated calls, such as placing orders or checking balances, the API key and secret are essential. Always handle API credentials securely, for example, by using environment variables instead of hardcoding them directly in your code. The Google Cloud Python client library documentation offers general guidance on securing API keys.
Community libraries
Beyond the officially supported SDKs, the broader developer community has created and maintained various libraries that interact with the Gemini API. These community-driven projects can offer alternative language support, specialized functionalities, or different architectural approaches. While not officially endorsed or supported by Gemini, they can be valuable resources for developers seeking specific features or working in environments not covered by the official SDKs.
When considering community libraries, it is important to evaluate their maintenance status, security practices, and compatibility with the latest Gemini API versions. Checking the project's GitHub repository for recent commits, open issues, and pull requests can provide insight into its activity level. Examples of community libraries are often found on platforms like GitHub, PyPI, npm, and other language-specific package repositories by searching for "Gemini API" or "Gemini exchange" alongside the desired programming language.
Developers should exercise caution and conduct thorough security reviews before integrating third-party libraries into production environments, especially when dealing with financial transactions and sensitive API credentials. Always refer to the official Gemini API documentation as the authoritative source for API specifications and security guidelines, regardless of the client library used.