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

zargaran-apiclient

v1.1.0

Published

TypeScript client for the Moamelat Trading Platform — supporting authentication, real-time trading, TP/SL management, accounting, and KYC.

Readme

zargaran-apiclient

TypeScript client for the Moamelat Trading Platform — a gold trading API supporting authentication, real-time trading, TP/SL management, accounting, and KYC.

Installation

npm install zargaran-apiclient
# or
bun install zargaran-apiclient
# or
yarn add zargaran-apiclient
# or
pnpm add zargaran-apiclient

Quick Start

import { MoamelatClient, ApiError } from "zargaran-apiclient";

const client = new MoamelatClient({
  baseUrl: "https://api.moamelat.com",
});

// Login
const { data: loginData } = await client.loginByIdentifier("09123456789", "password");
client.setToken(loginData.token);

// Get profile
const { data: profile } = await client.getProfile();
console.log(profile.fullname, profile.margin);

// Open a trade
const { data: trade } = await client.openTrade("buy", 5);
console.log("Trade ID:", trade.result.trade_id);

API Reference

Authentication

| Method | Description | |---|---| | getTrader(identifier) | Check if trader exists | | loginByIdentifier(id, password) | Login with phone/chat_id | | loginByUsername(username, password) | Login with username | | sendCode(traderId, type) | Send verification code | | verifyCode(traderId, code, type) | Verify SMS code | | setPassword(traderId, password, code) | Set password after verification | | requestChangePassword(newPassword) | Request password change | | changePassword(newPassword, code) | Confirm password change |

Profile

| Method | Description | |---|---| | getProfile() | Get trader profile | | getOpenTrades() | Get all open trades | | getCapacity(rate?) | Get trading capacity | | getReferral() | Get referral info | | editNickname(nickname) | Change nickname |

Trading

| Method | Description | |---|---| | openTrade(type, amount) | Open market trade (buy/sell) | | closeTrade(tradeId) | Close a specific trade | | closeAllTrades(type) | Close multiple trades | | changeLeverage(leverage) | Change leverage (1-5) |

TP/SL Management

| Method | Description | |---|---| | updateTPSL(tradeId, tp?, sl?) | Set/update take profit & stop loss | | getPendingOrders(status?) | Get pending orders | | cancelPendingOrder(pendingId) | Cancel a pending order |

History & Accounting

| Method | Description | |---|---| | getHistory(filters?) | Get trade history with pagination | | getMargin() | Get margin/balance info | | getTransactions(page, limit) | Get transaction history | | getDepositConstraints() | Get deposit limits | | getWithdrawConstraints(cardNumber?) | Get withdraw limits | | depositIRT(amount, gateway) | Deposit IRT (Toman) | | depositUSDT(amount, txId) | Deposit USDT | | withdraw(amount, type, cardNumber?) | Withdraw funds |

KYC

| Method | Description | |---|---| | getKycStatus() | Get KYC verification status | | submitKycStep1(data) | Submit personal info | | submitKycStep2(data) | Submit ID card photos | | submitKycStep3(data) | Submit selfie photo |

Card Management

| Method | Description | |---|---| | listCards() | List saved bank cards | | addCard(data) | Add new bank card | | deleteCard(cardId) | Delete a bank card |

Configuration

const client = new MoamelatClient({
  baseUrl: "https://api.moamelat.com",  // API base URL
  token: "123:abc...",                   // Optional initial token
  maxRetries: 3,                         // Max retry attempts
  retryDelayMs: 1000,                    // Base delay between retries
});

Token Management

client.setToken("123:abc...");   // Set authentication token
client.getToken();               // Get current token
client.clearToken();             // Clear token (logout)

Error Handling

All API errors throw an ApiError with detailed information:

import { MoamelatClient, ApiError } from "zargaran-apiclient";

try {
  await client.openTrade("buy", 5);
} catch (error) {
  if (error instanceof ApiError) {
    console.log(error.code);     // e.g., "INSUFFICIENT_CREDIT"
    console.log(error.status);   // HTTP status code
    console.log(error.response); // Full API response
  }
}

Retryable Errors

The client automatically retries on:

  • RATE_LIMITED — Too many requests
  • BOT_DISABLED — Bot temporarily unavailable

Testing

bun test

The test suite covers all API methods with mocked responses — no network connection required.

  • 55 tests across 12 categories
  • Mocked fetch for fully offline execution
  • Covers success paths, error handling, retry logic, and auth header behavior

License

MIT