Wyre NodeJS API Client
Node.js client library for the Wyre API.
npm install @wyre/api
Regarding Decimal Numbers
Some currencies, like ETH, have many decimal places. This can cause problems with the many JSON implementations that fail to offer support arbitrary precision numbers. Moreover, IEEE 754 floating point is not in general a good representation for money - it does not necessarily preserve precision.
In the examples below, we have supplied the
format parameter as
"json_numberstring". This encodes all
numbers returned from our API as strings. If you need to perform arithmetic on these numbers, you must
use an arbitrary-precision library:
Alternatively, instead supply the (default)
"format":"json" and the API will encode numbers directly in JSON.
As the Wyre API may be used in a custodial context; this means that a single account may have permission to act
on behalf of subaccount. To assist maintaining firm barriers between account permissions (creating an extra barrier
of protection), when acting on behalf of a specific account we require explicitly declaring this via the
This parameter must be passed as a query parameter and not via the body! Alternatively, you may use the masquerading API for a more natural declaration.
const WyreClient = WyreClientlet wyre =format: "json_numberstring"apiKey: "AK-AAAAAAA-AAAAAAA-AAAAAAA-AAAAAAA"secretKey: "SK-AAAAAAA-AAAAAAA-AAAAAAA-AAAAAAA"// baseUrl: "" // todo uncomment this line to use the testwyre environment;wyre;
You're all set to begin coding!
Example API Calls
Attempt a $10 USD->BTC conversion:
Upload a document:
var fs = ;let my_id = fs;wyre;
let wyre = /*parameter object*/
|apiKey||your environment-specific Wyre API key|
|secretKey||your environment-specific Wyre API secret|
|baseUrl||specifies the Wyre environment you'd like to use. please use either:
|format||the data format you're requesting.
|options||options that are passed to the underlying Request for every request|
Note that the ability to override options used by the Request client is available both generally as well as per-request.
Timeouts may be adjusted via the
options.timeout (expressed in milliseconds). This may be controlled via the constructor,
or per-request (as with all options).
Each of these methods performs a single Wyre API request and returns a promise for the resulting API response.
This is an alternative to supplying the
masqueradeAs parameter as a query parameter.
// init the wyre client as usuallet wyre = /* your master api access setup here */ ;// create another sub-client authenticated as a particular userlet user1_wyre = wyre;// now use that client as normal!user1_wyre;
Example error response: