Dev Null Productions

The Blog

XRBP - The Ultimate XRP / Ruby Interface

Dev Null Productions is pleased to announce the general availability of XRBP a library aimed at providing an accessible, fault-tolerant interface to the XRP ledger. XRBP allows the developer to read and write data to/from the XRP network in real time, synchronizing ledger data including accounts, transactions, objects, and more. Data is presented via both synchronous and asynchronous mechanisms with multiple-connection load balancing and fault tolerance baked in behind the scenes.

But some code is worth a 1000 words! The following allows you to pull server info pertaining to the instance of rippled you are connected to:

require 'xrbp'

ws = "wss://"
ws.add_plugin :autoconnect, :command_dispatcher


Above we see

  • the XRBP library is included
  • a new websocket connection to is established
  • and the ServerInfo command is dispatched and the results printed

To facilitate fully-customizable and configurable applications XRBP incorporates a pluggable architecture where modules customizing the request/response workflow and validating/transforming result sets may be registed with connection objects. As of the current date, plugins exist to:

  • Automatically timeout inactive connections and reestablish the link
  • Automatically retry failed requests (with configurable max tries and timeout)
  • Allow the user to register custom data parsers to transform received data
  • Paginate results behind the scenes so large data sets (transactions, account objects, etc) can all be seemlessly retrieved and aggregated before the results are returned
  • Dispatch and validate XRP specific commands, extracting specific data out of the result set for client consumption

Furthemore XRBP facilitates fault tolerant communications by implementing serveral multi-connection strategies behind these scenes. Each strategy manages an internal pool of connections and cycles through them according to different criteria.

To use multiple XRP servers in a 'round-robin' manner where subsequent connections will always be delegated to the next connection in the list:

ws = "wss://",

ws.add_plugin :command_dispatcher

puts ws.cmd("rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"))
puts ws.cmd("rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"))

In the above example we will retrieve info pertaining to the first account (rvYAf...) from and the second account (rhub8...) from With the RoundRobin strategy, once all connections are used, we will cycle back to the first, in this case the next request will be issued to

To automatically leverage backup servers if a request fails, we can use the Prioritized strategy:

ws = "wss://",

ws.add_plugin :command_dispatcher, :result_parser
ws.parse_results { |res|

puts ws.cmd(

In this example we see that we establish a Prioritized connection set, and register a plugin to automatically parse data retrieved from the server. If we are not able to retrieve a valid ledger, the parser will throw an error and we will automaticlaly try the next connection behind the scenes. Thus if we query for a ledger which has been deleted from our primary rippled server, we can fall back to a full-history node.

This is just the icing on the cake as far as multi-connection strategies, there are several more included in the public XRBP API and developing custom strategies is as simple as inheriting XRBP::WebSocket::MultiConnection and defining next_connection.

XRBP can do much more ontop of all this. We can sync validators, gateways, etc from the DataV2 API, sync market quotes from exchanges, crawl the network and much more!

Listing Validators

connection =
XRBP::Model::Validator.all(:connection => connection)
                      .each do |v|
  puts v

Crawling Nodes

connection =
connection.timeout = 3

connection.on :peer do |node, peer|
  puts "#{node.url} peer: #{peer.url}"

                        :connection => connection)

See project documentation and examples/ for complete details. And make sure to stay tuned there are alot more great features coming!