SDKs overview
Poloniex provides a REST API for developers to programmatically access market data, manage accounts, and execute trades on its cryptocurrency exchange. To streamline integration, Poloniex offers official Software Development Kits (SDKs) across several popular programming languages. These SDKs are designed to abstract the underlying HTTP requests, authentication mechanisms (such as HMAC-SHA256 for API key signing), and data parsing, allowing developers to focus on application logic rather than low-level API interactions. The official SDKs support both spot and futures trading functionalities, reflecting Poloniex's core offerings of spot trading and futures trading.
Beyond the official offerings, a vibrant community of developers contributes to a range of third-party libraries. These community-driven projects can offer support for additional languages, alternative architectural patterns, or specialized use cases not covered by the official SDKs. Developers are encouraged to consult the Poloniex developer documentation for specific API endpoints, rate limits, and security best practices, which are applicable regardless of whether an official or community library is used.
Official SDKs by language
Poloniex maintains official SDKs to facilitate integration with its trading platform. These SDKs are developed and supported by Poloniex, ensuring compatibility with the latest API versions and features. Each SDK provides a wrapper around the Poloniex REST API, simplifying tasks such as order placement, retrieving market data, and managing user accounts. The following table outlines the key official SDKs available, including their respective packages and typical installation commands.
| Language | Package/Repository | Install Command | Maturity |
|---|---|---|---|
| Python | poloniex-sdk-python |
pip install poloniex-sdk-python |
Stable |
| Java | poloniex-java-sdk (Maven/Gradle) |
Add dependency to pom.xml or build.gradle |
Stable |
| Go | poloniex-go-sdk |
go get github.com/poloniex/poloniex-go-sdk |
Stable |
| Node.js | poloniex-node-sdk |
npm install poloniex-node-sdk |
Stable |
| C++ | poloniex-cpp-sdk |
Manual build from source or package manager (details in docs) | Beta |
Each SDK typically includes modules for public market data (e.g., order books, ticker information) and private account-specific functions (e.g., placing orders, checking balances), which require API key authentication. Developers can find detailed documentation for each SDK, including API reference and usage examples, on the Poloniex developer portal.
Installation
Installing Poloniex SDKs generally follows the standard package management practices for each respective programming language. Below are common installation steps for the official SDKs. Prior to installation, ensure that the appropriate language runtime and package manager are installed on your system.
Python SDK
The Python SDK can be installed using pip, the Python package installer. It is recommended to use a virtual environment to manage dependencies.
python3 -m venv venv_poloniex
source venv_poloniex/bin/activate
pip install poloniex-sdk-python
Java SDK
For Java projects, the Poloniex SDK is typically integrated via Maven or Gradle. You need to add the SDK as a dependency in your project's configuration file.
Maven (pom.xml):
<dependencies>
<dependency>
<groupId>com.poloniex</groupId>
<artifactId>poloniex-java-sdk</artifactId>
<version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>
</dependencies>
Gradle (build.gradle):
dependencies {
implementation 'com.poloniex:poloniex-java-sdk:1.0.0' // Replace with the latest version
}
Go SDK
Go modules are used to manage dependencies for the Go SDK. You can fetch the module using the go get command.
go get github.com/poloniex/poloniex-go-sdk
Then, import it in your Go source files:
import "github.com/poloniex/poloniex-go-sdk/v2"
Node.js SDK
The Node.js SDK is available via npm, the Node.js package manager.
npm install poloniex-node-sdk
Or using Yarn:
yarn add poloniex-node-sdk
C++ SDK
The C++ SDK typically requires compiling from source. Developers should refer to the official Poloniex C++ SDK repository for specific build instructions, which may vary depending on the operating system and compiler environment. This often involves using CMake or a similar build system.
Quickstart example
This Python example demonstrates how to initialize the Poloniex SDK, retrieve the current ticker price for a specific trading pair (e.g., BTC_USDT), and fetch account balances. Before running this code, ensure you have installed the poloniex-sdk-python package and replaced the placeholder API key and secret with your actual Poloniex API credentials. API keys can be generated from your Poloniex account settings.
from poloniex import Poloniex
# Replace with your actual API Key and Secret
API_KEY = "YOUR_POLONIEX_API_KEY"
API_SECRET = "YOUR_POLONIEX_API_SECRET"
# Initialize the Poloniex API client
# For futures trading, you might need to specify a different host or client type
polo = Poloniex(API_KEY, API_SECRET)
# --- Public API Calls (no authentication needed) ---
# Get ticker for a specific pair
try:
ticker = polo.returnTicker()
btc_usdt_data = ticker.get('BTC_USDT')
if btc_usdt_data:
print(f"BTC/USDT Last Price: {btc_usdt_data['last']}")
print(f"BTC/USDT Ask Price: {btc_usdt_data['lowestAsk']}")
print(f"BTC/USDT Bid Price: {btc_usdt_data['highestBid']}")
else:
print("BTC_USDT ticker data not found.")
except Exception as e:
print(f"Error fetching ticker: {e}")
# --- Private API Calls (authentication needed) ---
# Get account balances
try:
balances = polo.returnBalances()
print("\nAccount Balances:")
for currency, amount in balances.items():
if float(amount) > 0:
print(f" {currency}: {amount}")
except Exception as e:
print(f"Error fetching balances: {e}")
# Place a test order (example - DO NOT RUN WITH REAL FUNDS WITHOUT UNDERSTANDING)
# This is a hypothetical example and may require specific parameters for actual execution.
# try:
# # Example: Buy 0.001 BTC with USDT at a specific price
# # Ensure you have sufficient USDT for this order and understand market conditions.
# order = polo.buy(currencyPair='USDT_BTC', rate='25000', amount='0.001')
# print(f"\nTest Buy Order Placed: {order}")
# except Exception as e:
# print(f"Error placing order: {e}")
This example demonstrates basic interaction with both public (returnTicker) and private (returnBalances) endpoints. For production applications, robust error handling, rate limit management, and secure API key storage are essential. The Mozilla Developer Network HTTP status codes documentation can provide context for understanding API responses, though specific error messages will be detailed in Poloniex's API documentation.
Community libraries
The Poloniex developer community has contributed various unofficial libraries and wrappers across different programming languages. These libraries often emerge to fill gaps in official support, provide alternative API designs, or cater to specific developer preferences. While not officially supported by Poloniex, they can be valuable resources for developers. When using community-contributed libraries, it is crucial to:
- Verify the source: Ensure the library comes from a reputable developer or repository.
- Check for active maintenance: Libraries that are actively maintained are more likely to be compatible with the latest Poloniex API changes and security standards.
- Review the code: Especially for libraries handling API keys and trading, a code review can help identify potential security vulnerabilities or inefficiencies.
- Consult documentation: Community libraries often have their own documentation, which should be consulted for usage instructions and specific features.
Examples of languages where community libraries might exist include Ruby, PHP, and C#. Developers can typically find these by searching GitHub or relevant package managers (e.g., RubyGems for Ruby, Packagist for PHP) using terms like "Poloniex API" or "Poloniex SDK." Always cross-reference their functionality and security practices with the official Poloniex API documentation to ensure proper and secure integration.