New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mf-tool

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mf-tool

Easily fetch Indian Mutual Fund data like NAV, scheme info, and historical records through a simple Node.js API client

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

Indian MF Tool

npm version License: MIT

A lightweight Node.js and TypeScript utility for fetching Indian Mutual Fund data from mfapi.in, including scheme details, NAVs, and historical data.

Features

  • Fetch complete list of Indian Mutual Fund schemes
  • Search for specific Mutual Fund schemes by name
  • Get latest NAV for any Mutual Fund scheme
  • Retrieve historical NAV data
  • Automatic local caching for improved performance

Installation

npm install mf-tool

Quick Start

import { MfTool } from 'mf-tool';

// Initialize the tool
const mfTool = new MfTool();

// Example: Search for a mutual fund scheme
async function findScheme() {
  const schemes = await mfTool.findSchemaCodeReference('SBI Blue Chip');
  console.log(schemes);
}

// Example: Get NAV details for a specific scheme
async function getNavDetails() {
  const navDetails = await mfTool.getFundNavDetails('123456');
  console.log(navDetails);
}

API Reference

new MfTool()

Creates a new instance of the MF Tool.

updateSchemaCodes(forcePull?: boolean): Promise<void>

Updates the local cache of mutual fund scheme codes.

ParameterTypeDefaultDescription
forcePullbooleanfalseWhen true, ignores local cache and fetches fresh data from API

findSchemaCodeReference(userInput: string): Promise<SchemaCodeReference[]>

Searches for mutual fund schemes that match the input string.

ParameterTypeDescription
userInputstringSearch term for mutual fund scheme names

Returns: Array of matching SchemaCodeReference objects

getAllSchemaCodeReference(): Promise<SchemaCodeReference[]>

Retrieves all available mutual fund schemes.

Returns: Array of all SchemaCodeReference objects

getFundNavDetails(schemaCode: string, needHistoric?: boolean): Promise<NavDetails>

Fetches NAV details for a specific mutual fund scheme.

ParameterTypeDefaultDescription
schemaCodestringThe unique code of the mutual fund scheme
needHistoricbooleanfalseWhen true, includes historical NAV data

Returns: NavDetails object containing the NAV information

Example Usage

Finding a Mutual Fund Scheme

import { MfTool } from 'indian-mf-tool';

async function searchFund() {
  const mfTool = new MfTool();
  
  // Search for HDFC funds
  const hdcpFunds = await mfTool.findSchemaCodeReference('HDFC');
  
  // Print the first 5 results
  console.log(hdcpFunds.slice(0, 5));
}

searchFund();

Getting NAV Details

import { MfTool } from 'indian-mf-tool';

async function getNavInfo() {
  const mfTool = new MfTool();
  
  // First find the scheme code
  const schemes = await mfTool.findSchemaCodeReference('Axis Bluechip Fund');
  
  if (schemes.length > 0) {
    // Get NAV details for the first matching scheme
    const navDetails = await mfTool.getFundNavDetails(schemes[0].schemaCode);
    console.log(`Latest NAV: ${navDetails.data.nav}`);
    console.log(`Date: ${navDetails.data.date}`);
  }
}

getNavInfo();

Working with Historical Data

import { MfTool } from 'indian-mf-tool';

async function getHistoricalNav() {
  const mfTool = new MfTool();
  
  // Get scheme with historical data
  const schemeCode = '119551'; // Example scheme code
  const navDetails = await mfTool.getFundNavDetails(schemeCode, true);
  
  // Access historical data
  const historicalData = navDetails.data.navHistory;

  console.log(historicalData);
}

getHistoricalNav();

Data Types

SchemaCodeReference

interface SchemaCodeReference {
  schemaCode: string;
  schemeName: string;
}

Error Handling

import { MfTool } from 'indian-mf-tool';

async function handleErrors() {
  const mfTool = new MfTool();
  
  try {
    // Using an invalid scheme code
    const navDetails = await mfTool.getFundNavDetails('invalid-code');
    console.log(navDetails);
  } catch (error) {
    console.error('Error fetching NAV details:', error.message);
  }
}

handleErrors();

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests on our GitHub repository.

License

MIT License - see the LICENSE file for details.

Acknowledgements

Keywords

mutual fund

FAQs

Package last updated on 02 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts