npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@exapi/api-client-typescript-fetch

v2.2.2

Published

ExKoin API Client for @exapi/api-client-typescript-fetch

Readme

API Client for typescript-fetch

This is an auto-generated SDK for the API.

Example Usage

// DISCLAIMER: This is an auto-generated example and library.
// This lib has NOT been tested by our support team.
// Please use at your own risk, and make tests before using it.
//
// install using "npm i -s @exapi/api-client-typescript-fetch"
import { Exchange } from '@exapi/api-client-typescript-fetch';

const exchange = new Exchange({
  domainName: 'exkoin.com',
  apiKey: 'YOUR_API_KEY',
  secret: 'YOUR_API_SECRET',
  useHmac: true // or false for Basic Auth
});

// Example 1: Get account balances
async function getAccountBalances() {
  try {
    const balances = await exchange.getBalances();
    console.log('Account balances:', balances);
  } catch (error) {
    console.error('Error fetching balances:', error);
  }
}

// Example 2: Get available currencies
async function getCurrencies() {
  try {
    const currencies = await exchange.getCurrencies();
    console.log('Available currencies:', currencies);
  } catch (error) {
    console.error('Error fetching currencies:', error);
  }
}

// Example 3: Get market data
async function getMarketData() {
  try {
    const markets = await exchange.getMarkets();
    console.log('Available markets:', markets);
    
    const orderbook = await exchange.getOrderbook({ symbol: 'BTC/USDT', limit: 10 });
    console.log('BTC/USDT orderbook:', orderbook);
    
    const trades = await exchange.getTrades({ symbol: 'BTC/USDT', limit: 20 });
    console.log('Recent BTC/USDT trades:', trades);
  } catch (error) {
    console.error('Error fetching market data:', error);
  }
}

// Example 4: Place a buy order
async function placeBuyOrder() {
  try {
    const order = await exchange.createOrder({
      symbol: 'BTC/USDT',
      type: 'limit',
      side: 'buy',
      quantity: '0.001',
      price: '45000'
    });
    console.log('Order placed:', order);
  } catch (error) {
    console.error('Error placing order:', error);
  }
}

// Example 5: Get order history
async function getOrderHistory() {
  try {
    const orders = await exchange.getOrders({ 
      symbol: 'BTC/USDT',
      limit: 50 
    });
    console.log('Order history:', orders);
  } catch (error) {
    console.error('Error fetching orders:', error);
  }
}

// Example 6: Get trade history
async function getTradeHistory() {
  try {
    const trades = await exchange.getUserTrades({ 
      symbol: 'BTC/USDT',
      limit: 100 
    });
    console.log('Trade history:', trades);
  } catch (error) {
    console.error('Error fetching trade history:', error);
  }
}

// Example 7: Cancel an order
async function cancelOrder(orderId: string) {
  try {
    const result = await exchange.cancelOrder({
      order_id: orderId,
      symbol: 'BTC/USDT'
    });
    console.log('Order cancelled:', result);
  } catch (error) {
    console.error('Error cancelling order:', error);
  }
}

// Example 8: Get deposit address
async function getDepositAddress() {
  try {
    const address = await exchange.getDepositAddress({
      currency: 'BTC',
      network: 'BTC'
    });
    console.log('BTC deposit address:', address);
  } catch (error) {
    console.error('Error getting deposit address:', error);
  }
}

// Example 9: Prepare and finish withdrawal
async function withdrawFunds() {
  try {
    // Step 1: Prepare withdrawal
    const preparation = await exchange.prepareWithdrawal({
      currency: 'BTC',
      amount: '0.001',
      address: 'bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh',
      network: 'BTC'
    });
    console.log('Withdrawal prepared:', preparation);
    
    // Step 2: Finish withdrawal (you would get the payload from the preparation response)
    const completion = await exchange.finishWithdrawal({
      payload: preparation.payload // This would come from the prepare response
    });
    console.log('Withdrawal completed:', completion);
  } catch (error) {
    console.error('Error processing withdrawal:', error);
  }
}

// Example 10: Get deposit/withdrawal history
async function getTransactionHistory() {
  try {
    const deposits = await exchange.getDeposits({
      currency: 'BTC',
      limit: 50
    });
    console.log('Deposit history:', deposits);
    
    const withdrawals = await exchange.getWithdrawals({
      currency: 'BTC',
      limit: 50
    });
    console.log('Withdrawal history:', withdrawals);
  } catch (error) {
    console.error('Error fetching transaction history:', error);
  }
}

// Example 11: Join a liquidity pool
async function joinLiquidityPool() {
  try {
    const result = await exchange.joinPool({
      pool_id: 'BTC/USDT',
      max_base_amount: '0.01',
      max_quote_amount: '500',
      min_price: '40000',
      max_price: '50000'
    });
    console.log('Joined pool:', result);
  } catch (error) {
    console.error('Error joining pool:', error);
  }
}

// Example 12: Get pool positions
async function getPoolPositions() {
  try {
    const positions = await exchange.getPoolPositions();
    console.log('Pool positions:', positions);
  } catch (error) {
    console.error('Error fetching pool positions:', error);
  }
}

// Example usage - run all examples
async function runExamples() {
  await getAccountBalances();
  await getCurrencies();
  await getMarketData();
  await getOrderHistory();
  await getTradeHistory();
  await getDepositAddress();
  await getTransactionHistory();
  await getPoolPositions();
  
  // Uncomment to test trading and withdrawals (be careful with real funds!)
  // await placeBuyOrder();
  // await withdrawFunds();
  // await joinLiquidityPool();
}

runExamples();