---
title: "HTX Account JavaScript SDK Example | Siebly"
description: "HTX Derivatives Private account JavaScript example for the Siebly HTX SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs."
canonical: "https://siebly.io/examples/HTX/Derivatives/Private/account"
robots: "index,follow"
---

# HTX Account JavaScript SDK Example

HTX Derivatives Private account JavaScript example for the Siebly HTX SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

**Path:** [Home](/) / [Examples](/examples) / [HTX](/examples/HTX) / [Derivatives](/examples/HTX/Derivatives) / [Private](/examples/HTX/Derivatives/Private) / [account.ts](/examples/HTX/Derivatives/Private/account)

[View source on GitHub](https://github.com/sieblyio/crypto-api-examples/blob/master/examples/HTX/Derivatives/Private/account.ts)

[Open the HTX JavaScript SDK guide](/sdk/htx/javascript)

## account.ts

```typescript
/* eslint-disable @typescript-eslint/no-unused-vars */
import { FuturesClient } from '@siebly/htx-api';

// This example shows how to call HTX Derivatives API endpoints for ACCOUNT INFORMATION.

const client = new FuturesClient({
  apiKey: process.env.API_FUTURES_KEY || 'insertApiKeyHere',
  apiSecret: process.env.API_FUTURES_SECRET || 'insertApiSecretHere',
});

const contractCode = 'BTC-USDT';

async function getLinearSwapAccountType() {
  try {
    const accountType = await client.getLinearSwapAccountType();
    console.log('Account Type: ', JSON.stringify(accountType, null, 2));
  } catch (e) {
    console.error('Get account type error: ', e);
  }
}

async function getCrossAccountInfo() {
  try {
    const accountInfo = await client.getLinearSwapCrossAccountInfo();
    console.log('Cross Account Info: ', JSON.stringify(accountInfo, null, 2));
  } catch (e) {
    console.error('Get cross account info error: ', e);
  }
}

async function getCrossPositions() {
  try {
    const positions = await client.getLinearSwapCrossPositions({
      contract_code: contractCode,
    });
    console.log('Cross Positions: ', JSON.stringify(positions, null, 2));
  } catch (e) {
    console.error('Get cross positions error: ', e);
  }
}

async function getCrossFills() {
  try {
    const fills = await client.getLinearSwapCrossFills({
      contract: contractCode,
      trade_type: 0,
    });
    console.log('Cross Fills: ', JSON.stringify(fills, null, 2));
  } catch (e) {
    console.error('Get cross fills error: ', e);
  }
}

async function getMultiAssetAccountBalance() {
  try {
    const balance = await client.getMultiAssetAccountBalance();
    console.log(
      'Multi-Asset Account Balance: ',
      JSON.stringify(balance, null, 2),
    );
  } catch (e) {
    console.error('Get multi-asset account balance error: ', e);
  }
}

async function getFinancialRecords() {
  try {
    const records = await client.getLinearSwapFinancialRecords({
      mar_acct: 'USDT',
      contract: contractCode,
      type: '3,4,5,6',
    });
    console.log('Financial Records: ', JSON.stringify(records, null, 2));
  } catch (e) {
    console.error('Get financial records error: ', e);
  }
}

async function transferLinearSwapInner() {
  try {
    const transfer = await client.transferLinearSwapInner({
      asset: 'USDT',
      from_margin_account: 'USDT',
      to_margin_account: contractCode,
      amount: '10',
    });
    console.log('Inner Transfer Result: ', JSON.stringify(transfer, null, 2));
  } catch (e) {
    console.error('Transfer linear swap inner error: ', e);
  }
}

async function getMultiAssetPositions() {
  try {
    const positions = await client.getMultiAssetPositions({
      contract_code: contractCode,
    });
    console.log('Multi-Asset Positions: ', JSON.stringify(positions, null, 2));
  } catch (e) {
    console.error('Get multi-asset positions error: ', e);
  }
}

// Uncomment the function you want to test:

// getLinearSwapAccountType();
// getCrossAccountInfo();
// getCrossPositions();
// getCrossFills();
// getMultiAssetAccountBalance();
// getFinancialRecords();
// transferLinearSwapInner();
// getMultiAssetPositions();
```
