Skip to content

This repository created all city and its districts of Türkiye as JSON format.

Notifications You must be signed in to change notification settings

mertmtn/CityDistrictJSONAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

CityDistrictJSONAPI

This repository created all cities and its districts of Türkiye as JSON format.

All data retrieved from https://www.e-icisleri.gov.tr/Anasayfa/MulkiIdariBolumleri.aspx on 26.09.2023

Features (Extra features added except cities and districts from retrieved data)

  • Cities
  • Total city count
  • Total district count
  • District list of each city
  • District count of each city
  • Plate (Vehicle registration number of each city)

Reaching Data

It published Github Pages like an API https://mertmtn.github.io/CityDistrictJSONAPI/all-city-district.json

Usage

JavaScript Implementation

getCityCount("https://mertmtn.github.io/CityDistrictJSONAPI/city-district.json");

async function getCityCount(file) {
  let response = await fetch(file);
  let responseJson = await response.json();  
  console.log(responseJson.cityCount); //Result : 81
}

C# Implementation

using (HttpClient httpClient = new())
{
    try
    {
        string url = "https://mertmtn.github.io/CityDistrictJSONAPI/all-city-district.json";

        var httpResponseMessage = await httpClient.GetAsync(url);

        if (httpResponseMessage.IsSuccessStatusCode)
        { 
            string responseJson = await httpResponseMessage.Content.ReadAsStringAsync();
            var deserializedClass = JsonConvert.DeserializeObject<Root>(responseJson);
        }
        else
        {
            Console.WriteLine($"HTTP Error: {httpResponseMessage.StatusCode}");
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Error: {ex.Message}");
    }
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Releases

No releases published

Packages

No packages published