API Dokümantasyonu

vitaRoute API entegrasyon rehberi

Hızlı Başlangıç

vitaRoute API'si REST tabanlıdır ve JSON ile çalışır. Tüm istekler HTTPS üzerinden gönderilmelidir.

Base URL: https://api.vitaroute.com
  1. Ücretsiz hesap oluşturun
  2. Dashboard'dan API key oluşturun
  3. İlk optimizasyon isteğinizi gönderin

Kimlik Doğrulama

Tüm API istekleri X-Api-Key header'ı ile kimlik doğrulaması gerektirir.

X-Api-Key: vtr_live_xxxxxxxxxxxxxxxxxxxx

⚠️ Güvenlik Notu

API key'lerinizi kaynak kodunuza dahil etmeyin. Ortam değişkenleri kullanın.

Endpoint'ler

POST/api/optimization/optimize

Gelişmiş rota optimizasyonu. RL destekli tescilli vitaRoute algoritması ile 20+ parametre değerlendirilerek en verimli rotalar hesaplanır.

POST/api/route/calculate

Temel rota hesaplama. Kümeleme tabanlı basit rota planı.

POST/api/route/cluster-stops

Mevcut duraksları araç kapasitesine göre kümelere ayırır.

İstek Şeması

AlanTipAçıklama
facilityLatfloatTesis/depo enlem koordinatı
facilityLngfloatTesis/depo boylam koordinatı
totalCapacityintAraç başına maksimum kapasite (varsayılan: 16)
vehicleCountintKullanılacak araç sayısı
maxWalkingintMaksimum yürüme mesafesi (metre, varsayılan: 500)
maxDurationintMaksimum rota süresi (dakika, varsayılan: 90)
nodesNodeInput[]Optimize edilecek personel/konum listesi

NodeInput

AlanTipAçıklama
idstringBenzersiz personel/lokasyon kimliği
namestringPersonel adı
latitudefloatEnlem koordinatı
longitudefloatBoylam koordinatı
districtstring?İlçe adı (isteğe bağlı, district kuralları için)

Yanıt Şeması

{
  "routes": [
    {
      "routeId": "uuid",
      "routeName": "GEBZE 1",
      "totalDuration": 45,
      "totalDistance": 28500,
      "nodeCount": 14,
      "totalLoad": 14,
      "stops": [
        {
          "stopIndex": 0,
          "latitude": 40.8962,
          "longitude": 29.1882,
          "nodes": [
            { "id": "1", "name": "Ali Yilmaz" }
          ]
        }
      ],
      "routeCenter": {
        "latitude": 40.9,
        "longitude": 29.2
      }
    }
  ]
}

İstek Limitleri

PlanAylık İstekMaks. NodeEş Zamanlı
Free5011
Starter1,0001005
Growth5,00050020
EnterpriseSınırsızSınırsızÖzel

Rate limit aşıldığında 429 Too Many Requests yanıtı döner. Retry-After header'ı bekleme süresini belirtir.

Hata Kodları

400

Bad Request

Geçersiz JSON veya eksik zorunlu alan

401

Unauthorized

API key eksik veya geçersiz

403

Forbidden

Plan limitiniz aşıldı

429

Too Many Requests

Rate limit aşıldı

500

Internal Server Error

Sunucu hatası, destek ekibine bildirin

Kod Örnekleri

curl

curl -X POST https://api.vitaroute.com/api/optimization/optimize \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: vtr_live_your_key_here" \
  -d '{
    "facilityLat": 40.9139,
    "facilityLng": 29.1167,
    "totalCapacity": 16,
    "vehicleCount": 3,
    "maxWalking": 500,
    "maxDuration": 90,
    "nodes": [
      { "id": "1", "name": "Ali Yilmaz", "latitude": 40.8962, "longitude": 29.1882, "district": "Kadikoy" },
      { "id": "2", "name": "Ayse Demir", "latitude": 40.9278, "longitude": 29.3125, "district": "Gebze" }
    ]
  }'

python

import requests

response = requests.post(
    "https://api.vitaroute.com/api/optimization/optimize",
    headers={
        "Content-Type": "application/json",
        "X-Api-Key": "vtr_live_your_key_here"
    },
    json={
        "facilityLat": 40.9139,
        "facilityLng": 29.1167,
        "totalCapacity": 16,
        "vehicleCount": 3,
        "maxWalking": 500,
        "maxDuration": 90,
        "nodes": [
            {"id": "1", "name": "Ali Yilmaz", "latitude": 40.8962, "longitude": 29.1882}
        ]
    }
)

data = response.json()
for route in data["routes"]:
    print(f"{route['routeName']}: {route['nodeCount']} stops, {route['totalDuration']} min")

javascript

const response = await fetch(
  "https://api.vitaroute.com/api/optimization/optimize",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-Api-Key": "vtr_live_your_key_here",
    },
    body: JSON.stringify({
      facilityLat: 40.9139,
      facilityLng: 29.1167,
      totalCapacity: 16,
      vehicleCount: 3,
      maxWalking: 500,
      maxDuration: 90,
      nodes: [
        { id: "1", name: "Ali Yilmaz", latitude: 40.8962, longitude: 29.1882 },
      ],
    }),
  }
);

const { routes } = await response.json();
routes.forEach(route => {
  console.log(`${route.routeName}: ${route.nodeCount} stops`);
});

C#

using System.Net.Http.Json;

var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "vtr_live_your_key_here");

var payload = new {
    facilityLat = 40.9139,
    facilityLng = 29.1167,
    totalCapacity = 16,
    vehicleCount = 3,
    maxWalking = 500,
    maxDuration = 90,
    nodes = new[] {
        new { id = "1", name = "Ali Yilmaz", latitude = 40.8962, longitude = 29.1882 }
    }
};

var response = await client.PostAsJsonAsync(
    "https://api.vitaroute.com/api/optimization/optimize",
    payload
);

var result = await response.Content.ReadFromJsonAsync<RouteResponse>();