Unofficial OrionX Ruby SDK
The unofficial OrionX SDK for Ruby - A comprehensive Ruby library for interacting with the OrionX cryptocurrency exchange API.

Features
- 🔐 Secure Authentication - HMAC-SHA512 signature authentication
- 🐛 Debug Mode - Comprehensive logging and debugging capabilities
- 🛡️ Error Handling - Robust error handling with custom exception classes
- 🔄 Auto Retry - Automatic retry mechanism for failed requests
- 📈 Trading Operations - Full support for limit, market, and stop orders
- 💰 Account Management - Balance inquiries and account information
- 📊 Market Data - Real-time market data and orderbook information
- 💸 Transactions - Transaction history and cryptocurrency transfers
- 🧪 Comprehensive Tests - Well-tested with RSpec
- 📚 Rich Examples - Multiple usage examples included
Installation
Add this line to your application's Gemfile:
gem 'orionx-sdk'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install orionx-sdk
Quick Start
1. Get Your API Credentials
First, you'll need to get your API credentials from OrionX:
2. Configuration
Configure the SDK with your credentials:
require 'orionx'
OrionX.configure do |config|
config.api_key = 'your-api-key'
config.api_secret = 'your-api-secret'
config.debug = true
end
client = OrionX::Client.new
Or configure per client instance:
client = OrionX::Client.new(
api_key: 'your-api-key',
api_secret: 'your-api-secret',
debug: true
)
3. Basic Usage
ping = client.ping
puts ping
user = client.me
puts user['name']
balances = client.accounts.get_balances
balances.each do |balance|
puts "#{balance[:currency]}: #{balance[:balance]}"
end
market = client.markets.get_market('BTCCLP')
puts "BTC/CLP Last Price: #{market.dig('lastTrade', 'price')}"
API Reference
User Operations
user = client.user.me
user_id = client.user.user_id
Account Management
balances = client.accounts.get_balances
btc_account = client.accounts.get_account('BTC')
btc_balance = client.accounts.get_balance('BTC')
Market Data
markets = client.markets.get_markets
btc_market = client.markets.get_market('BTCCLP')
orderbook = client.markets.get_orderbook('BTCCLP', limit: 10)
stats = client.markets.get_market_stats('BTCCLP')
Order Management
orders = client.orders.get_orders(onlyOpen: true, limit: 10)
order = client.orders.get_order('order_id')
limit_order = client.orders.place_limit_order(
market_code: 'BTCCLP',
amount: 10000,
limit_price: 50000000,
sell: false
)
market_order = client.orders.place_market_order(
market_code: 'BTCCLP',
amount: 10000,
sell: false
)
stop_order = client.orders.place_stop_limit_order(
market_code: 'BTCCLP',
stop_price_up: 52000000,
stop_price_down: 48000000,
amount: 10000,
limit_price: 50000000,
sell: true
)
cancelled = client.orders.cancel_order('order_id')
Transaction Operations
transactions = client.transactions.get_transactions(
limit: 20,
page: 1,
types: ['trade-in', 'trade-out']
)
transaction = client.transactions.get_transaction('transaction_id')
btc_history = client.transactions.get_history('BTC', limit: 10)
send_result = client.transactions.send_crypto(
wallet_id: 'wallet_id',
network: 'BTC',
amount: 100000,
contact_id: 'contact_id'
)
Error Handling
The SDK provides comprehensive error handling with specific exception types:
begin
result = client.me
rescue OrionX::AuthenticationError => e
puts "Invalid API credentials: #{e.message}"
rescue OrionX::ValidationError => e
puts "Invalid parameters: #{e.message}"
rescue OrionX::RateLimitError => e
puts "Rate limit exceeded: #{e.message}"
rescue OrionX::NetworkError => e
puts "Network error: #{e.message}"
rescue OrionX::APIError => e
puts "API error: #{e.message}"
rescue OrionX::Error => e
puts "SDK error: #{e.message}"
end
Exception Types
OrionX::AuthenticationError - Invalid API credentials
OrionX::ValidationError - Invalid parameters or input validation failed
OrionX::RateLimitError - API rate limit exceeded
OrionX::NetworkError - Network connectivity issues
OrionX::APIError - General API errors
OrionX::Error - Base SDK error class
Debug Mode
Enable debug mode to see detailed HTTP requests and responses:
OrionX.configure do |config|
config.debug = true
end
client.debug = true
Configuration Options
OrionX.configure do |config|
config.api_key = 'your-api-key'
config.api_secret = 'your-api-secret'
config.api_endpoint = 'custom-endpoint'
config.debug = false
config.timeout = 30
config.retries = 3
config.logger = custom_logger
end
Examples
The SDK includes several comprehensive examples:
Basic Usage Example
ruby examples/basic_usage.rb
Demonstrates connection testing, user information, balances, and market data.
Trading Operations Example
ruby examples/trading_operations.rb
Shows how to place different order types, manage orders, and handle trading operations.
Market Data Monitor
ruby examples/market_monitor.rb
Real-time market monitoring with price updates and orderbook data.
Debug and Error Handling
ruby examples/debug_and_errors.rb
Comprehensive demonstration of debug features and error handling patterns.
Development
Setup
git clone https://github.com/PabloB07/orionx-sdk-ruby.git
cd orionx-sdk-ruby
bundle install
Running Tests
bundle exec rspec
COVERAGE=true bundle exec rspec
bundle exec rspec spec/client_spec.rb
Code Quality
bundle exec rubocop
bundle exec rubocop -A
API Reference Documentation
For detailed API documentation, visit:
Important Notes
Currency Units
OrionX uses specific units for different currencies:
- BTC: 8 decimal places (Satoshis) - 1 BTC = 100,000,000 units
- ETH: 18 decimal places (Wei) - 1 ETH = 1,000,000,000,000,000,000 units
- CLP: 0 decimal places - 1 CLP = 1 unit
- USD: 2 decimal places - 1 USD = 100 units
Rate Limits
The OrionX API has rate limits. The SDK automatically handles retries with exponential backoff for rate-limited requests.
Security
- Never commit your API credentials to version control
- Use environment variables for credentials in production
- Enable debug mode only in development environments
- Regularly rotate your API keys
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Write tests for your changes
- Ensure all tests pass (
bundle exec rspec)
- Run RuboCop (
bundle exec rubocop)
- Commit your changes (
git commit -am 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
Changelog
Version 1.0.0
- Initial release
- Complete API coverage for OrionX GraphQL API
- Comprehensive error handling and debug capabilities
- Full test suite with RSpec
- Multiple usage examples
- Detailed documentation
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
Acknowledgments
Made with ❤️ by PabloB07