1.0.1 • Published 1 year ago
turkey-location-data v1.0.1
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-dataUsage
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 },
...
];