![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@evanshortiss/binance.js
Advanced tools
No nonsense wrapper for the Binance API, written in TypeScript
Node.js and Browser friendly wrapper for the Binance API, written using TypeScript.
crypto
module when used with Node.js to greatly improve
performance of HMAC generation vs. other modules.npm install @evanshortiss/binance.js --save
This is a Node.js example using ES5 syntax, but you can use ES6 and TypeScript too.
'use strict'
const Binance = require('@evanshortiss/binance.js')
const client = new Binance.RestClient({
apikey: 'YOUR KEY GOES HERE',
apisecret: 'YOUR KEY GOES HERE'
})
client.getAccountInformation()
.then((balances) => {
// Do something with your account balance information
})
This module throws Error subclasses so you can easily detect the type of an error and handle it accordingly.
The MalformedRequestError
, RequestResultUnknownError
, and
InternalRequestError
have the following properties:
code
and msg
properties per the Binance API Docs.Some examples are shown below.
If a protocol or connection error occurs then this error is thrown, e.g ETIMEDOUT or ECONNREFUSED. Also thrown if the internal HTTP module (Axios) encounters an error.
If you attempt to call an endpoint that requires SIGNED or API-KEY permissions,
but didn't provide the apikey
and/or apisecret
when creating a
Binance.RestClient
this error is thrown.
If the Binance API returns a 4xx status code then this error is thrown.
const Binance = require('@evanshortiss/binance.js')
const client = new Binance.RestClient()
// Deliberately pass a bad symbol to get a 4xx error
client.getOrderBook('BADSYMBOL')
.then((book) => doSomething(book))
.catch((err) => {
if (err instanceof Binance.Errors.MalformedRequestError) {
// We can inspect the error to find a root cause. Error has properties
// like those shown below
// {
// response: { code: -1121, msg: 'Invalid symbol.' },
// statusText: 'Bad Request',
// statusCode: 400,
// name: 'BinanceMalformedRequestError' }
// }
} else {
// Some other type of error
}
})
This error is reserved for when Binance return a HTTP 504 to us. This means they got your request, but didn't generate a response within their timeout period.
Don't treat this as a failure since the request might have been a success.
Read their API Docs for more info.
When Binance return a 5xx status code other than 504 this is thrown.
The RestClient allows you to perform HTTPS requests against the Biance API. It supports the following options:
RestClient behaviours:
response.result
..catch()
function on Promises and try/catch
if
using Async/Await.All of the following functions and the returned data types are detailed in the Binance API docs. For details of the types shown below visit the src/models folder in this repo and read the Binance API docs.
Public methods are detailed below. Optional parameters are denoted using the ?
character. Return types are between the angled braces, e.g <ReturnType>
. If
the return type is followed by braces then it means an array containing entries
of that type will be returned, e.g <ReturnType[]>
Perform a HTTPS request to the Binance API. You should only provide the relative
path, e.g /public/getmarkets
since this library will create the fully formed
url.
Resolves the Promise with an AxiosResponse Object.
// Example call to the Binance API
client.http('/v1/ping', { timeout: 5000 })
.then((result) => {})
.catch((error) => {})
Returns the order book for a given symbol. This is one of the few functions where data is changed from the Binance format to another format for ease of use.
Data will look similar to this:
{
lastUpdateId: number
bids: [
{
price: string
quantity: string
}
]
asks: [
{
price: string
quantity: string
},
{
price: string
quantity: string
}
]
}
FAQs
No nonsense wrapper for the Binance API, written in TypeScript
We found that @evanshortiss/binance.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.