Skip to content

ismetcanbyk/turkey-location-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turkey Location Data

With this package, you can access the most up-to-date list of provinces, districts and neighborhoods in Turkey.

Installation

To install the package, use npm:

npm install turkey-location-data

Usage

Import the functions you need from the package:

import {
  getAllProvinces,
  getDistrictsByProvinceApiId,
  getNeighborhoodsByDistrictApiId,
  getDistrictsByProvinceName,
} from "turkey-location-data";

Methods

getAllProvinces

Fetches all provinces with their apiId:

const provinces = getAllProvinces();
console.log(provinces);
Response
[
  { name: 'Adana', apiId: 23 },
  { name: 'Adıyaman', apiId: 24 },
  { name: 'Afyonkarahisar', apiId: 25 },
  ...
];

getDistrictsByProvinceApiId

Fetches districts based on the province's apiId:

const districts = getDistrictsByProvinceApiId(23);
console.log(districts);
Response
[
  { name: 'Aladağ', apiId: 104 },
  { name: 'Ceyhan', apiId: 105 },
  { name: 'Çukurova', apiId: 6113 },
  ...
];

getNeighborhoodsByDistrictApiId

Fetches neighborhoods based on the district's apiId:

const neighborhoods = getNeighborhoodsByDistrictApiId(104);
console.log(neighborhoods);
Response
[
  'Akören',    'Akpınar',       'Başpınar',
  'Boztahta',  'Büyüksofulu',   'Ceritler',
  ...
];

getDistrictsByProvinceName

Fetches districts based on the province's name:

const districts = getDistrictsByProvinceName("Adana");
console.log(districts);
Response
[
  { name: 'Aladağ', apiId: 104 },
  { name: 'Ceyhan', apiId: 105 },
  { name: 'Çukurova', apiId: 6113 },
    ...
];

Contact

Feel free to contact me with any questions or suggestions.