@dv.net/js-client
v0.1.1
Published
TypeScript SDK for DV Net API
Maintainers
Readme
DV Net TypeScript Client
TypeScript SDK for DV Net API - a comprehensive solution for merchant integration with blockchain payment processing.
Extended Documentation
See https://docs.dv.net/ for full API reference and integration guides.
Installation
npm install @dv.net/js-client
yarn add @dv.net/js-clientUsage
Basic Setup
import { MerchantClient } from "@dv.net/js-client";
const client = new MerchantClient({
xApiKey: 'your-api-key',
host: 'https://api.example.com'
});API Methods
Get Exchange Balances
const balances = await client.getExchangeBalances();Get External Wallet
const wallet = await client.getExternalWallet({
storeExternalId: 'store-123', // required
email: '[email protected]',
ip: '192.168.1.1',
amount: '100',
currency: 'Trx.Tron'
});Get Processing Wallets Balances
const balances = await client.getProcessingWalletsBalances();Get Store Currencies
const currencies = await client.getStoreCurrencies();Get Store Currency Rate
const rate = await client.getStoreCurrencyRate({
currencyId: 'BTC.Bitcoin'
});Initialize Transfer
const withdrawal = await client.initializeTransfer({
addressTo: '0x9260004698F0Ba0c8968aF9b2971154A883E7c75',
currencyId: 'BTC.Bitcoin',
amount: '50',
requestId: '1'
});Get Withdrawal Processing Status
const status = await client.getWithdrawalProcessingStatus({
withdrawalId: '8a6f472c-9b59-419f-a101-07638cedc3fa'
});Delete Withdrawal from Processing
await client.deleteWithdrawalFromProcessing({
id: '8a6f472c-9b59-419f-a101-07638cedc3fa'
});Get Hot Wallet Balances
const accounts = await client.getHotWalletBalances();Using with Custom HTTP Client
import { MerchantClient, HttpClient } from '@dv.net/js-client';
class CustomHttpClient implements HttpClient {
async request<T = any>(config: {
method: string;
url: string;
data?: any;
headers?: Record<string, string>;
}): Promise<{
data: T;
status: number;
statusText: string;
}> {
// Your custom HTTP implementation
// ...
}
}
const client = new MerchantClient({
httpClient: new CustomHttpClient(),
host: 'https://api.example.com',
xApiKey: 'your-api-key'
});Error Handling
The client now surfaces backend errors verbatim. When the API responds with an error, you receive the same shape:
{
"errors": [
{ "message": "email must be a valid email address", "field": "email" }
],
"code": 422
}For non-backend issues (network, configuration), the client throws a normalized error with the same structure and code set to 500:
{
"errors": [ { "message": "Network error" } ],
"code": 500
}Example usage:
try {
const wallet = await client.getExternalWallet({
storeExternalId: 'store-123',
email: '[email protected]'
});
} catch (error: any) {
// error has shape: { errors: { message, field? }[], code: number }
console.error(error);
}License
MIT
