Skip to content
Ruby library for Deribit API
Ruby Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Fix local ENV vars in bin/console Mar 6, 2019
lib Add detailed logger, schedule bi-monthly maintenance Aug 11, 2019
.gitignore Prepare 0.1.3 release Jul 2, 2019
.travis.yml Add detailed logger, schedule bi-monthly maintenance Aug 11, 2019 Generate gem library Dec 18, 2018
LICENSE Create LICENSE Feb 27, 2019 Private Websocket API Apr 17, 2019
Rakefile Add detailed logger, schedule bi-monthly maintenance Aug 11, 2019
deribit.gemspec Add detailed logger, schedule bi-monthly maintenance Aug 11, 2019


Build Status Maintainability Test Coverage Inline docs Gem Version Yard Docs License: MIT

Ruby library for Deribit API


Add this line to your application's Gemfile:

gem 'deribit-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install deribit-api



require 'deribit-api'

Create a simple client to access public APIs

client =
trades = client.trades 'options', count: 3
  => #<Hashie::Mash amount=3.0 direction="buy" indexPrice=3817.31 instrument="BTC-29MAR19-4500-C" iv=60.33 price=0.016 quantity=3.0 tickDirection=0 timeStamp=1551274556589 tradeId=16055937 tradeSeq=712>
  => "BTC-29MAR19-4500-C"

Pass key and secret to access private APIs

client = key: 'KEY', secret: 'SECRET'
account = client.account
 => #<Hashie::Mash PNL=0.0 SRPL=0.0 SUPL=0.0 availableFunds=9.99995789 balance=9.99995789 currency="BTC" deltaTotal=0.0 depositAddress="2N6SU5Yjn7AfYcT89QyeeHvHyZoqTt2GLyi" equity=9.999957896 futuresPNL=0.0 futuresSRPL=0.0 futuresSUPL=0.0 initialMargin=0.0 maintenanceMargin=0.0 marginBalance=9.99995789 optionsD=0.0 optionsG=0.0 optionsPNL=0.0 optionsSRPL=0.0 optionsSUPL=0.0 optionsTh=0.0 optionsV=0.0 sessionFunding=0.0>
  => 9.999957896


Fetch all tradable instruments:

instruments = client.instruments
puts instruments.first

Orderbook for BTCUSD perpetual instrument:

orderbook = client.orderbook 'BTC-PERPETUAL', depth: 3
puts orderbook.asks.first

Orderbook streaming via websocket:

@client.orderbook 'ETH-PERPETUAL' do |orderbook|
  puts orderbook

Place a BTCUSD limit buy order 100 contracts @ 2500:

response = 'BTC-PERPETUAL', 100, price: 2500
puts response.order.state

Get last 10 option trades via HTTP:

trades = client.trades 'options', count: 10
puts trades.first

Stream ongoing trades via websocket:

@client.trades do |trade|
 puts trade

Options trading summary:

summaries = client.summary :options
puts summaries.first

API Endpoints

All endpoints marked with [X] are fully implemented and ready to use, see the features table below:

API endpoints Private? HTTP API Websocket API FIX API
Time [X] [X]
Setheartbeat N/A [X]
Cancelheartbeat N/A [X]
Test [X] [X]
Ping [X] [X]
Instruments [X] [X]
Currencies [X] [X]
Index [X] [X]
Orderbook [X] [X]
Trades [X] [X]
Summary [X] [X]
Announcements [X] [X]
Settlements [X] [X]
Account YES [X] [X]
Buy YES [X] [X]
Sell YES [X] [X]
Edit YES [X] [X]
Cancel YES [X] [X]
Cancel all YES [X] [X]
Orders YES [X] [X]
Positions YES [X] [X]
Orders history YES [X] [X]
Order YES [X] [X]
Trades history YES [X] [X]
New announcements YES [X] [X]
Logout YES N/A [X]
Cancel on disconnect YES N/A [X]
Get email lang YES [X] [X]
Set email lang YES [X] [X]
Set announcements read YES [X] [X]
Settlements history YES [X] [X]
Subscribe N/A
Unsubscribe N/A


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Code of Conduct

Everyone interacting in the Deribit project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

You can’t perform that action at this time.