update from upstream#13
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds Margin and Lending APIs and related public methods (mgTransfer..., mgBorrow/Repay, mgAccount, lending, universalTransfer), expands TypeScript typings, migrates build/CI to TypeScript/Rollup/GitHub Actions, adds many tests/examples, updates packaging to ESM/CJS with exports/typings, and bumps package version to 1.0.20. (43 words) Changes
Sequence Diagram(s)sequenceDiagram
participant App as Example/Consumer
participant Lib as node-binance-api
participant REST as Binance REST API
rect rgba(243,247,255,0.5)
Note right of Lib: Margin transfer flow
App->>Lib: binance.mgTransferMainToMargin(asset, amount)
Lib->>REST: POST /sapi/v1/margin/transfer (signed)
REST-->>Lib: 200 OK {tranId,...}
Lib-->>App: resolved response
end
sequenceDiagram
participant App as Example/Consumer
participant Lib as node-binance-api
participant REST as Binance REST API
rect rgba(249,251,240,0.5)
Note right of Lib: universalTransfer abstraction
App->>Lib: binance.universalTransfer(fromToEnum, asset, amount)
Lib->>REST: POST /sapi/v1/asset/transfer (signed)
REST-->>Lib: 200 OK {tranId,...}
Lib-->>App: resolved response
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Vulnerable Libraries (4)
More info on how to fix Vulnerable Libraries in JavaScript. 👉 Go to the dashboard for detailed results. 📥 Happy? Share your feedback with us. |
There was a problem hiding this comment.
Actionable comments posted: 20
Outside diff range, codebase verification and nitpick comments (8)
README.md (5)
1-1: Consider adding a comma.Consider adding a comma after "support" for better readability.
> ### ⚠ Binance is no longer offering support +> ### ⚠ Binance is no longer offering support,Tools
LanguageTool
[typographical] ~1-~1: Consider adding a comma here.
Context: ... ⚠ Binance is no longer offering support > Please consider using the new, offically suppo...(PLEASE_COMMA)
4-4: Avoid bare URLs.Consider using Markdown syntax for links to avoid bare URLs.
- > Or this community supported library: https://github.com/ViewBlock/binance-api-node + > Or this community supported library: [https://github.com/ViewBlock/binance-api-node](https://github.com/ViewBlock/binance-api-node)Tools
Markdownlint
4-4: null
Bare URL used(MD034, no-bare-urls)
1533-1533: Avoid repetitive sentence beginnings.Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
- binance.dustLog((error, dustlog) => { - console.info(dustlog); - }) + binance.dustLog((error, dustlog) => { + if (error) return console.error(error); + console.info(dustlog); + });Tools
LanguageTool
[style] ~1533-~1533: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); });#### Get dust logjavascript binance.dustLog(...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
2045-2045: Add period after "etc".In American English, abbreviations like “etc.” require a period.
- [exchangeInfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md#exchangeinfo-pull-minimum-order-size-quantity-etc)\ + [exchangeInfo: Pull minimum order size, quantity, etc.](https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md#exchangeinfo-pull-minimum-order-size-quantity-etc)\Tools
LanguageTool
[style] ~2045-~2045: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...(ETC_PERIOD)
278-278: Specify language for fenced code blocks.Fenced code blocks should have a language specified.
- ``` + ```jsTools
Markdownlint
278-278: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
node-binance-api.d.ts (3)
29-203: Consider specifying return types for better type safety.The interface
IWebsocketsis correctly defined. However, specifying return types for methods likeuserData,userMarginData, etc., would improve type safety.
205-234: Consider making boolean properties optional.The interface
IConstructorArgsis correctly defined. However, making boolean properties likeuseServerTime,reconnect, etc., optional would improve readability and usability.
236-1586: Consider specifying return types and fixing typos in doc comments.The class
Binanceis correctly defined. However, specifying return types for methods likedepthCache,depthVolume, etc., would improve type safety. Additionally, fix typos in doc comments, such as "depch" to "depth" and "addtional" to "additional".
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
Files selected for processing (11)
- .all-contributorsrc (1 hunks)
- .eslintrc.json (1 hunks)
- README.md (20 hunks)
- examples/advanced.md (5 hunks)
- examples/binanceStreams.js (1 hunks)
- examples/experiments.js (1 hunks)
- examples/oco.md (1 hunks)
- node-binance-api.d.ts (1 hunks)
- package.json (2 hunks)
- test.js (3 hunks)
- vue.config.js (1 hunks)
Files skipped from review due to trivial changes (2)
- .eslintrc.json
- vue.config.js
Additional context used
LanguageTool
examples/oco.md
[uncategorized] ~13-~13: Loose punctuation mark.
Context: ...e: 0.001 }, (error, response) => {}) } )();(UNLIKELY_OPENING_PUNCTUATION)
examples/advanced.md
[style] ~193-~193: ‘exactly the same’ might be wordy. Consider a shorter alternative.
Context: ... Cancelled Orders via WebSocket This is exactly the same as the ws User Data but calling: ```jav...(EN_WORDINESS_PREMIUM_EXACTLY_THE_SAME)
[uncategorized] ~266-~266: Possible missing comma found.
Context: ...s://ip:port # run your app ``` For web sockets currently only the socks method is func...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~266-~266: A comma might be missing here.
Context: ...ort # run your app ``` For web sockets currently only the socks method is functional at ...(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
README.md
[typographical] ~1-~1: Consider adding a comma here.
Context: ... ⚠ Binance is no longer offering support > Please consider using the new, offically suppo...(PLEASE_COMMA)
[style] ~1533-~1533: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); });#### Get dust logjavascript binance.dustLog(...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[uncategorized] ~1930-~1930: Possible missing comma found.
Context: ...()usebinance.mgSell(). For market orders usebinance.mgMarketBuy()andbinanc...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~1936-~1936: Possible missing preposition found.
Context: ...e 'regular account' counterparts. #### Get your Trade History for the Margin accou...(AI_HYDRA_LEO_MISSING_TO)
[style] ~2045-~2045: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...(ETC_PERIOD)
Markdownlint
examples/advanced.md
252-252: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
259-259: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
268-268: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
274-274: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
README.md
46-46: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
60-60: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
214-214: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
325-325: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
6-6: null
Multiple spaces after blockquote symbol(MD027, no-multiple-space-blockquote)
2-2: null
Bare URL used(MD034, no-bare-urls)
4-4: null
Bare URL used(MD034, no-bare-urls)
278-278: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
25-25: null
No empty links(MD042, no-empty-links)
1879-1879: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
1998-1998: Expected: h2; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
Biome
examples/binanceStreams.js
[error] 217-217: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 218-218: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 219-219: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 219-223: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 224-225: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 370-370: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 371-371: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 372-372: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 372-376: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 377-378: This code is unreachable
... because this statement will return from the function beforehand
(lint/correctness/noUnreachable)
[error] 549-549: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
[error] 588-588: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 1286-1378: This property value named depthCache is later overwritten by an object member with the same name.
Overwritten with this value.
If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored.
Unsafe fix: Remove this property value named depthCache(lint/suspicious/noDuplicateObjectKeys)
[error] 1348-1348: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
Additional comments not posted (23)
examples/oco.md (4)
1-2: LGTM!The code is correctly using an IIFE and importing the necessary library.
The code changes are approved.
8-9: LGTM!The code is correctly placing an OCO order using the Binance API.
The code changes are approved.
11-12: LGTM!The code is correctly placing an OCO order using an alternative syntax.
The code changes are approved.
13-14: LGTM!The code correctly ends the IIFE. The loose punctuation mark flagged by the static analysis tool is a false positive.
The code changes are approved.
Tools
LanguageTool
[uncategorized] ~13-~13: Loose punctuation mark.
Context: ...e: 0.001 }, (error, response) => {}) } )();(UNLIKELY_OPENING_PUNCTUATION)
examples/experiments.js (1)
7-7: LGTM!The code is correctly updating the API endpoint to a newer version.
The code changes are approved.
package.json (2)
3-3: LGTM!The updates to the version, typings, and dependencies are appropriate. The addition of
json-bigintis beneficial for handling large integers in JSON data.The code changes are approved.
Also applies to: 6-6, 8-11, 13-13, 15-15
34-34: LGTM!The updates to the author information and devDependencies are appropriate and align the project with modern development standards.
The code changes are approved.
Also applies to: 41-46, 48-49, 51-51
examples/advanced.md (6)
1-1: LGTM!The badges provide useful information about the project and enhance the README's visual appeal.
The code changes are approved.
52-73: LGTM!The new section provides a clear and practical example of how to log the status code, used weight, and last URL for various API calls. This is beneficial for users to understand the API's usage limits.
The code changes are approved.
192-196: LGTM!The new section provides a clear and practical example of how to receive account balance updates and trade updates via WebSocket for margin trading. This is beneficial for users interested in real-time data for margin trading.
The code changes are approved.
Tools
LanguageTool
[style] ~193-~193: ‘exactly the same’ might be wordy. Consider a shorter alternative.
Context: ... Cancelled Orders via WebSocket This is exactly the same as the ws User Data but calling: ```jav...(EN_WORDINESS_PREMIUM_EXACTLY_THE_SAME)
234-239: LGTM!The new example provides a clear and practical example of how to use a custom name for withdrawal addresses. This enhances the usability of the API by illustrating a practical scenario.
The code changes are approved.
241-246: LGTM!The new example provides a clear and practical example of how to implement a callback for withdrawal responses. This enhances the usability of the API by illustrating a practical scenario.
The code changes are approved.
280-304: LGTM!The new section provides clear and practical examples of three common patterns for handling asynchronous API calls: using callbacks, promises, and async/await. This is beneficial for developers looking to understand different error-handling strategies when interacting with the API.
The code changes are approved.
.all-contributorsrc (1)
1-455: LGTM!The JSON configuration file is correctly formatted and includes relevant information about the project, contributors, and their contributions.
The code changes are approved.
test.js (3)
74-100: LGTM!The new test case correctly verifies the construction of the
Binanceobject in various ways, ensuring that each instance maintains its own options.The code changes are approved.
646-646: LGTM!The modification to include
quoteAssetPrecisionin thesymbolMembersarray ensures that the test correctly validates the presence of this new property in the symbols returned from the API.The code changes are approved.
716-731: LGTM!The new test case correctly checks for the expected error message and success status when attempting to withdraw BNB without saving to the address book, improving error handling and validation in the withdrawal process.
The code changes are approved.
README.md (1)
2076-2077: Ensure proper usage of async/await.Ensure that
await binance.useServerTime();is inside an async function.- await binance.useServerTime(); - binance.balance((error, balances) => { - if ( error ) return console.error(error); - console.info("balances()", balances); - console.info("BNB balance: ", balances.BNB.available); - }); + (async () => { + await binance.useServerTime(); + binance.balance((error, balances) => { + if ( error ) return console.error(error); + console.info("balances()", balances); + console.info("BNB balance: ", balances.BNB.available); + }); + })();node-binance-api.d.ts (3)
7-7: LGTM!The type alias
_callbackis correctly defined.The code changes are approved.
9-9: LGTM!The type alias
_symbolis correctly defined.The code changes are approved.
11-27: LGTM!The type alias
_intervalis correctly defined.The code changes are approved.
examples/binanceStreams.js (2)
21-21: Consider usingconstinstead ofletforcontentType.The variable
contentTypeis not reassigned. Usingconstinstead ofletcan prevent accidental reassignment and improve readability.Apply this diff to use
constforcontentType:-const contentType = 'x-www-form-urlencoded'; +const contentType = 'x-www-form-urlencoded';Likely invalid or redundant comment.
100-110: Consider usingconstinstead ofletforreqObjandreqObjPOST.These variables are not reassigned. Using
constinstead ofletcan prevent accidental reassignment and improve readability.Apply this diff to use
constfor these variables:-const reqObj = ( url, data = {}, method = 'GET', key ) => ( { +const reqObj = ( url, data = {}, method = 'GET', key ) => ( { url: url, json: data, //qs method, timeout: options.recvWindow, headers: { 'Content-type': contentType, 'X-MBX-APIKEY': key || '' } } ) -const reqObjPOST = ( url, data = {}, method = 'POST', key ) => ( { +const reqObjPOST = ( url, data = {}, method = 'POST', key ) => ( { url: url, json: data, //form: data, method, timeout: options.recvWindow, headers: { 'Content-type': contentType, 'X-MBX-APIKEY': key || '' } } )Likely invalid or redundant comment.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
README.md (2)
15-15: Empty Link in 'GitHub Last Commit' Badge:
The 'GitHub last commit' badge currently uses a placeholder link (“#”). It would be beneficial to replace this with a valid URL (for example, linking to the repo’s commit history) to provide meaningful context for users.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
15-15: No empty links
null(MD042, no-empty-links)
268-268: Fenced Code Block Language Specification:
Several fenced code blocks do not specify a language. For better syntax highlighting and readability, consider adding language identifiers (e.g. “javascript” instead of just “”).🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
268-268: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(20 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
15-15: No empty links
null
(MD042, no-empty-links)
36-36: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
50-50: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
204-204: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
268-268: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
315-315: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1869-1869: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1988-1988: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1523-~1523: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2035-~2035: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
🔇 Additional comments (8)
README.md (8)
2-4: Updated Badge Links:
The new badge links for the Binance Community API and Yearly Downloads look great and provide a modern look with updated metrics. Verify that the URLs point to the intended resources, especially when these metrics (like downloads) might be dynamic.
36-36: Heading Level Consistency:
The "Installation" header is marked as a level‑4 heading (“#### Installation: …”) even though static analysis recommends only incrementing heading levels by one. However, as noted by the user in previous discussions, styling such as heading levels is not a priority for this PR.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
36-36: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
41-46: Initialization Example Approved:
The "Getting started" snippet clearly demonstrates how to import and initialize the Binance API with the proper configuration usingconsole.infofor logging. This example is succinct and very helpful for new users.
48-83: Futures API Examples Are Comprehensive:
The updated examples in the "Binance Futures API" section effectively demonstrate various functionalities (prices, account balances, limit orders, etc.). The consistent use ofconsole.infooverconsole.logstandardizes output, contributing to clearer documentation.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
50-50: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
1869-1929: New Margin API Methods Added:
The additions for margin account operations—such asmgTransferMainToMargin,mgTransferMarginToMain,mgBorrow,mgRepay, andmgTrades—expand the API’s capabilities. The examples are clear, and the callbacks include basic error handling. This consistency helps users understand how to work with margin accounts.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1869-1869: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
1988-2032: Lending API Enhancements:
The new Lending API section, including the example of asynchronously retrieving lending account details, is a valuable update. The detailed response previews in the “View response” blocks enhance clarity, making it easier for users to see how the data is structured.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1988-1988: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
1568-1578: WebSocket Chart Update Example:
The example for the “Get Complete WebSocket Chart Cache” is well structured. The use of helper functions (e.g.binance.last(chart)) and clear logging of the last price demonstrates an effective pattern for real‑time chart data handling.
1641-1653: Candlestick WebSocket Updates:
The candlestick WebSocket example makes good use of destructuring to extract key data points (open, high, low, close, volume, etc.) and logs them clearly. This real‑time update is easy to follow and should help users who need to monitor live market data.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
README.md (5)
2-8: Badge Updates and Deprecated Badges
The updated badge links (e.g. the new "Yearly Downloads" badge at line 3 and the download badge at line 6) reflect up‐to‐date metrics, which is a welcome improvement. Since several older badge URLs are now commented out, consider removing those commented sections if they are no longer needed.
24-35: Navigation Bar Enhancement
The added navigation bar (lines 24–35) provides a quick overview of the available API sections via clickable links. For consistency with markdown style, you might consider using pure markdown link syntax rather than HTML tags and inline styles—but if the current approach meets your design goals, it’s acceptable as is.
1570-1654: WebSocket and Real-Time Data Examples
The updated WebSocket examples (including the chart cache, candlestick updates, and trade updates) are very comprehensive. They demonstrate real-time data handling effectively by using clear, well-documented callbacks and asynchronous patterns. If you wish to streamline the documentation further, consider consolidating similar examples; otherwise, the current level of detail is valuable for users.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1584-1584: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
1987-1994: Lending API Example
The lending example with async/await at lines 1987–1994 is clear and succinct. For improved robustness in real-world usage, you might consider demonstrating error handling as well, though the current example works well as a basic usage sample.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1989-1989: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
2036-2036: Markdown Styling Considerations (Optional)
Static analysis tools have flagged several minor markdown issues (e.g., MD001 heading increments on various headers and MD040 for fenced code blocks without a specified language). Given that previous feedback indicated this styling is not a priority, you may choose to address these in a separate cleanup pass. If you later decide to polish the markdown formatting for consistency and adherence to linting rules, I’d be happy to offer more detailed suggestions.Also applies to: 269-269, 316-316, 1870-1870, 1989-1989
🧰 Tools
🪛 LanguageTool
[style] ~2036-~2036: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...(ETC_PERIOD)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(20 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
37-37: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
51-51: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
205-205: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
269-269: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
316-316: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1870-1870: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1989-1989: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1524-~1524: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2036-~2036: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
🔇 Additional comments (7)
README.md (7)
16-17: Updated Twitter Badge
The new Twitter badge at line 17 is a nice addition to the header and helps promote social presence.
37-38: Installation Instruction Heading Level
The installation instruction is introduced with a fourth-level header ("#### Installation:…") at line 37. Static analysis tools flag MD001 (heading level increment) here. If this deeper heading level is intentional for styling purposes—and you’ve previously noted that minor styling issues aren’t a priority—you can safely ignore this warning; otherwise, consider revising the heading hierarchy for improved consistency.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
37-37: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
41-47: Getting Started Code Example
The code snippet in the “Getting started” section (lines 41–47) clearly demonstrates how to initialize the API with the provided key and secret. The use of modern JavaScript syntax (e.g. asynchronous usage viaconsole.info) makes the example both clear and practical.
49-103: Futures API Examples
The extensive examples in the Futures API section (approximately lines 49–103) effectively showcase a variety of functionalities—from retrieving futures prices and account balances to executing limit and market orders. The asynchronous syntax and use ofconsole.infothroughout make for consistent and easy-to-follow examples.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
51-51: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
1868-1961: Margin API Enhancements
The newly added Margin API methods (lines 1868–1961) and their examples for transferring funds, borrowing, and checking order status mirror the spot trading examples nicely. The code examples are clear and consistent, making it easy for users to understand the new functionality.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1870-1870: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
2051-2073: Troubleshooting Section
The troubleshooting section (lines 2051–2073) provides practical guidance for resolving common issues such as time synchronization and network timeouts. The inclusion of code examples for setting options likeuseServerTime,recvWindow, and enabling verbose logging is very helpful for debugging.
2082-2089: Contribution and Community Engagement
The contribution section (lines 2082–2089) is inviting and clearly outlines how external contributors can get involved. The inclusion of star history and social badges adds a nice touch.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
.github/workflows/js.yml (1)
27-27: Missing Newline at End-of-File
Static analysis has flagged that there is no newline at the end of the file. Adding a newline will help conform to best practices and satisfy linting rules.Suggested diff:
-npm run test \ No newline at end of file +npm run test +🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 27-27: no new line character at the end of file
(new-line-at-end-of-file)
README.md (2)
56-92: Comprehensive Binance Futures API Examples
The new section for the Binance Futures API introduces multiple useful examples (e.g., fetching futures prices, account balances, and executing limit orders). The examples use consistent logging via console.info. Please ensure that any asynchronous functions (using await where applicable) are correctly handled in user applications.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
58-58: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
1877-1942: Thorough Binance Margin API Coverage
The Margin API section now covers critical operations including transferring funds (both to and from the margin account), checking maximum transferable and borrowable amounts, borrowing, and repaying. The use of callbacks for error handling is consistent across examples. Users should verify that error handling in their implementations meets their specific needs.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1877-1877: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/js.yml(1 hunks)README.md(20 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/js.yml
[error] 27-27: no new line character at the end of file
(new-line-at-end-of-file)
🪛 markdownlint-cli2 (0.17.2)
README.md
39-39: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
44-44: Bare URL used
null
(MD034, no-bare-urls)
58-58: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
212-212: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
276-276: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
323-323: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1877-1877: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1996-1996: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1531-~1531: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2043-~2043: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
🔇 Additional comments (12)
.github/workflows/js.yml (1)
1-27: New GitHub Actions Workflow Added
This new workflow file sets up CI for the project by triggering on manual dispatch, pushes, and pull requests to the main/master branches. The steps for checking out the repository, setting up Node.js (version 20) with npm caching, installing npm dependencies (including dev dependencies), and running tests are clearly defined.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 27-27: no new line character at the end of file
(new-line-at-end-of-file)
README.md (11)
2-16: Updated Badge and Metrics Section
The badge links have been updated to new metrics (e.g., yearly downloads, GitHub stars, last commit times, etc.). Although a bare URL appears on one line (static analysis hint on line 44), styling concerns of this nature have been previously noted as low priority by the project owner. Overall, the updates clearly communicate the project’s current status.
47-54: Clear “Getting Started” Example
The introductory code snippet for initializing and configuring the Binance API client is concise and helps users get started quickly. It clearly shows the required API key and secret placeholders.
93-111: Multiple Orders Example is Well Structured
The example that demonstrates placing multiple orders using an array of order objects is clear and effectively shows how to combine orders. This approach aids users in understanding how to issue batch order requests.
112-119: Utilizing New Order Response Type
The snippet showing usage of the newOrderRespType parameter is a welcome addition—it helps users obtain more detailed order information upon order execution.
1562-1569: Candlestick Data Retrieval Example is Effective
The candlestick (Kline) data example clearly demonstrates how to retrieve historical candlestick data and extract the latest price. The destructuring of the last tick into its components is straightforward and helpful.
1577-1585: WebSocket Chart Cache Example
This example for obtaining a complete WebSocket chart cache is robust. It shows how to use the helper method to get the last candle and log the full chart. Consider removing any obsolete commented code if it no longer serves a purpose.
1649-1660: Real-Time Candlestick Updates via WebSocket
The example that handles real-time candlestick updates uses clear destructuring and logs key data (open, high, low, close, volume, and isFinal flag). This will be very useful for live chart synchronization.
1665-1668: Trade Updates via WebSocket
The snippet on receiving trade updates captures essential fields such as price, quantity, and maker flag. The concise logging will help users monitor live trade data effectively.
1868-1874: Universal (Internal Wallet) Transfer Example
The Universal Transfer example clearly demonstrates how to transfer funds between accounts using async/await. The snippet is brief and to the point, making it easy for users to integrate this functionality.
1996-2000: Succinct Binance Lending API Example
The Lending API example uses async/await to fetch lending account details. It is succinct and informative. Please ensure that any necessary error handling is incorporated in production usage.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1996-1996: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
2055-2096: Informative Troubleshooting and Contribution Sections
The troubleshooting section offers practical advice such as synchronizing server time, adjusting recvWindow, and enabling verbose logging to aid debugging. The Contribution section is friendly and visually appealing, encouraging community involvement through clear calls to action.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
README.md (5)
26-36: Navigation Links Consistency:
The HTML-based navigation links are well organized and visually engaging. For consistency with Markdown’s native syntax, you might consider converting some of these links into standard Markdown links. This is optional, but it could make maintenance easier in the future.
41-43: Fenced Code Block Language:
The code block used for installation instructions (lines 41–43) does not specify a language. Adding a language identifier (for example, ```bash) will enable proper syntax highlighting and improve readability.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
41-41: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
47-49: Bare URL in Community Section:
The “Community Telegram Chat” section includes a bare URL (line 49). Converting this URL into a Markdown link with descriptive text can improve clarity and accessibility. For example:
Join our Telegram Chat🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
49-49: Bare URL used
null(MD034, no-bare-urls)
39-41: Heading Levels Consistency:
Several headings throughout the document (as indicated by static analysis hints at lines 39, 73, 227, 338, 1892, and 2011) do not increment by one level at a time. This can affect document structure and accessibility. If the current hierarchy is an intentional stylistic choice, it may be left as is; otherwise, consider adjusting the heading levels for improved consistency and readability.Also applies to: 73-73, 227-227, 338-338, 1892-1892, 2011-2011
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
39-39: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
41-41: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
2058-2058: Punctuation in Advanced Examples Section:
The static analysis tool noted that abbreviations like “etc.” need a period in American English. Adding a period after “etc” on line 2058 will improve style consistency.🧰 Tools
🪛 LanguageTool
[style] ~2058-~2058: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...(ETC_PERIOD)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(20 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
39-39: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
41-41: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
49-49: Bare URL used
null
(MD034, no-bare-urls)
73-73: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
227-227: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
291-291: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
338-338: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1892-1892: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
2011-2011: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1546-~1546: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2058-~2058: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
🔇 Additional comments (5)
README.md (5)
2-12: Badge Section & Header Comments:
The updated badges and updated links now clearly reflect current metrics (yearly downloads, stars, etc.). This improves the visual appeal and relevance of the information presented. One suggestion is to remove or clean up any commented‐out badge blocks if they are no longer needed, so that the file remains uncluttered.
1941-1947: Margin Orders Update:
The updated instructions and examples for margin-specific order functions (using mgBuy, mgSell, mgMarketBuy, etc.) are clear and consistent with the latest API updates. This precision will help users understand the difference from regular spot trading functionality.
2075-2085: Troubleshooting Section Clarity:
The troubleshooting examples—such as setting options for server time and verbose logging—are comprehensive and useful. They provide clear guidance for resolving timing issues and debugging WebSocket streams.
2089-2095: Use of Asynchronous Server Time Setup:
The inclusion of the asynchronous call (using “await binance.useServerTime()”) before checking balances is a thoughtful touch. It ensures that the system time is in sync with the server, which can prevent common errors.
2101-2111: Contribution Section & Final Badges:
The “Contribution” section is clear and inviting, and the final badges further enhance the document’s professional look. This section effectively encourages community engagement and provides useful links to issues and the git repository.
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
demo.js(1 hunks)
🔇 Additional comments (2)
demo.js (2)
1-1: LGTM!The module import follows Node.js conventions and correctly uses a relative path for the local module.
4-4: Verify the futuresTime API method usage.Let's confirm the correct usage of the
futuresTime()method.✅ Verification successful
🌐 Web query:
What is the Binance Futures API endpoint for server time? How to use futuresTime in node-binance-api?💡 Result:
The Binance Futures API endpoint for retrieving server time is `/fapi/v1/time` for USDⓈ-M Futures and `/dapi/v1/time` for Coin-Margined Futures[1][7]. This endpoint returns a UNIX epoch timestamp in milliseconds, which is crucial for synchronizing requests and avoiding timestamp-related authentication errors[10]. To use `futuresTime()` in **node-binance-api**: ```javascript const Binance = require('node-binance-api'); const client = new Binance().options({ APIKEY: '<your_api_key>', APISECRET: '<your_api_secret>' }); // Get server time client.futuresTime().then(response => { console.log('Server Time:', response); }).catch(console.error); ``` Example response: `1508478457643` (milliseconds since Unix epoch)[3][6] Key details: - **Request Weight**: 1[1] - **Authentication**: Not required - **Response Format**: JSON with single `serverTime` field - **Use Case**: Essential for generating valid signatures in authenticated requests[10] For Coin-Margined Futures using `binance-futures-connector-node`: ```javascript const { CMFutures } = require("@binance/futures-connector"); const cmClient = new CMFutures(null, null, { baseURL: "https://dapi.binance.com" }); cmClient.time() .then(response => console.log(response.data.serverTime)) .catch(console.error); ``` Always use this server time instead of local system time when making authenticated requests to avoid `recvWindow` errors[10]. The timestamp must be within ±5000ms of server time by default[10]. Citations: - 1: https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Check-Server-Time - 2: https://github.com/binance/binance-futures-connector-node - 3: https://classic.yarnpkg.com/en/package/binance-api-node - 4: https://docs.binance.us - 5: https://github.com/jaggedsoft/node-binance-api/blob/master/examples/advanced.md - 6: https://www.npmjs.com/package/binance-api-node/v/0.9.18 - 7: https://github.com/binance/binance-futures-connector-python/blob/main/binance/cm_futures/market.py - 8: https://www.npmjs.com/package/binance-api-node - 9: https://www.npmjs.com/package/binance-api-node/v/0.11.45 - 10: https://dev.binance.vision/t/timestamp-for-this-request-is-outside-of-the-recvwindow/22334
FuturesTime API usage verified.
- The
futuresTime()method is correctly called as shown in the node-binance-api documentation.- It properly retrieves the Binance Futures server time from the correct endpoint (
/fapi/v1/timefor USDⓈ-M Futures).
| async function run() { | ||
| const res = await binance.futuresTime(); | ||
| console.log( res ); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add error handling and improve documentation.
The async function should include error handling and better documentation:
+/**
+ * Fetches and logs the Binance futures server time
+ * @throws {Error} When the futures API call fails
+ */
async function run() {
+ try {
const res = await binance.futuresTime();
- console.log( res );
+ console.log( 'Futures server time:', res );
+ } catch (error) {
+ console.error('Failed to fetch futures time:', error.message);
+ throw error;
+ }
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async function run() { | |
| const res = await binance.futuresTime(); | |
| console.log( res ); | |
| } | |
| /** | |
| * Fetches and logs the Binance futures server time | |
| * @throws {Error} When the futures API call fails | |
| */ | |
| async function run() { | |
| try { | |
| const res = await binance.futuresTime(); | |
| console.log('Futures server time:', res); | |
| } catch (error) { | |
| console.error('Failed to fetch futures time:', error.message); | |
| throw error; | |
| } | |
| } |
| } | ||
|
|
||
|
|
||
| run(); No newline at end of file |
There was a problem hiding this comment.
Handle promise rejection for the async function call.
The async function invocation should handle potential errors:
-run();
+run().catch(error => {
+ console.error('Script failed:', error.message);
+ process.exit(1);
+});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| run(); | |
| run().catch(error => { | |
| console.error('Script failed:', error.message); | |
| process.exit(1); | |
| }); |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
README.md (1)
76-76: Standardize logging method usage.The codebase inconsistently uses both
console.infoandconsole.log. Consider standardizing to one method throughout the documentation.Apply this change consistently across all examples:
-console.log +console.infoAlso applies to: 341-342, 422-423, 489-490, 511-513, 840-841, 1163-1164, 1475-1476, 1501-1503, 1509-1510, 1542-1543, 1549-1550, 1556-1560, 1567-1569, 1579-1581, 1593-1600, 1665-1675, 1681-1683, 1689-1691, 1727-1735, 1770-1773, 1779-1787
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
README.md(20 hunks)package.json(2 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
39-39: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
41-41: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
49-49: Bare URL used
null
(MD034, no-bare-urls)
74-74: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
228-228: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
292-292: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
339-339: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1893-1893: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
2012-2012: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1547-~1547: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2059-~2059: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
🔇 Additional comments (5)
package.json (1)
3-3: Verify the impact of version bump and TypeScript support.The package version has been updated from 0.9.2 to 0.13.1, and TypeScript typings have been added. This is a significant change that could impact existing users.
Let's verify the TypeScript support and check for any breaking changes:
Also applies to: 6-6
❌ Verification inconclusive
🏁 Script executed:
#!/bin/bash # Check if the TypeScript definition file exists and is valid if [ -f "node-binance-api.d.ts" ]; then # Install typescript for validation npm install -g typescript # Validate the TypeScript definitions tsc node-binance-api.d.ts --noEmit else echo "TypeScript definition file not found" fiLength of output: 1839
We'll need to further verify the TypeScript definitions. The previous script attempted to install TypeScript globally, but that failed due to permission issues. I recommend re-running the verification using the local (or on-demand) TypeScript compiler via npx. Please run the following script:
Once we have the output from the above script, we can draw a final conclusion about the TypeScript support and whether there are any breaking changes resulting from the version updates.
🏁 Script executed:
[run_scripts] #!/bin/bash if [ -f "node-binance-api.d.ts" ]; then # Use local npx to execute tsc, this avoids global installation issues. npx tsc node-binance-api.d.ts --noEmit if [ $? -eq 0 ]; then echo "Type definitions are valid." else echo "Type definitions have errors or tsc is not available." fi else echo "TypeScript definition file not found." fiLength of output: 959
Action: Verify TypeScript definitions and dependency version updates manually.
The TypeScript file (“node-binance-api.d.ts”) is present but our automated check failed to validate it because the TypeScript compiler wasn’t available locally. This prevents a conclusive automated verification of the type definitions. Additionally, the major version bumps for dependencies (e.g., socks-proxy-agent, mocha, jsdoc) may introduce breaking changes.
Next steps:
- Add TypeScript as a local devDependency (or otherwise ensure a proper compiler is available) and run
npx tsc node-binance-api.d.ts --noEmitto validate the typings.- Manually test the major dependency upgrades to confirm no breaking issues (especially for users relying on backward compatibility).
README.md (4)
26-37: LGTM! Navigation improvements.The new navigation section improves documentation accessibility by clearly organizing different API sections.
52-60: LGTM! Modern JavaScript example.Good addition of ESM import example with async/await syntax, which follows modern JavaScript best practices.
1891-2057: LGTM! Comprehensive Margin API documentation.The new Margin API section provides clear examples and explanations for all margin-related operations.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
1893-1893: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
2012-2012: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
2010-2056: LGTM! Clear Lending API documentation.The new Lending API section effectively documents the lending functionality with detailed response examples.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
2012-2012: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
package.json (1)
17-25: 🛠️ Refactor suggestionUpdate test and lint configurations.
The test script now points to
./tests/live-tests.jsbut the lint script still references the oldtest.js.Apply this diff to update the lint script:
- "lint": "eslint -c .eslintrc.js node-binance-api.js test.js", + "lint": "eslint -c .eslintrc.js node-binance-api.js tests/live-tests.js",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
package.json(2 hunks)test.js(0 hunks)tests/live-tests.js(1 hunks)
💤 Files with no reviewable changes (1)
- test.js
🧰 Additional context used
🪛 Gitleaks (8.21.2)
tests/live-tests.js
25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
26-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
29-29: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
71-71: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
72-72: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🪛 Biome (1.9.4)
tests/live-tests.js
[error] 8-9: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.
(lint/suspicious/noRedundantUseStrict)
🪛 ESLint
tests/live-tests.js
[error] 53-53: 'stopSockets' is assigned a value but never used.
(no-unused-vars)
🔇 Additional comments (4)
tests/live-tests.js (2)
226-288: Consider enabling commented out test cases.Several test cases for critical functionality like buy/sell orders are commented out. These tests are important for ensuring the reliability of trading operations.
Please verify if these test cases can be enabled with proper test credentials and error handling. If needed, I can help implement mock responses to test these scenarios safely.
901-1341: Consider enabling WebSocket test cases.Multiple WebSocket-related test cases are commented out. WebSocket functionality is crucial for real-time market data and order updates.
Please verify if these test cases can be enabled. Consider:
- Using mock WebSocket servers for testing
- Implementing proper connection cleanup in afterEach hooks
- Adding timeout handling for WebSocket operations
package.json (2)
8-15: Review and update code for breaking changes in dependencies.Several dependencies have major version updates that could introduce breaking changes:
- socks-proxy-agent: 4.0.1 → 8.0.5
- ws: 4.1.0 → 7.2.0
Please verify compatibility with these updates. Key changes to review:
- socks-proxy-agent v8.x requires separate arguments for connection details and agent options
- ws v7.x has breaking changes in the WebSocket client API
40-52: Review and update code for breaking changes in dev dependencies.Several dev dependencies have major version updates that could affect testing:
- mocha: 5.2.0 → 11.1.0
- eslint: 4.19.1 → 6.6.0
- jsdoc: 3.5.5 → 4.0.4
Please verify compatibility with these updates. Key changes to review:
- mocha v11.x uses ESM-first file loading
- eslint v6.x has new rules and breaking changes
- jsdoc v4.x has template and plugin API changes
| let binance = new Binance().options( { | ||
| APIKEY: 'X4BHNSimXOK6RKs2FcKqExquJtHjMxz5hWqF0BBeVnfa5bKFMk7X0wtkfEz0cPrJ', | ||
| APISECRET: 'x8gLihunpNq0d46F2q0TWJmeCDahX5LMXSlv3lSFNbMI3rujSOpTDKdhbcmPSf2i', | ||
| test: true | ||
| } ); |
There was a problem hiding this comment.
Remove hardcoded API credentials from test code.
The test file contains hardcoded API credentials which is a security risk, even if they are test credentials. Consider:
- Moving credentials to environment variables
- Using a configuration file that is not checked into version control
Apply this diff to use environment variables:
-let binance = new Binance().options( {
- APIKEY: 'X4BHNSimXOK6RKs2FcKqExquJtHjMxz5hWqF0BBeVnfa5bKFMk7X0wtkfEz0cPrJ',
- APISECRET: 'x8gLihunpNq0d46F2q0TWJmeCDahX5LMXSlv3lSFNbMI3rujSOpTDKdhbcmPSf2i',
- test: true
-} );
+let binance = new Binance().options( {
+ APIKEY: process.env.BINANCE_API_KEY,
+ APISECRET: process.env.BINANCE_API_SECRET,
+ test: true
+} );📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let binance = new Binance().options( { | |
| APIKEY: 'X4BHNSimXOK6RKs2FcKqExquJtHjMxz5hWqF0BBeVnfa5bKFMk7X0wtkfEz0cPrJ', | |
| APISECRET: 'x8gLihunpNq0d46F2q0TWJmeCDahX5LMXSlv3lSFNbMI3rujSOpTDKdhbcmPSf2i', | |
| test: true | |
| } ); | |
| let binance = new Binance().options( { | |
| APIKEY: process.env.BINANCE_API_KEY, | |
| APISECRET: process.env.BINANCE_API_SECRET, | |
| test: true | |
| } ); |
🧰 Tools
🪛 Gitleaks (8.21.2)
25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
26-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (6)
tests/static-tests.mjs (3)
1-9: Consider using more specific imports.Instead of importing the entire
utilsmodule which isn't used, consider removing unused imports to keep the code clean.-import utils from 'util';
15-26: Add error handling for request interception.The
beforeEachhook should handle potential errors in request interception to prevent test failures from being obscured.beforeEach(() => { interceptedUrl = null; interceptedBody = null; nock(/.*/) .get(/.*/) + .replyWithError((uri) => { + console.error(`Failed to intercept request to ${uri}`); + return new Error('Request interception failed'); + }) .reply(200, function (uri, requestBody) { interceptedUrl = `${this.req.options.proto}://${this.req.options.hostname}${uri}`; interceptedBody = requestBody; return { success: true }; }); });
28-68: Enhance test coverage with additional assertions.The test cases only verify the URL format. Consider adding assertions for:
- Request headers
- Query parameters
- Response handling
Example enhancement for the FetchTicker test:
it( 'FetchTicker', async function ( ) { await binance.prices( 'BNBBTC' ) assert.equal( interceptedUrl, 'https://api.binance.com/api/v3/ticker/price?symbol=BNBBTC' ) + assert.equal( this.req.options.headers['User-Agent'], 'node-binance-api' ) + assert.equal( this.req.options.method, 'GET' ) }).github/workflows/js.yml (1)
1-12: Consider adding concurrency limits.Add concurrency settings to prevent multiple workflow runs from interfering with each other, especially for live tests.
permissions: contents: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true.gitignore (1)
62-63: Document the purpose of ignoring text files.Consider adding a comment explaining why text files are being ignored to help future maintainers understand the rationale.
+# Generated files # +################ *.txtpackage.json (1)
18-19: Consider adding test coverage reporting.The test scripts have been updated, but coverage reporting scripts might need adjustment for the new test structure.
"scripts": { "test": "mocha ./tests/live-tests.js", "static-test": "mocha ./tests/static-tests.mjs", + "coverage": "nyc --reporter=lcov --reporter=text-summary npm run test", + "coverage:static": "nyc --reporter=lcov --reporter=text-summary npm run static-test",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (7)
.github/workflows/js.yml(1 hunks).gitignore(1 hunks).travis.yml(0 hunks)examples/standalone.js(0 hunks)launch.json(0 hunks)package.json(2 hunks)tests/static-tests.mjs(1 hunks)
💤 Files with no reviewable changes (3)
- launch.json
- examples/standalone.js
- .travis.yml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/js.yml
[error] 29-29: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (2)
package.json (2)
8-15: ** Update code for breaking changes in dependencies.**As noted in previous reviews, several dependencies have breaking changes that need to be addressed.
6-6: Verify TypeScript typings file exists.The package now includes TypeScript typings, but the referenced file needs to be verified.
✅ Verification successful
🏁 Script executed:
#!/bin/bash # Check if the TypeScript typings file exists if [ ! -f "node-binance-api.d.ts" ]; then echo "TypeScript typings file is missing" exit 1 fiLength of output: 38
TypeScript typings file verified: The file "node-binance-api.d.ts" exists at the repository's root, as indicated by the absence of an error message from the inspection script.
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 2 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
| - name: Install npm dependencies | ||
| run: npm i --include=dev | ||
| - name: Static Tests | ||
| run: npm run static-test | ||
| - name: Live Tests | ||
| run: npm run test No newline at end of file |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add missing newline and enhance job configuration.
The file is missing a newline at the end. Also, consider adding timeouts and environment setup for the tests.
- name: Live Tests
run: npm run test
+ timeout-minutes: 10
+ env:
+ NODE_ENV: test
+📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install npm dependencies | |
| run: npm i --include=dev | |
| - name: Static Tests | |
| run: npm run static-test | |
| - name: Live Tests | |
| run: npm run test | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install npm dependencies | |
| run: npm i --include=dev | |
| - name: Static Tests | |
| run: npm run static-test | |
| - name: Live Tests | |
| run: npm run test | |
| timeout-minutes: 10 | |
| env: | |
| NODE_ENV: test |
🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 29-29: no new line character at the end of file
(new-line-at-end-of-file)
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
tests/live-tests.js (1)
24-28:⚠️ Potential issueRemove hardcoded API credentials from test code.
The test file contains hardcoded API credentials which is a security risk, even if they are test credentials.
Consider:
- Moving credentials to environment variables
- Using a configuration file that is not checked into version control
Apply this diff to use environment variables:
-let binance = new Binance().options( { - APIKEY: 'X4BHNSimXOK6RKs2FcKqExquJtHjMxz5hWqF0BBeVnfa5bKFMk7X0wtkfEz0cPrJ', - APISECRET: 'x8gLihunpNq0d46F2q0TWJmeCDahX5LMXSlv3lSFNbMI3rujSOpTDKdhbcmPSf2i', - test: true -} ); +let binance = new Binance().options( { + APIKEY: process.env.BINANCE_API_KEY, + APISECRET: process.env.BINANCE_API_SECRET, + test: true +} );Also update the second instance:
- binance.options( { - APIKEY: 'X4BHNSimXOK6RKs2FcKqExquJtHjMxz5hWqF0BBeVnfa5bKFMk7X0wtkfEz0cPrJ', - APISECRET: 'x8gLihunpNq0d46F2q0TWJmeCDahX5LMXSlv3lSFNbMI3rujSOpTDKdhbcmPSf2i', - useServerTime: true, - reconnect: false, - verbose: true, - test: true, - log: debug - } ); + binance.options( { + APIKEY: process.env.BINANCE_API_KEY, + APISECRET: process.env.BINANCE_API_SECRET, + useServerTime: true, + reconnect: false, + verbose: true, + test: true, + log: debug + } );Also applies to: 70-78
🧰 Tools
🪛 Gitleaks (8.21.2)
25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
26-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🧹 Nitpick comments (3)
tests/live-tests.js (3)
9-9: Remove redundant 'use strict' directive.The 'use strict' directive is redundant in ES modules as they are automatically in strict mode.
-'use strict';🧰 Tools
🪛 Biome (1.9.4)
[error] 8-9: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.(lint/suspicious/noRedundantUseStrict)
37-43: Consider using a logging library.The custom logger implementation could be replaced with a proper logging library like Winston or Bunyan for better features and maintainability.
Consider using Winston:
const winston = require('winston'); const logger = winston.createLogger({ level: 'debug', format: winston.format.combine( winston.format.timestamp(), winston.format.json() ), transports: [ new winston.transports.Console() ] });
53-60: Fix unused variable warning.The
stopSocketsfunction is defined but never used due to commented out WebSocket tests.Either:
- Remove the unused function if WebSocket tests are permanently disabled
- Enable the WebSocket tests that use this function
-let stopSockets = function ( log = false ) { - //stopSocketsRunning = true; - let endpoints = binance.websockets.subscriptions(); - for ( let endpoint in endpoints ) { - if ( log ) console.log( 'Terminated ws endpoint: ' + endpoint ); - binance.websockets.terminate( endpoint ); - } -}🧰 Tools
🪛 ESLint
[error] 53-53: 'stopSockets' is assigned a value but never used.
(no-unused-vars)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/live-tests.js(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
tests/live-tests.js
[error] 8-9: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.
(lint/suspicious/noRedundantUseStrict)
🪛 Gitleaks (8.21.2)
tests/live-tests.js
25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
26-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
29-29: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
71-71: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
72-72: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🪛 ESLint
tests/live-tests.js
[error] 53-53: 'stopSockets' is assigned a value but never used.
(no-unused-vars)
🔇 Additional comments (2)
tests/live-tests.js (2)
226-242: Consider enabling commented test cases.Several test cases are commented out. If these tests are still relevant, they should be enabled and updated. If they are no longer needed, they should be removed.
Run this script to check if these test cases are still relevant:
Also applies to: 261-267, 269-277, 279-288, 290-297
✅ Verification successful
🏁 Script executed:
#!/bin/bash # Check if the commented out test cases have corresponding API endpoints # Search for the API endpoints in the codebase rg -l "buy|sell|marketBuy|marketSell" --type js # Check if there are any related tests in other test files fd -e js -e ts -p "test.*" --exec grep -l "buy|sell|marketBuy|marketSell" {} \;Length of output: 221
Action: Verify the relevance of the commented-out test cases in tests/live-tests.js
We ran a script that searched for API endpoints related to "buy", "sell", "marketBuy", and "marketSell". The results confirm that these endpoints are mentioned only in the contexts of the tests and examples (not in additional test files). This suggests that the commented-out tests in tests/live-tests.js are the only test cases exercising these API methods.
Considering that:
- The API methods (e.g.,
binance.buy()andbinance.sell()) are indeed referenced in the codebase (e.g., in node-binance-api.js and examples).- There are currently no alternative tests exercising these endpoints in other test files.
It would be preferable to re-enable these tests—after verifying that they function correctly and reflect any changes in the API—to ensure comprehensive test coverage for these endpoints. If they are now outdated or redundant, they should be removed entirely.
Recommendations:
- Enable and update the tests in tests/live-tests.js if the
binance.buy()andbinance.sell()functions are still active and relevant.- Alternatively, if these functions are deprecated or replaced, remove the commented code and update documentation accordingly.
910-1256: Consider enabling WebSocket tests.A large section of WebSocket-related tests is commented out. These tests are important for ensuring real-time data functionality.
Run this script to check if WebSocket functionality is still supported:
✅ Verification successful
🏁 Script executed:
#!/bin/bash # Check if WebSocket functionality is still present in the codebase # Search for WebSocket-related code rg -l "websockets?|ws" --type js # Check for WebSocket dependencies in package.json jq '.dependencies | keys | .[] | select(contains("ws"))' package.jsonLength of output: 280
WebSocket tests are intentionally disabled but functionality is still supported.
- The dependency
"ws"in package.json confirms that WebSocket functionality is active.- Multiple examples (e.g., in
examples/websocket-ticker.jsand others) indicate ongoing support for WebSocket features.- The tests in
tests/live-tests.jsare commented out as part of an intentional temporary disablement. Consider re-enabling them if real-time data functionality needs regular verification.
| describe( 'MarketBuy', function () { | ||
| it( 'Attempt to buy LTC at market price', async function () { | ||
| let quantity = 0.5; | ||
| const res = await binance.marketBuy( 'LTCUSDT', quantity ) | ||
| assert( res['orderId'] !== undefined ) | ||
| } ).timeout( TIMEOUT ); | ||
| } ); | ||
|
|
||
|
|
||
| describe( 'MarketSell', function () { | ||
| it( 'Attempt to buy LTC at market price', async function () { | ||
| let quantity = 0.5; | ||
| const res = await binance.marketSell( 'LTCUSDT', quantity ) | ||
| assert( res['orderId'] !== undefined ) | ||
| } ).timeout( TIMEOUT ); | ||
| } ); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add error handling tests for market orders.
The market order tests only verify successful cases. Consider adding tests for error scenarios like insufficient funds or invalid quantities.
Add error test cases:
describe('MarketBuy', function () {
it('Should handle insufficient balance error', async function () {
let quantity = 999999;
try {
await binance.marketBuy('LTCUSDT', quantity);
assert.fail('Should have thrown an error');
} catch (error) {
assert(error.message.includes('insufficient balance'));
}
});
});There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
tests/live-tests.js (2)
24-28:⚠️ Potential issueCritical: Remove hardcoded API credentials from test code.
The test file contains multiple instances of hardcoded API credentials which is a security risk, even if they are test credentials. This was previously flagged in a past review and needs to be addressed.
Move the credentials to environment variables:
-let binance = new Binance().options( { - APIKEY: 'X4BHNSimXOK6RKs2FcKqExquJtHjMxz5hWqF0BBeVnfa5bKFMk7X0wtkfEz0cPrJ', - APISECRET: 'x8gLihunpNq0d46F2q0TWJmeCDahX5LMXSlv3lSFNbMI3rujSOpTDKdhbcmPSf2i', - test: true -} ); +let binance = new Binance().options( { + APIKEY: process.env.BINANCE_API_KEY, + APISECRET: process.env.BINANCE_API_SECRET, + test: true +} ); -let futuresBinance = new Binance().options( { - APIKEY: '227719da8d8499e8d3461587d19f259c0b39c2b462a77c9b748a6119abd74401', - APISECRET: 'b14b935f9cfacc5dec829008733c40da0588051f29a44625c34967b45c11d73c', - hedgeMode: true, - test: true -} ); +let futuresBinance = new Binance().options( { + APIKEY: process.env.BINANCE_FUTURES_API_KEY, + APISECRET: process.env.BINANCE_FUTURES_API_SECRET, + hedgeMode: true, + test: true +} );Also applies to: 29-34, 76-84
🧰 Tools
🪛 Gitleaks (8.21.2)
25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
26-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
250-265: 🛠️ Refactor suggestionAdd error handling tests for market orders.
The market order tests only verify successful cases. Consider adding tests for error scenarios like insufficient funds or invalid quantities.
Add error test cases:
describe('MarketBuy', function () { it('Should handle insufficient balance error', async function () { let quantity = 999999; try { await binance.marketBuy('LTCUSDT', quantity); assert.fail('Should have thrown an error'); } catch (error) { assert(error.message.includes('insufficient balance')); } }); });
🧹 Nitpick comments (2)
tests/live-tests.js (2)
9-9: Remove redundant 'use strict' directive.The 'use strict' directive is redundant in ES modules as they are automatically in strict mode.
-'use strict';🧰 Tools
🪛 Biome (1.9.4)
[error] 8-9: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.(lint/suspicious/noRedundantUseStrict)
59-66: Fix unused function warning.The
stopSocketsfunction is defined but never used according to static analysis. Either use it in the tests or remove it.-let stopSockets = function ( log = false ) { - //stopSocketsRunning = true; - let endpoints = binance.websockets.subscriptions(); - for ( let endpoint in endpoints ) { - if ( log ) console.log( 'Terminated ws endpoint: ' + endpoint ); - binance.websockets.terminate( endpoint ); - } -}🧰 Tools
🪛 ESLint
[error] 59-59: 'stopSockets' is assigned a value but never used.
(no-unused-vars)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/live-tests.js(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
tests/live-tests.js
[error] 8-9: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.
(lint/suspicious/noRedundantUseStrict)
🪛 Gitleaks (8.21.2)
tests/live-tests.js
25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
26-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
31-31: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
35-35: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
36-36: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
77-77: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
78-78: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🪛 ESLint
tests/live-tests.js
[error] 59-59: 'stopSockets' is assigned a value but never used.
(no-unused-vars)
🔇 Additional comments (2)
tests/live-tests.js (2)
232-248: Consider enabling commented test cases.There are multiple commented-out test cases for important functionality like buy/sell orders. These should either be enabled and fixed or removed if no longer needed.
Would you like me to help implement these test cases with proper error handling and mocked responses?
933-1373: Enable or remove commented websocket tests.A large section of websocket-related tests is commented out. These tests are important for ensuring websocket functionality works correctly. Consider enabling them with proper mocking of the websocket connections.
Would you like me to help implement these test cases with proper websocket mocking?
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
tests/static-tests.mjs (3)
4-4: Fix formatting in import statement.Remove the extra space after
from.-import Binance from '../node-binance-api.js' +import Binance from '../node-binance-api.js'
32-57: Refactor Nock setup to reduce duplication.The Nock setup contains duplicated code for different HTTP methods. Consider refactoring to reduce duplication and add error scenarios.
beforeEach(() => { interceptedUrl = null; interceptedBody = null; - nock(/.*/) - .get(/.*/) - .reply(200, function (uri, requestBody) { - interceptedUrl = `${this.req.options.proto}://${this.req.options.hostname}${uri}`; - interceptedBody = requestBody; - return { success: true }; - }); - nock(/.*/) - .post(/.*/) - .reply(200, function (uri, requestBody) { - interceptedUrl = `${this.req.options.proto}://${this.req.options.hostname}${uri}`; - interceptedBody = requestBody; - return { success: true }; - }); - nock(/.*/) - .delete(/.*/) - .reply(200, function (uri, requestBody) { - interceptedUrl = `${this.req.options.proto}://${this.req.options.hostname}${uri}`; - interceptedBody = requestBody; - return { success: true }; - }); + const replyFn = function (uri, requestBody) { + interceptedUrl = `${this.req.options.proto}://${this.req.options.hostname}${uri}`; + interceptedBody = requestBody; + return { success: true }; + }; + + ['get', 'post', 'delete'].forEach(method => { + nock(/.*/) + [method](/.*/) + .reply(200, replyFn); + }); });Also consider adding error scenarios:
// Add after the success scenarios afterEach(() => { // Test rate limit errors nock(/.*/) .get(/.*/) .reply(429, { code: -1003, msg: "Too many requests" }); // Test server errors nock(/.*/) .get(/.*/) .reply(500, { code: -1002, msg: "Internal server error" }); });
59-207: Enhance test coverage with parameterized tests and error scenarios.The test suite would benefit from:
- Parameterized tests for similar operations
- Error handling scenarios
- Edge cases testing
Example of parameterized tests:
const marketOperations = [ { name: 'MarketBuy', fn: binance.marketBuy, params: ['LTCUSDT', 0.5], expected: { url: 'https://api.binance.com/api/v3/order', body: { symbol: 'LTCUSDT', side: 'BUY', type: 'MARKET', quantity: 0.5 } } }, // Add more operations... ]; marketOperations.forEach(({ name, fn, params, expected }) => { it(name, async () => { await fn.apply(binance, params); assert.equal(interceptedUrl, expected.url); const obj = urlToObject(interceptedBody); Object.entries(expected.body).forEach(([key, value]) => { assert.equal(obj[key], value); }); }); });Example of error handling tests:
it('handles rate limit errors', async () => { nock(/.*/) .get(/.*/) .reply(429, { code: -1003, msg: "Too many requests" }); try { await binance.prices('BNBBTC'); assert.fail('Should throw rate limit error'); } catch (error) { assert.equal(error.code, -1003); } });Example of edge cases:
it('handles zero quantity', async () => { try { await binance.marketBuy('LTCUSDT', 0); assert.fail('Should throw invalid quantity error'); } catch (error) { assert.match(error.message, /Invalid quantity/); } });
| const debug = function ( x ) { | ||
| if ( typeof ( process.env.node_binance_api ) === 'undefined' ) { | ||
| return; | ||
| } | ||
| logger.log( typeof ( x ) ); | ||
| logger.log( util.inspect( x ) ); | ||
| } |
There was a problem hiding this comment.
Fix undefined references in debug function.
The debug function references undefined logger and uses util instead of the imported utils.
const debug = function ( x ) {
if ( typeof ( process.env.node_binance_api ) === 'undefined' ) {
return;
}
- logger.log( typeof ( x ) );
- logger.log( util.inspect( x ) );
+ console.log( typeof ( x ) );
+ console.log( utils.inspect( x ) );
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const debug = function ( x ) { | |
| if ( typeof ( process.env.node_binance_api ) === 'undefined' ) { | |
| return; | |
| } | |
| logger.log( typeof ( x ) ); | |
| logger.log( util.inspect( x ) ); | |
| } | |
| const debug = function ( x ) { | |
| if ( typeof ( process.env.node_binance_api ) === 'undefined' ) { | |
| return; | |
| } | |
| console.log( typeof ( x ) ); | |
| console.log( utils.inspect( x ) ); | |
| } |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
README.md (4)
57-75: Improve Getting Started section with TypeScript support.The Getting Started section should mention TypeScript support since the package includes type definitions.
Add TypeScript example:
+#### Getting started (TypeScript) +```typescript +import Binance from 'node-binance-api'; + +async function run() { + const exchange = new Binance({ + APIKEY: '<key>', + APISECRET: '<secret>', + test: true // if you want to use the sandbox/testnet + }); + const res = await exchange.futuresTime(); + console.log(res); +} +```
1899-1904: Add error handling example for margin transfer.The margin transfer example should include proper error handling and type information.
Improve the example:
-binance.mgTransferMainToMargin(asset, amount, (error, response) => { - if ( error ) return console.warn(error); - // Success! Transaction ID: response.tranId -}); +// Example: Transfer 1.5 BTC from Main account to Margin account +binance.mgTransferMainToMargin('BTC', 1.5, (error, response) => { + if (error) { + console.error('Transfer failed:', error.message); + return; + } + console.info(`Transfer successful! Transaction ID: ${response.tranId}`); + console.info('Transferred amount:', response.amount); +});
2019-2020: Add type information and error handling for lending API.The lending API example lacks proper error handling and type information.
Improve the example:
-let lendingData = await binance.lending(); +try { + const lendingData = await binance.lending(); + console.info('Total amount in USDT:', lendingData.totalAmountInUSDT); + console.info('Total amount in BTC:', lendingData.totalAmountInBTC); + + // Process position amounts + lendingData.positionAmountVos.forEach(position => { + console.info(`${position.asset} amount: ${position.amount}`); + }); +} catch (error) { + console.error('Failed to fetch lending data:', error.message); +}
2081-2090: Add rate limiting information to configuration options.The troubleshooting section should include information about rate limits.
Add rate limit information:
binance.options({ APIKEY: 'xxx', APISECRET: 'xxx', useServerTime: true, recvWindow: 60000, // Set a higher recvWindow to increase response timeout verbose: true, // Add extra output when subscribing to WebSockets, etc + // Rate limits for REST API requests + // See https://binance-docs.github.io/apidocs/spot/en/#limits + handleDrift: true, // Automatically handle time drift + reconnect: true, // Automatically reconnect on connection loss log: log => { console.log(log); // You can create your own logger here, or disable console output } });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(20 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
44-44: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
46-46: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
54-54: Bare URL used
null
(MD034, no-bare-urls)
79-79: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
233-233: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
297-297: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
344-344: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1898-1898: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
2017-2017: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1552-~1552: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2064-~2064: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
publish.sh (2)
8-9: Improve version update handling and add safety checks.The current implementation lacks error handling and backup mechanisms.
Apply this diff to improve the version update process:
-# cut the release -VERSION=$(npm --no-git-tag-version version $RELEASE | sed 's/v//') +# Backup package.json +cp package.json package.json.bak + +# Update version +if ! VERSION=$(npm --no-git-tag-version version $RELEASE 2>&1); then + echo "Error: Failed to update version" + mv package.json.bak package.json + exit 1 +fi + +# Clean version string +VERSION=${VERSION#v} + +# Remove backup on success +rm package.json.bak
18-22: Enhance user instructions and add safety checks.The current implementation lacks npm credential verification and user confirmation.
Apply this diff to improve the user instructions:
-echo -e "\033[1;92m You are ready to publish!" -echo -e "\033[1;95m git push" -echo -e "\033[1;95m git push --tags" -echo -e "\033[1;95m npm publish" +# Define colors +GREEN='\033[1;92m' +MAGENTA='\033[1;95m' +NC='\033[0m' # No Color + +# Verify npm credentials +if ! npm whoami >/dev/null 2>&1; then + echo "Error: Not logged in to npm. Run 'npm login' first." + exit 1 +fi + +# Show summary and prompt for confirmation +echo -e "${GREEN}Release Summary:${NC}" +echo -e " Version: ${VERSION}" +echo -e " Branch: ${CURRENT_BRANCH}" +echo -e " npm user: $(npm whoami)" +echo +echo -e "${MAGENTA}Next steps:${NC}" +echo -e " git push" +echo -e " git push --tags" +echo -e " npm publish" +echo +read -p "Continue with publishing? [y/N] " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "Aborted." + exit 1 +fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
package.json(2 hunks)publish.sh(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
🧰 Additional context used
🪛 Shellcheck (0.10.0)
publish.sh
[error] 2-2: The shebang must be on the first line. Delete blanks and move comments.
(SC1128)
| # release defaults to patch (last number in semver) | ||
| RELEASE="patch" && [ -n "$1" ] && RELEASE=$1 |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Improve release type handling and add usage information.
The current implementation lacks input validation and usage information.
Apply this diff to improve the release type handling:
-# release defaults to patch (last number in semver)
-RELEASE="patch" && [ -n "$1" ] && RELEASE=$1
+# Valid release types
+VALID_RELEASES="major minor patch"
+
+# Show usage information
+usage() {
+ echo "Usage: $0 [release_type]"
+ echo " release_type: one of [${VALID_RELEASES}] (default: patch)"
+ exit 1
+}
+
+# Set release type
+RELEASE=${1:-patch}
+
+# Validate release type
+if [[ ! " ${VALID_RELEASES} " =~ " ${RELEASE} " ]]; then
+ echo "Error: Invalid release type '${RELEASE}'"
+ usage
+fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # release defaults to patch (last number in semver) | |
| RELEASE="patch" && [ -n "$1" ] && RELEASE=$1 | |
| # Valid release types | |
| VALID_RELEASES="major minor patch" | |
| # Show usage information | |
| usage() { | |
| echo "Usage: $0 [release_type]" | |
| echo " release_type: one of [${VALID_RELEASES}] (default: patch)" | |
| exit 1 | |
| } | |
| # Set release type | |
| RELEASE=${1:-patch} | |
| # Validate release type | |
| if [[ ! " ${VALID_RELEASES} " =~ " ${RELEASE} " ]]; then | |
| echo "Error: Invalid release type '${RELEASE}'" | |
| usage | |
| fi |
| git add package.json | ||
| git commit -m "release: cut the $VERSION release" | ||
|
|
||
| # tag the release | ||
| git tag $VERSION | ||
| git tag -l |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add Git operation safeguards.
The current implementation lacks Git operation validations.
Apply this diff to add Git operation safeguards:
+# Ensure we're on main/master branch
+CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+if [[ "$CURRENT_BRANCH" != "main" && "$CURRENT_BRANCH" != "master" ]]; then
+ echo "Error: Must be on main/master branch to release"
+ exit 1
+fi
+
+# Check for clean working directory
+if ! git diff-index --quiet HEAD --; then
+ echo "Error: Working directory is not clean"
+ exit 1
+fi
+
+# Check if tag already exists
+if git rev-parse "$VERSION" >/dev/null 2>&1; then
+ echo "Error: Tag $VERSION already exists"
+ exit 1
+fi
+
git add package.json
-git commit -m "release: cut the $VERSION release"
+git commit -m "release: cut the $VERSION release" || {
+ echo "Error: Failed to create commit"
+ exit 1
+}
-# tag the release
-git tag $VERSION
-git tag -l
+# Create annotated tag with release message
+git tag -a "$VERSION" -m "Release $VERSION" || {
+ echo "Error: Failed to create tag"
+ exit 1
+}
+
+# List tags for verification
+git tag -n1 | grep "$VERSION"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| git add package.json | |
| git commit -m "release: cut the $VERSION release" | |
| # tag the release | |
| git tag $VERSION | |
| git tag -l | |
| # Ensure we're on main/master branch | |
| CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
| if [[ "$CURRENT_BRANCH" != "main" && "$CURRENT_BRANCH" != "master" ]]; then | |
| echo "Error: Must be on main/master branch to release" | |
| exit 1 | |
| fi | |
| # Check for clean working directory | |
| if ! git diff-index --quiet HEAD --; then | |
| echo "Error: Working directory is not clean" | |
| exit 1 | |
| fi | |
| # Check if tag already exists | |
| if git rev-parse "$VERSION" >/dev/null 2>&1; then | |
| echo "Error: Tag $VERSION already exists" | |
| exit 1 | |
| fi | |
| git add package.json | |
| git commit -m "release: cut the $VERSION release" || { | |
| echo "Error: Failed to create commit" | |
| exit 1 | |
| } | |
| # Create annotated tag with release message | |
| git tag -a "$VERSION" -m "Release $VERSION" || { | |
| echo "Error: Failed to create tag" | |
| exit 1 | |
| } | |
| # List tags for verification | |
| git tag -n1 | grep "$VERSION" |
|
|
||
| #!/bin/bash | ||
| set -e | ||
|
|
There was a problem hiding this comment.
Fix shebang line position and enhance error handling.
The shebang must be on the first line to ensure proper script execution across different systems.
Apply this diff to fix the shebang position and add additional error handling:
-
-#!/bin/bash
-set -e
-
+#!/bin/bash
+set -euo pipefail
+
+# Ensure required commands are available
+command -v npm >/dev/null 2>&1 || { echo "npm is required but not installed. Aborting." >&2; exit 1; }
+command -v git >/dev/null 2>&1 || { echo "git is required but not installed. Aborting." >&2; exit 1; }The changes:
- Move shebang to first line
- Add
set -uto exit on undefined variables - Add
set -o pipefailto catch pipe failures - Add checks for required commands
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #!/bin/bash | |
| set -e | |
| #!/bin/bash | |
| set -euo pipefail | |
| # Ensure required commands are available | |
| command -v npm >/dev/null 2>&1 || { echo "npm is required but not installed. Aborting." >&2; exit 1; } | |
| command -v git >/dev/null 2>&1 || { echo "git is required but not installed. Aborting." >&2; exit 1; } |
🧰 Tools
🪛 Shellcheck (0.10.0)
[error] 2-2: The shebang must be on the first line. Delete blanks and move comments.
(SC1128)
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
README.md (1)
2-16: 🛠️ Refactor suggestionImprove badge section formatting.
The badge section contains commented-out badges and raw URLs that should be properly formatted as markdown links for better maintainability.
Apply this diff to improve the badge section:
-<!-- [](https://dev.binance.vision/) --> - -<!--  --> -<!-- [](https://www.npmjs.com/package/node-binance-api) [](https://travis-ci.org/jaggedsoft/node-binance-api) [](https://coveralls.io/github/jaggedsoft/node-binance-api) [](https://codecov.io/github/jaggedsoft/node-binance-api/) [](https://www.codacy.com/app/jaggedsoft/node-binance-api?utm_source=github.com&utm_medium=referral&utm_content=jaggedsoft/node-binance-api&utm_campaign=Badge_Coverage) [](https://www.codacy.com/app/jaggedsoft/node-binance-api) https://img.shields.io/npm/dm/node-binance-api.svg?labelColor=blueviolet) -https://badgen.net/npm/dm/node-binance-api?labelColor=7C4DFF&color=green&scale=2&label=Downloads&icon=bitcoin -🟣 Used by 727 https://badgen.net/github/dependents-repo/jaggedsoft/node-binance-api?labelColor=blue&color=purple&label=Used%20by&icon=github -🧪 Releases 87 https://badgen.net/github/releases/jaggedsoft/node-binance-api?scale=2&icon=github&labelColor=purple&color=green&label=%F0%9F%A7%AA%20Release -🎈💡 Merged PRs 79 https://badgen.net/github/merged-prs/jaggedsoft/node-binance-api -⭐ Stars 630 https://badgen.net/github/stars/jaggedsoft/node-binance-api?scale=2&label=%E2%AD%90Stars&labelColor=black&color=purple -✅ship Commits 568 https://badgen.net/github/commits/micromatch/micromatch?label=%E2%9C%A8Commits&labelColor=black&color=red -⚡ Updated about 16 hours ago https://badgen.net/github/last-commit/jaggedsoft/node-binance-api?scale=2&icon=bitcoin-lightning&label=Updated&labelColor=black&color=448AFF -👀👁 Watchers 48 https://badgen.net/github/watchers/jaggedsoft/node-binance-api -color=blueviolet 🔵q ---> +[](https://www.npmjs.com/package/node-binance-api) +[](https://github.com/jaggedsoft/node-binance-api/network/dependents) +[](https://github.com/jaggedsoft/node-binance-api/releases) +[](https://github.com/jaggedsoft/node-binance-api/stargazers) +[](https://github.com/jaggedsoft/node-binance-api/commits) +[](https://github.com/jaggedsoft/node-binance-api/watchers)
🧹 Nitpick comments (2)
README.md (2)
44-50: Clean up installation section.Remove the commented-out npm badge for cleaner documentation.
Apply this diff:
#### Installationnpm install -s node-binance-api
[](https://npmjs.org/package/node-binance-api) -<!-- [](https://npmjs.org/package/node-binance-api) -->🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
44-44: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
46-46: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
1900-1903: Add error handling example.The margin transfer example would benefit from additional error handling details.
Add error handling example:
binance.mgTransferMainToMargin(asset, amount, (error, response) => { - if ( error ) return console.warn(error); + if ( error ) { + if (error.code === -3015) { + console.error('Transfer failed: Insufficient balance'); + } else if (error.code === -3041) { + console.error('Transfer failed: Property not found'); + } else { + console.error('Transfer failed:', error.msg); + } + return; + } // Success! Transaction ID: response.tranId });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(20 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
44-44: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
46-46: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
54-54: Bare URL used
null
(MD034, no-bare-urls)
79-79: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
233-233: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
297-297: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
344-344: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1898-1898: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
2017-2017: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1552-~1552: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2064-~2064: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
🔇 Additional comments (3)
README.md (3)
31-42: LGTM!The navigation menu is well-structured and follows markdown best practices. The links are properly formatted with appropriate styling.
57-75: LGTM!The getting started section provides clear examples for both ESM and CJS imports, along with proper configuration options.
2076-2101: LGTM!The troubleshooting section provides comprehensive guidance for common issues, with clear examples for server time synchronization and timeout configuration.
| https://t.me/nodebinanceapi | ||
|
|
||
|
|
||
| **This project is powered by** <a href="https://github.com/ccxt/ccxt"><img src="https://avatars.githubusercontent.com/u/31901609" width=5% height=5%></a> |
There was a problem hiding this comment.
This image is missing a text alternative. This is a problem for people using screen readers.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
README.md (1)
1956-1956: Clarify callback usage.The statement "Usage and callbacks are the same as the 'regular account' counterparts" is inconsistent with the examples shown, which demonstrate both callback and async/await patterns. Consider clarifying that both patterns are supported.
-Usage and callbacks are the same as the 'regular account' counterparts. +Usage supports both callbacks and async/await patterns, similar to the 'regular account' counterparts.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(20 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
44-44: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
46-46: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
54-54: Bare URL used
null
(MD034, no-bare-urls)
57-57: Images should have alternate text (alt text)
null
(MD045, no-alt-text)
82-82: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
236-236: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
300-300: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
347-347: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1901-1901: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
2020-2020: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1555-~1555: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2067-~2067: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
🔇 Additional comments (4)
README.md (4)
2-16: Fix badge formatting and remove commented-out code.The badge section still contains multiple commented-out badges and raw URLs that should be properly formatted as markdown links.
31-42: LGTM! Well-structured navigation menu.The navigation menu is well-organized and provides clear access to all major sections of the documentation.
1952-1952: Add missing comma.A comma is missing after "orders".
44-78:Details
✅ Verification successful
Verify the latest package version.
Let's check if there's a newer version of the package available.
🌐 Web query:
What is the latest version of node-binance-api on npm?💡 Result:
The latest version of
node-binance-apion npm is 0.13.4, published a day ago[1]. This package provides comprehensive coverage of Binance APIs, including Spot Trading, Futures, Margin, and WebSocket streaming capabilities[1][7].For comparison:
- The security-focused
binance-api-nodepackage (a different library) has version 0.12.9[10]- Binance's official
binanceSDK (another alternative) is at 2.15.9 with active maintenance[6]Key updates in
node-binance-apiinclude recent fixes for futures position handling and delivery API improvements[7]. Developers using Next.js should note potential compatibility considerations with server-side rendering[2].Citations:
- 1: https://www.npmjs.com/package/node-binance-api
- 2: https://dev.binance.vision/t/best-npm-package-for-next-js/16497
- 3: https://socket.dev/npm/package/updated-node-binance-api
- 4: https://www.npmjs.com/package/binance-api-nodejs?activeTab=code
- 5: https://classic.yarnpkg.com/en/package/binance-api-node
- 6: https://www.npmjs.com/package/binance
- 7: https://github.com/jaggedsoft/node-binance-api/releases
- 8: https://dev.binance.vision/t/my-new-open-source-npm-binance-api-library-binance-lib/14294
- 9: https://security.snyk.io/package/npm/node-binance-api
- 10: https://www.npmjs.com/package/binance-api-node
Latest Package Version Verified: 0.13.4 Confirmed
The installation and "Getting Started" sections are clear and well-documented. We verified that the latest version on npm is indeed 0.13.4 (published a day ago). Please ensure that this version is intended for use or consider noting the version explicitly in the documentation if specific compatibility is required.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
44-44: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
46-46: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
54-54: Bare URL used
null(MD034, no-bare-urls)
57-57: Images should have alternate text (alt text)
null(MD045, no-alt-text)
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (4)
tests/live-tests.js (4)
24-28:⚠️ Potential issueRemove hardcoded API credentials from test code.
The test file contains hardcoded API credentials which is a security risk, even if they are test credentials.
Apply this diff to use environment variables:
-let binance = new Binance().options( { - APIKEY: 'X4BHNSimXOK6RKs2FcKqExquJtHjMxz5hWqF0BBeVnfa5bKFMk7X0wtkfEz0cPrJ', - APISECRET: 'x8gLihunpNq0d46F2q0TWJmeCDahX5LMXSlv3lSFNbMI3rujSOpTDKdhbcmPSf2i', - test: true -} ); +let binance = new Binance().options( { + APIKEY: process.env.BINANCE_API_KEY, + APISECRET: process.env.BINANCE_API_SECRET, + test: true +} );🧰 Tools
🪛 Gitleaks (8.21.2)
25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
26-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
257-272: 🛠️ Refactor suggestionAdd error handling tests for market orders.
The market order tests only verify successful cases. Consider adding tests for error scenarios like insufficient funds or invalid quantities.
Add error test cases:
describe('MarketBuy', function () { it('Should handle insufficient balance error', async function () { let quantity = 999999; try { await binance.marketBuy('LTCUSDT', quantity); assert.fail('Should have thrown an error'); } catch (error) { assert(error.message.includes('insufficient balance')); } }); });
76-84:⚠️ Potential issueRemove duplicate hardcoded API credentials.
API credentials are duplicated in the Construct test.
Apply this diff:
- binance.options( { - APIKEY: 'X4BHNSimXOK6RKs2FcKqExquJtHjMxz5hWqF0BBeVnfa5bKFMk7X0wtkfEz0cPrJ', - APISECRET: 'x8gLihunpNq0d46F2q0TWJmeCDahX5LMXSlv3lSFNbMI3rujSOpTDKdhbcmPSf2i', - useServerTime: true, - reconnect: false, - verbose: true, - test: true, - log: debug - } ); + binance.options( { + APIKEY: process.env.BINANCE_API_KEY, + APISECRET: process.env.BINANCE_API_SECRET, + useServerTime: true, + reconnect: false, + verbose: true, + test: true, + log: debug + } );🧰 Tools
🪛 Gitleaks (8.21.2)
77-77: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
78-78: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
29-34:⚠️ Potential issueRemove hardcoded futures API credentials.
Similar to the previous issue, futures API credentials should not be hardcoded.
Apply this diff:
-const futuresBinance = new Binance().options( { - APIKEY: '227719da8d8499e8d3461587d19f259c0b39c2b462a77c9b748a6119abd74401', - APISECRET: 'b14b935f9cfacc5dec829008733c40da0588051f29a44625c34967b45c11d73c', - hedgeMode: true, - test: true -} ); +const futuresBinance = new Binance().options( { + APIKEY: process.env.BINANCE_FUTURES_API_KEY, + APISECRET: process.env.BINANCE_FUTURES_API_SECRET, + hedgeMode: true, + test: true +} );🧰 Tools
🪛 Gitleaks (8.21.2)
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
31-31: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🧹 Nitpick comments (3)
tests/live-tests.js (3)
9-9: Remove redundant 'use strict' directive.The 'use strict' directive is redundant as JavaScript modules are automatically in strict mode.
Apply this diff:
-'use strict';🧰 Tools
🪛 Biome (1.9.4)
[error] 8-9: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.(lint/suspicious/noRedundantUseStrict)
43-49: Improve logger implementation.The current logger implementation extracts line numbers from the error stack which is fragile and may break in different environments.
Consider using a proper logging library like winston or debug:
const debug = require('debug')('node-binance-api:tests'); let logger = { log: function(msg) { debug(msg); } };
940-1380: Re-enable websocket tests.A large number of websocket tests are commented out. These should be re-enabled to ensure websocket functionality is properly tested.
Would you like me to help uncomment and update these tests to use environment variables for credentials?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
demo.js(1 hunks)tests/live-tests.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- demo.js
🧰 Additional context used
🪛 Gitleaks (8.21.2)
tests/live-tests.js
25-25: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
26-26: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
30-30: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
31-31: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
35-35: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
36-36: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
77-77: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
78-78: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🪛 Biome (1.9.4)
tests/live-tests.js
[error] 8-9: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.
(lint/suspicious/noRedundantUseStrict)
🪛 ESLint
tests/live-tests.js
[error] 59-59: 'stopSockets' is assigned a value but never used.
(no-unused-vars)
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (6)
tests/cjs-test.cjs (6)
6-7: Consider using environment variables for API credentials.While using placeholder values is acceptable for tests, consider loading these from environment variables to follow security best practices, especially if this file might be used in CI/CD pipelines.
-const apiKey = 'XXXXXXXXXXXXXXXX' -const apiSecret = 'YYYYYYYYYYYYYYYYYYYYYY' +const apiKey = process.env.BINANCE_API_KEY || 'XXXXXXXXXXXXXXXX' +const apiSecret = process.env.BINANCE_API_SECRET || 'YYYYYYYYYYYYYYYYYYYYYY'
9-16: Test for instantiation without 'new' looks good.This test correctly verifies that the Binance API can be instantiated without the
newkeyword and that the options are properly set.Note: There are some spacing issues in the parentheses according to ESLint. Consider adding spaces after opening parentheses and before closing ones for consistent styling.
-const binanceWithoutNew = Binance().options({ +const binanceWithoutNew = Binance().options( {And on the assertion lines:
-assert(binanceWithoutNew.getOptions().APIKEY === apiKey) -assert(binanceWithoutNew.getOptions().APISECRET === apiSecret) +assert( binanceWithoutNew.getOptions().APIKEY === apiKey ) +assert( binanceWithoutNew.getOptions().APISECRET === apiSecret )🧰 Tools
🪛 ESLint
[error] 9-9: There must be a space after this paren.
(space-in-parens)
[error] 12-12: There must be a space before this paren.
(space-in-parens)
[error] 14-14: There must be a space after this paren.
(space-in-parens)
[error] 14-14: There must be a space before this paren.
(space-in-parens)
[error] 15-15: There must be a space after this paren.
(space-in-parens)
[error] 15-15: There must be a space before this paren.
(space-in-parens)
17-24: Test for instantiation with 'new' and options method looks good.This test correctly verifies that the Binance API can be instantiated with the
newkeyword followed by theoptionsmethod call.The same spacing issues exist here as mentioned in the previous comment.
🧰 Tools
🪛 ESLint
[error] 17-17: There must be a space after this paren.
(space-in-parens)
[error] 20-20: There must be a space before this paren.
(space-in-parens)
[error] 22-22: There must be a space after this paren.
(space-in-parens)
[error] 22-22: There must be a space before this paren.
(space-in-parens)
[error] 23-23: There must be a space after this paren.
(space-in-parens)
[error] 23-23: There must be a space before this paren.
(space-in-parens)
25-31: Test for direct instantiation with options looks good.This test correctly verifies that the Binance API can be instantiated directly with options passed to the constructor.
The same spacing issues exist here as mentioned in the previous comments.
🧰 Tools
🪛 ESLint
[error] 25-25: There must be a space after this paren.
(space-in-parens)
[error] 28-28: There must be a space before this paren.
(space-in-parens)
[error] 30-30: There must be a space after this paren.
(space-in-parens)
[error] 30-30: There must be a space before this paren.
(space-in-parens)
[error] 31-31: There must be a space after this paren.
(space-in-parens)
[error] 31-31: There must be a space before this paren.
(space-in-parens)
34-38: Consider removing or implementing the commented-out code.There's a commented-out async function that appears to be intended for testing the API's ability to fetch prices. Either implement this test or remove the code to avoid confusion.
If you decide to implement it, consider adding proper error handling and assertions:
-// async function main() { -// const ticker = await binanceWithOptions.prices( 'BNBBTC' ) -// console.log(ticker) -// } +async function testPriceRetrieval() { + try { + const ticker = await binanceWithOptions.prices( 'BNBBTC' ); + assert( ticker && typeof ticker === 'object', 'Ticker should be an object' ); + console.log( 'Price retrieval test passed:', ticker ); + } catch (error) { + console.error( 'Price retrieval test failed:', error.message ); + } +} + +// Uncomment to run the price retrieval test +// testPriceRetrieval();
1-38: Consider restructuring into a proper test framework.The current approach of using direct assertions works, but lacks structure and reporting capabilities. Consider using a test framework like Mocha with Chai for more structured tests with better reporting.
Example restructuring:
const path = require( 'path' ); const chai = require( 'chai' ); const assert = chai.assert; const Binance = require( path.resolve( __dirname, '../node-binance-api.js' ) ); const apiKey = process.env.BINANCE_API_KEY || 'XXXXXXXXXXXXXXXX'; const apiSecret = process.env.BINANCE_API_SECRET || 'YYYYYYYYYYYYYYYYYYYYYY'; describe( 'Binance API Initialization', () => { it( 'should initialize without new keyword', () => { const binanceWithoutNew = Binance().options( { APIKEY: apiKey, APISECRET: apiSecret, } ); assert( binanceWithoutNew.getOptions().APIKEY === apiKey ); assert( binanceWithoutNew.getOptions().APISECRET === apiSecret ); } ); it( 'should initialize with new keyword and options method', () => { const binanceWithOptions = new Binance().options( { APIKEY: apiKey, APISECRET: apiSecret, } ); assert( binanceWithOptions.getOptions().APIKEY === apiKey ); assert( binanceWithOptions.getOptions().APISECRET === apiSecret ); } ); it( 'should initialize with options in constructor', () => { const binance = new Binance( { APIKEY: apiKey, APISECRET: apiSecret, } ); assert( binance.getOptions().APIKEY === apiKey ); assert( binance.getOptions().APISECRET === apiSecret ); } ); // Optional: Test actual API functionality // it( 'should retrieve ticker prices', async () => { // const binance = new Binance( { // APIKEY: apiKey, // APISECRET: apiSecret, // } ); // // const ticker = await binance.prices( 'BNBBTC' ); // assert( ticker && typeof ticker === 'object' ); // } ); } );🧰 Tools
🪛 ESLint
[error] 9-9: There must be a space after this paren.
(space-in-parens)
[error] 12-12: There must be a space before this paren.
(space-in-parens)
[error] 14-14: There must be a space after this paren.
(space-in-parens)
[error] 14-14: There must be a space before this paren.
(space-in-parens)
[error] 15-15: There must be a space after this paren.
(space-in-parens)
[error] 15-15: There must be a space before this paren.
(space-in-parens)
[error] 17-17: There must be a space after this paren.
(space-in-parens)
[error] 20-20: There must be a space before this paren.
(space-in-parens)
[error] 22-22: There must be a space after this paren.
(space-in-parens)
[error] 22-22: There must be a space before this paren.
(space-in-parens)
[error] 23-23: There must be a space after this paren.
(space-in-parens)
[error] 23-23: There must be a space before this paren.
(space-in-parens)
[error] 25-25: There must be a space after this paren.
(space-in-parens)
[error] 28-28: There must be a space before this paren.
(space-in-parens)
[error] 30-30: There must be a space after this paren.
(space-in-parens)
[error] 30-30: There must be a space before this paren.
(space-in-parens)
[error] 31-31: There must be a space after this paren.
(space-in-parens)
[error] 31-31: There must be a space before this paren.
(space-in-parens)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/cjs-test.cjs(1 hunks)
🧰 Additional context used
🪛 ESLint
tests/cjs-test.cjs
[error] 9-9: There must be a space after this paren.
(space-in-parens)
[error] 12-12: There must be a space before this paren.
(space-in-parens)
[error] 14-14: There must be a space after this paren.
(space-in-parens)
[error] 14-14: There must be a space before this paren.
(space-in-parens)
[error] 15-15: There must be a space after this paren.
(space-in-parens)
[error] 15-15: There must be a space before this paren.
(space-in-parens)
[error] 17-17: There must be a space after this paren.
(space-in-parens)
[error] 20-20: There must be a space before this paren.
(space-in-parens)
[error] 22-22: There must be a space after this paren.
(space-in-parens)
[error] 22-22: There must be a space before this paren.
(space-in-parens)
[error] 23-23: There must be a space after this paren.
(space-in-parens)
[error] 23-23: There must be a space before this paren.
(space-in-parens)
[error] 25-25: There must be a space after this paren.
(space-in-parens)
[error] 28-28: There must be a space before this paren.
(space-in-parens)
[error] 30-30: There must be a space after this paren.
(space-in-parens)
[error] 30-30: There must be a space before this paren.
(space-in-parens)
[error] 31-31: There must be a space after this paren.
(space-in-parens)
[error] 31-31: There must be a space before this paren.
(space-in-parens)
🔇 Additional comments (1)
tests/cjs-test.cjs (1)
1-5: Module imports look good.The imports are well-structured, using both CommonJS
requiresyntax and local path resolution to import the Binance module.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
README.md (5)
2-17: Badge Section Cleanup:
You've removed a bulky, outdated block of commented-out badge code and replaced it with a cleaner presentation later in the document. This improves overall readability. It might be worth considering a further cleanup (i.e. fully removing any unused commented code) if it isn’t needed for historical context.
46-48: Fenced Code Block Language:
For consistency and improved syntax highlighting, please specify a language for the npm installation code block (for example, use “bash” instead of a plain “”).🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
46-46: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
25-27: Image Accessibility – Alt Text:
The telegram badge image and similar icons currently lack descriptive alt text. Adding alt text (e.g. “Telegram chat badge”) would improve accessibility for users utilizing screen readers.
52-56: Community URL Formatting:
The “Community Telegram Chat” section uses a bare URL. For consistency and clarity, converting this into a proper markdown link (e.g.[Join our Telegram Chat](https://t.me/nodebinanceapi)) is recommended.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
54-54: Bare URL used
null(MD034, no-bare-urls)
299-343: Delivery API Section Formatting:
The Delivery API endpoints are clearly listed; however, formatting them as a proper markdown list instead of a run-on block could significantly enhance readability and organization.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
300-300: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(20 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md
44-44: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
46-46: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
54-54: Bare URL used
null
(MD034, no-bare-urls)
57-57: Images should have alternate text (alt text)
null
(MD045, no-alt-text)
82-82: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
236-236: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
300-300: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
347-347: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
1901-1901: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
2020-2020: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4
(MD001, heading-increment)
🪛 LanguageTool
README.md
[style] ~1555-~1555: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); }); #### Get dust logjavascript binance.dustLog(...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2067-~2067: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...
(ETC_PERIOD)
🔇 Additional comments (2)
README.md (2)
61-78: Getting Started Examples (ESM & CJS):
The examples for both ESM and CJS usage are clear and concise. They effectively demonstrate how to initialize the API in different module systems.
80-2127: Comprehensive Documentation Update:
This update substantially enhances the README by introducing detailed sections covering the Binance Futures API, Spot Trading, Margin, Lending APIs, and various WebSocket streams. The inclusion of abundant, practical code examples across these topics greatly improves the usability and clarity for developers integrating with the API.Note:
- Static analysis tools have flagged a few styling issues (e.g. heading level increments, missing language specifiers on some fenced code blocks, and minor punctuation adjustments). However, as per previous feedback, such stylistic refinements are not currently a priority.
- Overall, the documentation upgrade meets the PR objectives and is a significant improvement over the upstream version.
🧰 Tools
🪛 LanguageTool
[style] ~1555-~1555: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...mbol+" orders:", orders); });#### Get dust logjavascript binance.dustLog(...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~2067-~2067: In American English, abbreviations like “etc.” require a period.
Context: ...nfo: Pull minimum order size, quantity, etc](https://github.com/jaggedsoft/node-bin...(ETC_PERIOD)
🪛 markdownlint-cli2 (0.17.2)
82-82: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
236-236: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
300-300: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
347-347: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
504-504: Hard tabs
Column: 7(MD010, no-hard-tabs)
1412-1412: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
1443-1443: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
1548-1548: Trailing punctuation in heading
Punctuation: '.'(MD026, no-trailing-punctuation)
1597-1597: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
1615-1615: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
1705-1705: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
1749-1749: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
1901-1901: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
2020-2020: Heading levels should only increment by one level at a time
Expected: h2; Actual: h4(MD001, heading-increment)
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (8)
node-binance-api.d.ts (8)
5-8: Consider stronger typing for_callback.
Currently,_callback = (...args: any) => any;indicates an extremely loose definition that undermines the benefits of TypeScript. If feasible, define a more precise function signature to ensure better type checks.-type _callback = (...args: any) => any; +type _callback = (data: Record<string, unknown>) => void;
29-203: Return types inIWebsocketsinterface are too permissive.
All methods currently returnanyorany[], which makes it difficult for consumers to leverage type safety. If possible, define accurate return types (e.g., WebSocket references, subscription identifiers, etc.).
244-244: Typo in doc: "depch" should be "depth".
Please fix the doc comments to avoid confusion:- * @param {symbol} symbol - get depch cache for this symbol + * @param {symbol} symbol - get depth cache for this symbol - * @param {symbol} symbol - get depch volume for this symbol + * @param {symbol} symbol - get depth volume for this symbolAlso applies to: 252-252
643-643: Minor typo in address tag parameter documentation.
"and addtional address tag" → "and an additional address tag".- * @param {string} addressTag - and addtional address tag + * @param {string} addressTag - and an additional address tag
454-454: Spelling error in buy order flags doc.
"aadditionalbuy" should be “additional buy”.- * @param {object} flags - aadditionalbuy order flags + * @param {object} flags - additional buy order flags
1283-1283: Typo in doc string: “optionnal” → “optional”.
Correct these occurrences for clarity:- * @param {function} callback - the callback function (optionnal) + * @param {function} callback - the callback function (optional)Also applies to: 1294-1294
799-799: Doc comment mismatch for parameter descriptions.
Line 799 designates “@param {function} interval - the callback function” but in code,intervalis an_intervaltype, not a function. Please correct the JSDoc to match the actual types.
236-1586: Consider providing more specific return types forBinanceclass methods.
Most methods are typed asPromise<any>orany, which reduces the effectiveness of TypeScript in user code. Where practical, define interfaces/models for the returned data to help consumers.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (1)
node-binance-api.d.ts(1 hunks)
🔇 Additional comments (2)
node-binance-api.d.ts (2)
1-4: Looks great at first glance!
The file header and author metadata appear consistent and well-structured.
1-1591: Mismatch with AI summary.
The AI summary describes extensive updates toREADME.mdand mentions new sections about the Binance Futures API, but this file solely declares TypeScript definitions with no mention of MD changes. Please confirm if the summary is outdated or if relevant doc changes are missing.Likely an incorrect or invalid review comment.
| depth(...args: any): any; | ||
| depth(...args: any): any; |
There was a problem hiding this comment.
Duplicate depth(...args: any): any; detected.
This duplication may confuse the TypeScript compiler regarding overload resolution or overshadow preceding definitions.
- depth(...args: any): any;
- depth(...args: any): any;
+ depth(...args: any): any;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| depth(...args: any): any; | |
| depth(...args: any): any; | |
| depth(...args: any): any; |
| tradeFee(...args: any): any; | ||
| tradeFee(...args: any): any; |
There was a problem hiding this comment.
Duplicate tradeFee(...args: any): any; signatures.
Reiterating identical method definitions can lead to overshadowing or unexpectedly ambiguous behavior.
- tradeFee(...args: any): any;
- tradeFee(...args: any): any;
+ tradeFee(...args: any): any;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tradeFee(...args: any): any; | |
| tradeFee(...args: any): any; | |
| tradeFee(...args: any): any; |
| orderCount(...args: any): any; | ||
|
|
There was a problem hiding this comment.
Duplicate orderCount(...args: any): any; signatures.
Same overload repeated consecutively can cause unnecessary confusion in type resolution.
- orderCount(...args: any): any;
- orderCount(...args: any): any;
+ orderCount(...args: any): any;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| orderCount(...args: any): any; | |
| orderCount(...args: any): any; |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
node-binance-api.d.ts (2)
1176-1187: Align doc comments with the function signature formgMarketBuy.
The JSDoc omits thepriceparameter, while the function signature includes it. Consider adding thepriceto the doc or removing the parameter if not actually needed for a market order./** * Creates a market buy order * @param {string} symbol - the symbol to buy * @param {numeric} quantity - the quantity required + * @param {numeric} price - the optional price parameter (verify usage) * @param {object} flags - additional buy order flags * @param {function} callback - the callback function * @param {string} isIsolated - the isolate margin option * @return {undefined} */
1188-1199: Align doc comments with the function signature formgMarketSell.
Similar tomgMarketBuy, there is apriceparameter in the function signature but no mention in the doc comments, which may cause confusion./** * Creates a market sell order * @param {string} symbol - the symbol to sell * @param {numeric} quantity - the quantity required + * @param {numeric} price - the optional price parameter (verify usage) * @param {object} flags - additional sell order flags * @param {function} callback - the callback function * @param {string} isIsolated - the isolate margin option * @return {undefined} */
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
node-binance-api.d.ts(1 hunks)
🔇 Additional comments (4)
node-binance-api.d.ts (4)
1-4: Looks good overall!
The introductory header block and module declaration are clear and well-defined.
107-108: Remove duplicate declaration ofdepth(...args: any): any;
This duplication was previously flagged and remains unresolved.- depth(...args: any): any; - depth(...args: any): any; + depth(...args: any): any;
435-436: Remove duplicate declaration oforderCount(...args: any): any;
This duplication was also previously flagged and remains unresolved.- orderCount(...args: any): any; - orderCount(...args: any): any; + orderCount(...args: any): any;
693-694: Remove duplicate declaration oftradeFee(...args: any): any;
This duplication was also previously noted in past reviews.- tradeFee(...args: any): any; - tradeFee(...args: any): any; + tradeFee(...args: any): any;
|
CodeAnt AI Incremental review completed. |
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI Incremental review completed. |
Route futures WebSocket streams to Binance's new category-based URLs per the 2026-03-06 upgrade notice. Legacy URLs retire 2026-04-23.
The new /private/ endpoint requires ?listenKey=<key> format instead of the legacy path-based /<key> format.
feat: migrate USDⓈ-M futures WS to /public /market /private endpoints
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI Incremental review completed. |
fix: re-export missing types
|
CodeAnt AI is running Incremental review Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI Incremental review completed. |
CodeAnt-AI Description
Ship a CommonJS build with updated Binance endpoints, examples, and wider test coverage
What Changed
Impact
✅ Works in CommonJS Node projects✅ Fewer failures from outdated API paths✅ Clearer setup for trading, transfers, and websocket streams💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.