Liking cljdoc? Tell your friends :D


A client for Bitstamp API based on core.async.

CircleCI Dependencies Status License


[clj-bitstamp "0.4.0"]


This library is a thin wrapper around com.pusher/pusher-java-client within a simple usage. A function new-pusher opens a new connection with the Pusher server, subscribes a requested channel and returns a following tuple [pusher pusher-channel status-ch data-ch] where

  • pusher a Pusher instance
  • pusher a subscribed Channel instance
  • status-ch an async channel containing a pusher and channel messages as a tuple [action data]
  • data-ch an async channel containing data for the subscribed channel as a tuple [channel-name event-name data]

The function takes an option object:

  • channel-name a channel name to subscribe, required
  • pusher-key a Pusher key, default de504dc5763aeef9ff52, optional
  • event-name an event name to bind on the subscribed channel, optional
  • status-buffer-or-n a buffer-or-n for the status channel, optional
  • data-buffer-or-n a buffer-or-n for the data channel, optional
  • str-big-decimals? when true coerce a volume and price (in strings) as BigDecimal, default true

Data channel returns a tuple of channel-name, event-name (as keyword), and data.

Status channel returns a tuple of event-name (as keyword), and data. Expected events:

  • :change
  • :connecting
  • :connected
  • :disconnecting
  • :disconnected


(require '[clojure.core.async :as async])
(require '[clj-bitstamp.async :as bitstamp])

(let [[pusher pusher-channel status-ch data-ch]
      (bitstamp/new-pusher {:channel-name "order_book_btceur" ;; required
                            :event-name "data" ;; required
                            :data-buffer-or-n (async/sliding-buffer 16) ;; optinal
                            :status-buffer-or-n 16})] ;; optional
  (async/go-loop []
                 (let [[channel-name event-name data] (async/<! data-ch)]
                   (println channel-name event-name data)) ;; <-- put you logic here
  (async/go-loop []
                 (let [[event-name data] (async/<! status-ch)]
                   (println event-name data)) ;; <-- put status handler here

An established connection can be disconnected by

(clj-bitstamp/disconnect pusher)

and again connected withoin same pusher instance

(clj-bitstamp/connect pusher)


  • floating-point numbers are parsed as BigDecimals

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close