Skip to content

dutu/gemini-api-node

Repository files navigation

gemini-api-node

Build Status Dependency Status

gemini-api-node is a simple node.js wrapper for Gemini REST and WebSocket API.

Contents

Changelog

See detailed Changelog

Installation

npm install --save gemini-api-node

Quick examples

Clients for both the REST API and streaming WebSocket API are included. Private endpoints as indicated in the API docs require authentication with an API key and secret key.

REST API example:

import Gemini from 'gemini-api-node'

const gemini = new Gemini({ key, secret, sandbox: false })
gemini.getOrderBook('btcusd', { limit_asks: 10, limit_bids: 10 })
  .then(console.log)
  .catch(console.error)

WebSocket API examples:

import Gemini from 'gemini-api-node'

const gemini = new Gemini()
let ws = gemini.newWebSocketMarketData('btcusd', { 'top_of_book' : 'true', 'offers': true })

ws.onopen = () => {
  console.log('Websocket is open')
}
  
ws.onmessage = (message) => {
  let data = JSON.parse(message.data)
  console.log('Websocket data received')
}
import Gemini from 'gemini-api-node'

const gemini = new Gemini({ key, secret, sandbox: true })
let ws = gemini.newWebSocketOrderEvents({ symbolFilter: ['btcusd'], eventTypeFilter: ['fill', 'closed']})

ws.onopen = () => {
  console.log('Websocket is open')
}
  
ws.onmessage = (message) => {
  let data = JSON.parse(message.data)
  console.log('Websocket data received')
}

API

REST

All methods return promises.

  • getAllSymbols()
  • getTicker(symbol)
  • getOrderBook(symbol, params = {})
  • getTradeHistory(symbol, params = {})
  • getCurrentAuction(symbol)
  • getAuctionHistory(symbol, params = {})
  • newOrder(params = {})
  • cancelOrder({ order_id })
  • cancelAllSessionOrders()
  • cancelAllActiveOrders()
  • getMyOrderStatus({ order_id })
  • getMyActiveOrders()
  • getMyPastTrades(params = {})
  • getMyTradeVolume()
  • getMyAvailableBalances()
  • newAddress(currency)

WebSocket

All methods return a WebSocket object.

  • newWebSocketMarketData(symbol, params = {})
  • newWebSocketOrderEvents(params = {})

License

MIT