Registry / finance / moomoo-api

moomoo-api

JSON →
library10.7.6708jsnpmunverified

Moomoo API is a Node.js WebSocket client for accessing moomoo's OpenAPI platform, providing real-time market data and trading capabilities for quantitative trading. Current stable version is 10.7.6708. The API supports streaming quotes, order placement, account information retrieval, and more. It is maintained by moomoo (formerly Futu) and uses a custom versioning scheme. Key differentiators include direct access to moomoo's brokerage services, low-latency WebSocket connections, and comprehensive API documentation. The package is primarily used in the Chinese quantitative trading ecosystem.

npm install moomoo-api
INSTALL
IMPORT
SIG · MOOMOO-API
M
moomoo-api
financejavascriptv10.7.6708
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const moomoo = require('moomoo-api')
import moomoo from 'moomoo-api'
Package does not support ESM imports; use CommonJS require(). Type definitions are not provided.
MoomooClient
const MoomooClient = require('moomoo-api').MoomooClient
MoomooClient is the main class for establishing connections. It is not exported as a named export; access via require().MoomooClient.
Trd_GetAccList
const { Trd_GetAccList } = require('moomoo-api')
const Trd_GetAccList = require('moomoo-api/Trd_GetAccList')
All protocol functions are exported as named properties from the package root. Do not try to import from subpaths.

Connects to the local moomoo OpenD server, retrieves account list, and logs it.

const moomoo = require('moomoo-api'); const client = new moomoo.MoomooClient({ host: '127.0.0.1', port: 11111, connectionType: moomoo.ConnectType.Trd }); client.on('connect', async () => { console.log('Connected!'); const accList = await client.getAccList(); console.log(accList); }); client.on('error', (err) => console.error(err)); client.connect();
Debug
Known issues
breakingProtocol buffer definitions (ProtoID) changed in version 10.x; existing code using hardcoded ProtoID values will break.
fix
Update to use new ProtoID constants from the package or regenerate protobuf definitions. Refer to changelog for mapping.
affects: >=10.0.0
breakingThe connection initialization process changed in version 9.x; older 'initConnect' methods removed.
fix
Use new MoomooClient constructor with 'connectionType' option. Remove any calls to 'initConnect'.
affects: >=9.0.0
gotchaVersion numbers do not follow semver; they use custom scheme (e.g., 10.7.6708). npm's '^' or '~' may not work as expected.
fix
Pin exact version in package.json, e.g., "moomoo-api": "10.7.6708". Avoid using ranges.
affects: all
gotchaThe package requires a local OpenD server running; connecting to moomoo's cloud server directly is not supported out-of-the-box.
fix
Ensure OpenD is installed and running on the specified host/port before connecting.
affects: all
Errors
Common errors & fixes
Cannot find module 'moomoo-api'
Package not installed or not in node_modules.
fix
Run 'npm install moomoo-api@10.7.6708 --save' with exact version.
TypeError: moomoo.MoomooClient is not a constructor
Using wrong import style (e.g., import from 'moomoo-api' instead of require).
fix
Use 'const moomoo = require('moomoo-api'); new moomoo.MoomooClient(...)'.
Error: connect ECONNREFUSED 127.0.0.1:11111
OpenD server not running or port incorrect.
fix
Start OpenD server on localhost:11111 or change host/port in MoomooClient options.
Upgrade
Version history
10.7.6708latest on npm
Audit
Dependencies
wsrequiredWebSocket client for real-time data streaming
longrequiredSupport for 64-bit integers used in protocol buffers
protobufjsrequiredProtocol Buffers serialization for API messages
Agent activity
50 hits · last 30 days
node
46
OpenAI (training)
1
Resources
moomoo-api — npm install moomoo-api · libregistry