1.0.3 • Published 1 month ago

ind-state-district v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

ind-states-districts

npmvtypesdownloads

This npm package provides a list of districts across all states and union territories of India, along with their respective state codes(short forms) and district codes(short forms).

Installation

  npm install ind-state-district

Usage

1. State.getAllStates()

This function returns an array of objects, where each object represents a state/union territory in India and contains the following properties:

  • stateName: The name of the state/union territory.
  • tin: The taxpayer identification number of the state/union territory.
  • stateCode: The short form of the state/union territory name
  • isUT: If the current state is an Union Territory or not.
[
  { stateName: 'Andhra Pradesh', tin: '37', stateCode: 'AP',isUT:false },
  { stateName: 'Arunachal Pradesh', tin: '12', stateCode: 'AR',isUT:true },....
}

2. State.getStateNameFromCode(stateCode)

This function returns a string, the full name of state/union territory.

const {State} = require("state-district-ind")

console.log(State.getStateNameFromCode("OD"));

//Output - Odisha

3. Districts.getAllDistricts()

This function returns an array of objects, where each object represents a district of the all states/union territories in India and contains the following properties:

  • districtName: The name of the district.
  • stateCode: The short form of the state/union territory name
  • districtCode: The short form of the district name
[
  { districtName: 'Nicobar', stateCode: 'AN', districtCode: 'NI' },
  {
    districtName: 'North and Middle Andaman',
    stateCode: 'AN',
    districtCode: 'NMA'
  },
  {
    districtName: 'South Andaman',
    stateCode: 'AN',
    districtCode: 'SA'
  },....
]

4. Districts.getAllDistrictsByStateCode(stateCode)|Districts.getDistrictNameFromStateName(stateName)

This function returns an array of objects, where each object represents a district of the particular states/union territory of India and contains the following properties:

  • districtName: The name of the district.
  • stateCode: The short form of the state/union territory name
  • districtCode: The short form of the district name
    //Districts.getDistrictNameFromStateName("Andhra Pradesh")
[
    {
      "districtName": "Alluri Sitarama Raju",
      "stateCode": "AP",
      "districtCode": "ASR"
    },
    {
      "districtName": "Anakapalle",
      "stateCode": "AP",
      "districtCode": "AKP"
    },
    {
      "districtName": "Ananthapuramu",
      "stateCode": "AP",
      "districtCode": "ATP"
    },.....
]

5. Districts.getDistrictNameFromCode(districtCode)

This function returns a string, the full name of district.

const {Districts} = require("state-district-ind")

console.log(Districts.getDistrictNameFromCode("GTR"));
// Output - Gunter

Version

  • 1.0.2
    • Minor fixes
  • 1.0.1
    • Addition of state and district functionality

Acknowledgements

  • Vikaspedia - For data collection
  • TSUP - Simplest libraries to bundle Typescript
1.0.3

1 month ago

1.2.0

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago