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.
- Ücretsiz hesap oluşturun
- Dashboard'dan API key oluşturun
- İlk optimizasyon isteğinizi gönderin
Kimlik Doğrulama
Tüm API istekleri X-Api-Key header'ı ile kimlik doğrulaması gerektirir.
⚠️ Güvenlik Notu
API key'lerinizi kaynak kodunuza dahil etmeyin. Ortam değişkenleri kullanın.
Endpoint'ler
/api/optimization/optimizeGelişmiş rota optimizasyonu. RL destekli tescilli vitaRoute algoritması ile 20+ parametre değerlendirilerek en verimli rotalar hesaplanır.
/api/route/calculateTemel rota hesaplama. Kümeleme tabanlı basit rota planı.
/api/route/cluster-stopsMevcut duraksları araç kapasitesine göre kümelere ayırır.
İstek Şeması
| Alan | Tip | Açıklama |
|---|---|---|
facilityLat | float | Tesis/depo enlem koordinatı |
facilityLng | float | Tesis/depo boylam koordinatı |
totalCapacity | int | Araç başına maksimum kapasite (varsayılan: 16) |
vehicleCount | int | Kullanılacak araç sayısı |
maxWalking | int | Maksimum yürüme mesafesi (metre, varsayılan: 500) |
maxDuration | int | Maksimum rota süresi (dakika, varsayılan: 90) |
nodes | NodeInput[] | Optimize edilecek personel/konum listesi |
NodeInput
| Alan | Tip | Açıklama |
|---|---|---|
id | string | Benzersiz personel/lokasyon kimliği |
name | string | Personel adı |
latitude | float | Enlem koordinatı |
longitude | float | Boylam koordinatı |
district | string? | İ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
| Plan | Aylık İstek | Maks. Node | Eş Zamanlı |
|---|---|---|---|
| Free | 50 | 1 | 1 |
| Starter | 1,000 | 100 | 5 |
| Growth | 5,000 | 500 | 20 |
| Enterprise | Sınırsız | Sı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ı
Bad Request
Geçersiz JSON veya eksik zorunlu alan
Unauthorized
API key eksik veya geçersiz
Forbidden
Plan limitiniz aşıldı
Too Many Requests
Rate limit aşıldı
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>();