With this package, you can access the most up-to-date list of provinces, districts and neighborhoods in Turkey.
To install the package, use npm:
npm install turkey-location-data
Import the functions you need from the package:
import {
getAllProvinces,
getDistrictsByProvinceApiId,
getNeighborhoodsByDistrictApiId,
getDistrictsByProvinceName,
} from "turkey-location-data";
Fetches all provinces with their apiId
:
const provinces = getAllProvinces();
console.log(provinces);
[
{ name: 'Adana', apiId: 23 },
{ name: 'Adıyaman', apiId: 24 },
{ name: 'Afyonkarahisar', apiId: 25 },
...
];
Fetches districts based on the province's apiId
:
const districts = getDistrictsByProvinceApiId(23);
console.log(districts);
[
{ name: 'Aladağ', apiId: 104 },
{ name: 'Ceyhan', apiId: 105 },
{ name: 'Çukurova', apiId: 6113 },
...
];
Fetches neighborhoods based on the district's apiId
:
const neighborhoods = getNeighborhoodsByDistrictApiId(104);
console.log(neighborhoods);
[
'Akören', 'Akpınar', 'Başpınar',
'Boztahta', 'Büyüksofulu', 'Ceritler',
...
];
Fetches districts based on the province's name
:
const districts = getDistrictsByProvinceName("Adana");
console.log(districts);
[
{ name: 'Aladağ', apiId: 104 },
{ name: 'Ceyhan', apiId: 105 },
{ name: 'Çukurova', apiId: 6113 },
...
];