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

iranbanks

v1.0.1

Published

Detect Iranian banks from card numbers - Fast, lightweight, and reliable BIN lookup for Iranian banking system

Readme

Iran Bank Detector 🏦

npm version License: MIT

Detect Iranian banks from card numbers - تشخیص بانک‌های ایران از روی شماره کارت

A lightweight, fast, and reliable npm package to identify Iranian banks from card numbers using BIN (Bank Identification Number) codes.

Installation

npm install iranbanks

Usage

JavaScript

const {
  detectBank,
  isValidIranianCard,
  getSupportedBanks,
} = require("iranbanks");

// Detect bank from card number
const result = detectBank("6037991234567890");
console.log(result);
// {
//   success: true,
//   bank: {
//     name: 'بانک ملی',
//     bin: '603799',
//     cardNumber: '6037991234567890'
//   }
// }

// Validate Iranian card number
const isValid = isValidIranianCard("6037991234567890");
console.log(isValid); // true or false

// Get list of supported banks
const banks = getSupportedBanks();
console.log(banks);

TypeScript

import { detectBank, isValidIranianCard, DetectionResult } from "iranbanks";

const result: DetectionResult = detectBank("6037991234567890");

if (result.success) {
  console.log(`Bank: ${result.bank?.name}`);
}

API Reference

detectBank(cardNumber: string)

Detects the bank from a card number using BIN codes.

Parameters:

  • cardNumber: Card number (16 digits)

Returns:

{
  success: boolean;
  bank?: {
    name: string;      // Bank name (in Persian)
    bin: string;       // First 6 digits of card
    cardNumber: string; // Cleaned card number
  };
  message?: string;    // Error message if bank not detected
  bin?: string;        // BIN code if bank not detected
}

isValidIranianCard(cardNumber: string)

Validates Iranian card number using Luhn algorithm.

Parameters:

  • cardNumber: Card number to validate

Returns: boolean

getSupportedBanks()

Returns list of all supported Iranian banks.

Returns:

Array<{
  bin: string; // Bank BIN code
  name: string; // Bank name (in Persian)
}>;

Supported Banks

  • Bank Melli Iran (بانک ملی ایران)
  • Bank Saderat Iran (بانک صادرات ایران)
  • Bank Keshavarzi (بانک کشاورزی)
  • Bank Sepah (بانک سپه)
  • Bank Mellat (بانک ملت)
  • Bank Maskan (بانک مسکن)
  • Bank Tosee Saderat (بانک توسعه صادرات)
  • Bank Sanat va Madan (بانک صنعت و معدن)
  • Bank Tejarat (بانک تجارت)
  • Bank Refah Kargaran (بانک رفاه کارگران)
  • Bank Pasargad (بانک پاسارگاد)
  • Bank Eghtesad Novin (بانک اقتصاد نوین)
  • Bank Parsian (بانک پارسیان)
  • Bank Karafarin (بانک کارآفرین)
  • Bank Saman (بانک سامان)
  • Bank Sina (بانک سینا)
  • Bank Sarmayeh (بانک سرمایه)
  • Bank Shahr (بانک شهر)
  • Bank Day (بانک دی)
  • Bank Ansar (بانک انصار)
  • Bank Ghavamin (بانک قوامین)
  • Post Bank Iran (پست بانک ایران)
  • And more...

Examples

React Component

import React, { useState } from "react";
import { detectBank } from "iranbanks";

function BankDetector() {
  const [cardNumber, setCardNumber] = useState("");
  const [result, setResult] = useState(null);

  const handleDetect = () => {
    try {
      const detection = detectBank(cardNumber);
      setResult(detection);
    } catch (error) {
      setResult({ success: false, message: error.message });
    }
  };

  return (
    <div>
      <input
        type="text"
        value={cardNumber}
        onChange={(e) => setCardNumber(e.target.value)}
        placeholder="Enter card number"
      />
      <button onClick={handleDetect}>Detect Bank</button>

      {result && (
        <div>
          {result.success ? (
            <p>Bank: {result.bank.name}</p>
          ) : (
            <p>Error: {result.message}</p>
          )}
        </div>
      )}
    </div>
  );
}

Express.js API

const express = require("express");
const { detectBank } = require("iranbanks");

const app = express();
app.use(express.json());

app.post("/detect-bank", (req, res) => {
  try {
    const { cardNumber } = req.body;
    const result = detectBank(cardNumber);
    res.json(result);
  } catch (error) {
    res.status(400).json({ error: error.message });
  }
});

app.listen(3000);

Vue.js Component

<template>
  <div>
    <input
      v-model="cardNumber"
      placeholder="Enter card number"
      @input="detectBankInfo"
    />
    <div v-if="result">
      <p v-if="result.success">Bank: {{ result.bank.name }}</p>
      <p v-else>{{ result.message }}</p>
    </div>
  </div>
</template>

<script>
import { detectBank } from "iranbanks";

export default {
  data() {
    return {
      cardNumber: "",
      result: null,
    };
  },
  methods: {
    detectBankInfo() {
      if (this.cardNumber.length >= 6) {
        try {
          this.result = detectBank(this.cardNumber);
        } catch (error) {
          this.result = { success: false, message: error.message };
        }
      }
    },
  },
};
</script>

Features

  • Lightweight: No dependencies, small bundle size
  • Fast: Instant bank detection using BIN lookup
  • TypeScript Support: Full type definitions included
  • Error Handling: Comprehensive error management
  • Card Validation: Luhn algorithm validation
  • Format Flexible: Handles spaces, dashes in card numbers
  • Persian Names: Bank names in Persian (Farsi)
  • Well Tested: Comprehensive test coverage

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to all Iranian developers who contribute to this project 🇮🇷
  • Bank information sourced from official Central Bank of Iran data
  • Inspired by the need for better financial tools in Iranian web development

Made with ❤️ for the Iranian developer community