Genel Bakış
NosyAPI İl & İlçe Mesafe API dökümantasyonuna hoşgeldiniz.
Bu dökümantasyonu ile Türkiye'deki ilçelerin birbiriyleriyle olan uzaklığını km ve mil olarak ulaşabilirsiniz.
İçindekiler
- API Token Bilgileri
- İl & İlçe Mesafe Hesaplama - İstek
- İlçe Mesafe Hesaplama - Örnek Kodlar
- Şehir ve İlçelerin ID'lerini Listeleme - İstek
- Şehir ve İlçelerin ID'lerini Listeleme - Örnek Kodlar
API Token Bilgileri
API kullanımı için token bilgisine ihtiyaç duymaktayız. Bu token bilgisi ile istediğiniz bilgileri çekebilirsiniz. Her üyemize otomatik olarak token tanımlanır. Token bilginizi menüde yer alan API Bilgilerim bölümünden alabilirsiniz.
İl & İlçe Mesafe Hesaplama - İstek
İstek |
---|
GET - https://www.nosyapi.com/apiv2/distance/getDistance?go=1&end=2 (ID Değerleri aşağıdaki istekten alınacaktır) |
Alan | Açıklama | Veri Tipi | Zorunluluk |
---|---|---|---|
go | Başlangıç olarak yer alacak ilçenin ID'sidir. | int |
Zorunlu |
end | Bitiş olarak yer alacak ilçenin ID'sidir. | int |
Zorunlu |
Örnek Kodlar |
---|
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.nosyapi.com/apiv2/distance/getDistance?go=1&end=2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer API_KEY'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
curl --location --request GET 'https://www.nosyapi.com/apiv2/distance/getDistance?go=1&end=2' \
--header 'Authorization: Bearer API_KEY'
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://www.nosyapi.com/apiv2/distance/getDistance?go=1&end=2");
xhr.setRequestHeader("Authorization", "Bearer API_KEY");
xhr.send();
var client = new RestClient("https://www.nosyapi.com/apiv2/distance/getDistance?go=1&end=2");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer API_KEY");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Unirest.setTimeouts(0, 0);
HttpResponse response = Unirest.get("https://www.nosyapi.com/apiv2/distance/getDistance?go=1&end=2")
.header("Authorization", "Bearer API_KEY")
.asString();
import http.client
conn = http.client.HTTPSConnection("www.nosyapi.com")
payload = ''
headers = {
'Authorization': 'Bearer API_KEY'
}
conn.request("GET", "/apiv2/distance/getDistance?go=1&end=2", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
var semaphore = DispatchSemaphore (value: 0)
var request = URLRequest(url: URL(string: "https://www.nosyapi.com/apiv2/distance/getDistance?go=1&end=2")!,timeoutInterval: Double.infinity)
request.addValue("Bearer API_KEY", forHTTPHeaderField: "Authorization")
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
semaphore.signal()
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
Diğer programlama dilleri veya Postman çıktısı için lütfen info@nosyapi.com adresine mail atınız.
Not: API_TOKEN yazan yerleri kendi token bilginizle değiştirmeyi unutmayınız.
Yanıt |
---|
{
{
"status": "success",
"message": "ok",
"systemTime": 1608339443,
"rowCount": 1,
"data": {
"km": 100,
"mil": 62.13,
"time": "1 Saat, 6 Dakika, 40 Saniye"
}
}
ÜŞehir ve İlçelerin ID'lerini Listeleme - İstek
Buradaki işlemde yukarı yer alan "CountryID" bilgisini ilgili sayfaya göndermemiz gerekmektedir.
İstek |
---|
GET - https://www.nosyapi.com/apiv2/distance/getCityList (Şehirleri Listeler) |
GET - https://www.nosyapi.com/apiv2/distance/getCityList?city_id=35 (Şehir ID'sini girdiğinizde o ile ait ilçeleri listeler) |
Alan | Veri Tipi | Zorunluluk | Açıklama |
---|---|---|---|
city_id | Şehire ait ID değeridir. | int |
Zorunlu Değil |
Örnek Kodlar |
---|
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.nosyapi.com/apiv2/distance/getCityList?city_id=35',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer API_KEY'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
curl --location --request GET 'https://www.nosyapi.com/apiv2/distance/getCityList?city_id=35' \
--header 'Authorization: Bearer API_KEY'
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://www.nosyapi.com/apiv2/distance/getCityList?city_id=35");
xhr.setRequestHeader("Authorization", "Bearer API_KEY");
xhr.send();
var client = new RestClient("https://www.nosyapi.com/apiv2/distance/getCityList?city_id=35");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer API_KEY");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Unirest.setTimeouts(0, 0);
HttpResponse response = Unirest.get("https://www.nosyapi.com/apiv2/distance/getCityList?city_id=35")
.header("Authorization", "Bearer API_KEY")
.asString();
import http.client
conn = http.client.HTTPSConnection("www.nosyapi.com")
payload = ''
headers = {
'Authorization': 'Bearer API_KEY'
}
conn.request("GET", "/apiv2/distance/getCityList?city_id=35", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
var semaphore = DispatchSemaphore (value: 0)
var request = URLRequest(url: URL(string: "https://www.nosyapi.com/apiv2/distance/getCityList?city_id=35")!,timeoutInterval: Double.infinity)
request.addValue("Bearer API_KEY", forHTTPHeaderField: "Authorization")
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
semaphore.signal()
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
Diğer programlama dilleri ve postman dosyası lütfen info@nosyapi.com adresine mail atınız.
Not: API_TOKEN yazan yerleri kendi token bilginizle değiştirmeyi unutmayınız.
Yanıt |
---|
{
{
"status": "ok",
"systemTime": 1607171234,
"message": "ok",
"rowCount": 81,
"data": [
{
"_id": 819,
"cityName": "ALİAĞA"
},
{
"_id": 98,
"cityName": "BALÇOVA"
}...
]
}
Etiketler: iller arası mesafe api, ilçeler arası mesafe api, il ilçe mesafe hesaplama