{"id":47174,"library":"bitsharesjs-ws","title":"BitShares WebSocket Client","description":"Pure JavaScript BitShares blockchain websocket interface for node.js and browsers (v6.0.2). Allows connection to public or local BitShares API nodes for blockchain data access. Releases follow semver with active development on GitHub. Key differentiator: provides high-level API for Database and History methods with automatic connection management and subscription support. Requires Node >= 16.13.","status":"active","version":"6.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/bitshares/bitsharesjs-ws","tags":["javascript"],"install":[{"cmd":"npm install bitsharesjs-ws","lang":"bash","label":"npm"},{"cmd":"yarn add bitsharesjs-ws","lang":"bash","label":"yarn"},{"cmd":"pnpm add bitsharesjs-ws","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export, not default. Works with both ESM and CJS. In CJS, 'const { Apis } = require('bitsharesjs-ws')' is correct.","wrong":"const Apis = require('bitsharesjs-ws').Apis","symbol":"Apis","correct":"import { Apis } from 'bitsharesjs-ws'"},{"note":"Default export is available only in ESM context. Not recommended; prefer named exports.","wrong":"import { default as bitshares_ws } from 'bitsharesjs-ws'","symbol":"default","correct":"import bitshares_ws from 'bitsharesjs-ws'"},{"note":"Login is a named export for API connection with credentials. Also available as instance method via Apis.instance().","wrong":"const Login = require('bitsharesjs-ws').Login","symbol":"Login","correct":"import { Login } from 'bitsharesjs-ws'"}],"quickstart":{"code":"import { Apis } from 'bitsharesjs-ws';\n\n// Connect to a public BitShares node\nApis.instance('wss://bitshares.openledger.info/ws', true)\n  .init_promise\n  .then(res => {\n    console.log('Connected to network:', res[0].network);\n    // Call Database API\n    return Apis.db.get_objects(['1.3.0', '2.0.0']);\n  })\n  .then(objects => {\n    console.log('Objects:', objects);\n    // Subscribe to all object updates\n    Apis.db.set_subscribe_callback(updateCallback, true);\n  })\n  .catch(err => console.error('Connection error:', err));\n\nfunction updateCallback(object) {\n  console.log('Update:', object);\n}","lang":"typescript","description":"Shows how to connect to a public BitShares node, fetch blockchain objects, and subscribe to real-time updates."},"warnings":[{"fix":"Upgrade Node to 16.13+ or use an older version of the library (e.g., 4.x).","message":"Since v5.0.0, the library requires Node.js >= 16.13.0 and npm >= 8.2.0. Older Node versions will fail to install or run.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Use named imports: const { Apis } = require('bitsharesjs-ws').","message":"Since v4.0.0, the library is ESM-first. CommonJS require() still works with named exports, but default import via require() is not available.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Call Apis.instance('wss://...', true) or Apis.instance('wss://...', false).","message":"The method Apis.instance() without the second argument (auto reconnect) is deprecated. Always pass a boolean for auto reconnect.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Install 'ws' as a dependency for Node <18: 'npm install ws'.","message":"The library uses WebSocket under the hood. In browsers, the global WebSocket is used; in Node, the 'ws' package. Ensure the 'ws' package is installed if using Node <18 (it's a peer dependency but not listed in package.json).","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure Apis.instance() is called once and reuse the promise via Apis.instance().init_promise.","message":"Apis.instance() must be called only once. Calling it multiple times will create multiple connections and can cause unexpected behavior.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'16.13':57 'access':27 'activ':32 'allow':15 'api':22,42 'automat':49 'bitshar':1,6,21 'blockchain':7,25 'browser':13 'client':3 'connect':16,50 'data':26 'databas':44 'develop':33 'differenti':37 'follow':29 'github':35 'high':40 'high-level':39 'histori':46 'interfac':9 'javascript':5,58 'key':36 'level':41 'local':20 'manag':51 'method':47 'node':23,56 'node.js':11 'provid':38 'public':18 'pure':4 'releas':28 'requir':55 'semver':30 'subscript':53 'support':54 'v6.0.2':14 'websocket':2,8","created_at":"2026-06-07T16:50:10.445250+00:00","updated_at":"2026-06-07T16:50:10.445250+00:00","problems":[{"fix":"Run 'npm install bitsharesjs-ws' and ensure the import is correct: import { Apis } from 'bitsharesjs-ws'.","cause":"The package is not installed or the import path is incorrect.","error":"Module not found: Can't resolve 'bitsharesjs-ws'"},{"fix":"Use correct import: import { Apis } from 'bitsharesjs-ws' or const { Apis } = require('bitsharesjs-ws').","cause":"Using a default import instead of named import.","error":"TypeError: Apis.instance is not a function"},{"fix":"Install the 'ws' package: 'npm install ws'.","cause":"Missing peer dependency 'ws' for Node.js environments.","error":"Error: Can't resolve 'ws' in '/path/to/node_modules/bitsharesjs-ws/lib'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/bitshares/bitsharesjs-ws","github":"https://github.com/bitshares/bitsharesjs-ws","docs":null,"changelog":null,"pypi":null,"npm":"bitsharesjs-ws","openapi_spec":null,"status_page":null,"smithery":null,"categories":["blockchain"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}