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 🙏

© 2026 – Pkg Stats / Ryan Hefner

coins-js-api

v1.0.0

Published

TypeScript SDK for Coins API - Spot Trading, Wallet, Convert, Fiat, P2P Transfer and Invoice Payment functionality

Readme

Coins JS API SDK

TypeScript SDK for Coins API - Spot Trading, Wallet, Convert, Fiat, P2P Transfer and Invoice Payment functionality.

Installation

npm install coins-js-api

Features

  • TypeScript Support: Full TypeScript support with type definitions
  • Comprehensive API Coverage: Supports all Coins API endpoints
  • Modern Async/Await: Uses modern JavaScript async/await syntax
  • Secure Authentication: Built-in HMAC SHA256 signature generation
  • Easy to Use: Simple and intuitive API design

Quick Start

import { CoinsApiClient, CoinsApiConfig } from 'coins-js-api';

// Create configuration
const config = CoinsApiConfig.builder()
  .setApiKey('your-api-key')
  .setSecretKey('your-secret-key')
  .build();

// Or use direct instantiation
const config = new CoinsApiConfig({
  apiKey: 'your-api-key',
  secretKey: 'your-secret-key',
  baseUrl: 'https://api.coins.ph', // optional
  recvWindow: 5000, // optional
});

// Create client
const client = new CoinsApiClient(config);

// Use the API
async function example() {
  try {
    // Get account information
    const account = await client.wallet().getAccount();
    console.log('Account:', account);

    // Create a new order
    const order = await client.spotTrading().newOrder({
      symbol: 'BTCUSDT',
      side: 'BUY',
      type: 'LIMIT',
      timeInForce: 'GTC',
      quantity: '0.001',
      price: '50000',
    });
    console.log('Order:', order);

    // Get convert quote
    const quote = await client.convert().getQuote({
      fromCoin: 'BTC',
      toCoin: 'USDT',
      fromAmount: '0.001',
    });
    console.log('Quote:', quote);
  } catch (error) {
    console.error('Error:', error);
  }
}

example();

API Modules

Spot Trading

// Get trading fees
const fees = await client.spotTrading().getTradeFee({ symbol: 'BTCUSDT' });

// Get trade history
const trades = await client.spotTrading().getMyTrades({
  symbol: 'BTCUSDT',
  limit: 10,
});

// Get open orders
const openOrders = await client.spotTrading().getOpenOrders({ symbol: 'BTCUSDT' });

// Cancel order
const cancelled = await client.spotTrading().cancelOrder({ orderId: 12345 });

// Cancel all orders
const cancelledAll = await client.spotTrading().cancelAllOrders({ symbol: 'BTCUSDT' });

Wallet

// Get account info
const account = await client.wallet().getAccount();

// Get deposit address
const address = await client.wallet().getDepositAddress({
  coin: 'BTC',
  network: 'BTC',
});

// Get deposit history
const deposits = await client.wallet().getDepositHistory('BTC');

// Apply for withdrawal
const withdrawal = await client.wallet().applyWithdraw({
  coin: 'BTC',
  address: 'your-btc-address',
  amount: '0.001',
  network: 'BTC',
});

// Get transaction history
const history = await client.wallet().getTransactionHistory({
  tokenId: 'BTC',
  pageNum: 1,
  pageSize: 10,
});

Convert

// Get conversion quote
const quote = await client.convert().getQuote({
  fromCoin: 'BTC',
  toCoin: 'USDT',
  fromAmount: '0.001',
});

// Accept quote
const result = await client.convert().acceptQuote({
  quoteId: quote.quoteId,
});

// Get order history
const orders = await client.convert().getOrderHistory();

Fiat

// Get channel configuration
const config = await client.fiat().getChannelConfig({
  fiatCurrency: 'PHP',
  transactionType: 'BUY',
});

// Cash out
const cashout = await client.fiat().cashOut({
  fiatCurrency: 'PHP',
  cryptoCurrency: 'BTC',
  amount: '1000',
  paymentMethod: 'BANK_TRANSFER',
});

// Generate QR code
const qrCode = await client.fiat().generateQrCode({
  coin: 'BTC',
  amount: '0.001',
  description: 'Payment for order #123',
});

P2P Transfer

// Transfer to another user
const transfer = await client.p2pTransfer().transfer({
  coin: 'BTC',
  amount: '0.001',
  toEmail: '[email protected]',
});

// Get transfer history
const transfers = await client.p2pTransfer().getTransfers();

Invoice Payment

// Create payment request
const payment = await client.payment().createPaymentRequest({
  currency: 'PHP',
  amount: '1000',
  description: 'Payment for service',
  redirectUrl: 'https://example.com/callback',
});

// Get payment request
const paymentDetails = await client.payment().getPaymentRequest({
  id: payment.paymentRequest.id,
});

// List payment requests
const payments = await client.payment().listPaymentRequests(1, 10);

Error Handling

import { CoinsApiException } from 'coins-js-api';

try {
  const result = await client.spotTrading().newOrder({
    symbol: 'BTCUSDT',
    side: 'BUY',
    type: 'LIMIT',
    quantity: '0.001',
    price: '50000',
  });
} catch (error) {
  if (error instanceof CoinsApiException) {
    console.error('API Error Code:', error.getCode());
    console.error('API Error Message:', error.message);
  } else {
    console.error('Unknown Error:', error);
  }
}

Configuration Options

const config = new CoinsApiConfig({
  apiKey: 'your-api-key',          // Required: Your API key
  secretKey: 'your-secret-key',     // Required: Your secret key
  baseUrl: 'https://api.coins.ph',  // Optional: API base URL (default: https://api.coins.ph)
  recvWindow: 5000,                 // Optional: Request validity window in ms (default: 5000)
});

TypeScript Support

This library is written in TypeScript and provides full type definitions for all API requests and responses.

import {
  NewOrderRequest,
  NewOrderResponse,
  OrderResponse,
  TradeVo,
  // ... and many more types
} from 'coins-js-api';

Development

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Run linter
npm run lint

# Format code
npm run format

License

MIT

Support

For issues and questions, please visit the GitHub repository.