HyperRoute

HyperRoute API

HyperRoute API

Welcome to the HyperRoute API documentation. HyperRoute is an advanced routing and logistics optimization engine specifically designed for Turkey's unique transportation network. It provides precise distance calculations, optimal path finding, detailed cost analysis including fuel consumption, and supports multiple vehicle types with their specific characteristics. The engine offers both fastest and shortest route options while considering real-time traffic conditions.

🚀 Quick Start in 3 Steps

  1. Get your API key from tech@siriusaitech.com
  2. Make your first request to /health
  3. Generate your first optimized route with /route/generate
Base URLs:
Production: https://api.route.siriusaitech.com
Test: https://test.api.router.siriusaitech.com

Quick Start

Get up and running with HyperRoute API in minutes.

Your First Request

bash
curl -X POST https://test.api.router.siriusaitech.com/route/generate \
  -H "Authorization: Bearer YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "vehicleTypeId": 5,
    "from": {
      "lat": "41.0082",
      "lng": "28.9784"
    },
    "to": {
      "lat": "40.1885",
      "lng": "29.0610"
    },
    "waypoints": [],
    "avoidPoints": [],
    "routeType": "fast",
    "isToll": 1,
    "isShip": 0,
    "fuelRatio": 35
  }'
javascript
const response = await fetch('https://test.api.router.siriusaitech.com/route/generate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    vehicleTypeId: 5,
    from: { lat: "41.0082", lng: "28.9784" },
    to: { lat: "40.1885", lng: "29.0610" },
    waypoints: [],
    avoidPoints: [],
    routeType: "fast",
    isToll: 1,
    isShip: 0,
    fuelRatio: 35
  })
});

const route = await response.json();
console.log(\`Distance: \${route.data.distance} km\`);
console.log(\`Total Cost: \${route.data.totalCost} TL\`);
python
import requests

response = requests.post(
    'https://test.api.router.siriusaitech.com/route/generate',
    headers={
        'Authorization': 'Bearer YOUR_ACCESS_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'vehicleTypeId': 5,
        'from': {'lat': '41.0082', 'lng': '28.9784'},
        'to': {'lat': '40.1885', 'lng': '29.0610'},
        'waypoints': [],
        'avoidPoints': [],
        'routeType': 'fast',
        'isToll': 1,
        'isShip': 0,
        'fuelRatio': 35
    }
)

route = response.json()
print(f"Distance: {route['data']['distance']} km")
print(f"Total Cost: {route['data']['totalCost']} TL")

Authentication

HyperRoute API uses Bearer token authentication. Include your access key in the Authorization header of every request.

http
Authorization: Bearer YOUR_ACCESS_KEY
Security Notice: Never expose your access key in client-side code or public repositories.

Getting Access Keys

To obtain access keys for development or production use:

  • Contact our technical team at tech@siriusaitech.com
  • Provide your company name and use case
  • Specify if you need test or production access

Rate Limits

To ensure fair usage and system stability, the following rate limits apply:

Limit Type Default Enterprise
Requests per minute 100 Custom
Request timeout 30 seconds 60 seconds
Max request size 10 MB 10 MB

Rate limit information is included in response headers:

  • X-RateLimit-Limit - Your rate limit
  • X-RateLimit-Remaining - Remaining requests
  • X-RateLimit-Reset - Reset timestamp

Health Check

GET /health

Check the operational status of the API and its dependencies.

No authentication required for this endpoint.

Response Example

json
{
  "status": "healthy",
  "timestamp": "2024-12-25T10:00:00.000Z",
  "uptime": 3600,
  "version": "1.0.0",
  "services": {
    "database": "up",
    "cache": "up",
    "routeEngine": "up"
  }
}

Generate Route

POST /route/generate

Generate an optimized route with cost calculations.

Request Body

Parameter Type Required Description
vehicleTypeId integer Yes Vehicle type (1-5)
from object Yes Starting coordinates
to object Yes Destination coordinates
routeType string Yes "fast" or "short"
waypoints array No Intermediate waypoints
avoidPoints array No Points/areas to avoid
isToll integer No Include toll costs (0/1)
isShip integer No Include ferry routes (0/1)
fuelRatio number No Fuel consumption (L/100km)

Vehicle Types

  • 1 - Automobile
  • 2 - Minibus
  • 3 - Bus
  • 4 - Light Commercial
  • 5 - Truck

Response Example

json
{
  "status": true,
  "data": {
    "distance": 354.82,
    "totalCost": 2150.65,
    "totalTime": 18540,
    "routeId": "route_abc123",
    "segments": [
      {
        "start": {"lat": 41.0082, "lng": 28.9784},
        "end": {"lat": 40.1885, "lng": 29.0610},
        "distance": 354820,
        "duration": 18540
      }
    ],
    "costs": {
      "fuel": 1850.65,
      "toll": 300.00,
      "total": 2150.65
    }
  }
}

Get Route Details

GET /route/get

Retrieve detailed information about a previously generated route.

Query Parameters

Parameter Type Required Description
routeId string Yes The unique route identifier

Response Example

json
{
  "status": true,
  "data": {
    "location": {
      "from": {
        "lat": "41.0082",
        "lng": "28.9784",
        "name": "Istanbul"
      },
      "to": {
        "lat": "40.1885",
        "lng": "29.0610",
        "name": "Bursa"
      },
      "waypoints": [],
      "avoidPoints": []
    },
    "route": {
      "routeId": "route_abc123",
      "vehicleType": "Truck",
      "routeType": "fast",
      "distance": 354.82,
      "duration": 18540,
      "totalCost": 2150.65,
      "fuelCost": 1850.65,
      "tollCost": 300.00,
      "segments": [
        {
          "points": [[41.0082, 28.9784], [40.9876, 29.0123]],
          "distance": 15.5,
          "duration": 900
        }
      ],
      "tollPoints": [
        {
          "name": "Osmangazi Bridge",
          "lat": 40.7589,
          "lng": 29.7311,
          "cost": 300.00
        }
      ]
    }
  },
  "message": "işlem başarılı"
}

Vehicle Types

GET /route/get/vehicle/types

Get all available vehicle types with their IDs and names.

This endpoint returns the list of vehicle types that can be used in route generation.

Response Example

json
{
  "status": true,
  "data": [
    {
      "id": 1,
      "name": "Automobile"
    },
    {
      "id": 2,
      "name": "Minibus"
    },
    {
      "id": 3,
      "name": "Bus"
    },
    {
      "id": 4,
      "name": "Light Commercial"
    },
    {
      "id": 5,
      "name": "Truck"
    }
  ]
}
Note: Use these vehicle type IDs when calling the /route/generate endpoint.

Route History Management

GET /route/get/history

Get the active version and history of a route using its route key.

Query Parameters

Parameter Type Required Description
routeKey string Yes The route key to get history for

Response Example

json
{
  "status": true,
  "data": {
    "routeKey": "rou_123456",
    "activeRoute": {
      "id": 1234,
      "routeKey": "rou_123456",
      "fromLat": 41.0082,
      "fromLng": 28.9784,
      "toLat": 39.9334,
      "toLng": 32.8597,
      "vehicleTypeId": 5,
      "vehicleTypeName": "Tır",
      "isActive": true,
      "totalCost": 450.00,
      "kilometer": 453.2,
      "totalMinutes": 360,
      "waypoints": [...],
      "avoidPoints": [...],
      "costSummary": {
        "totalCost": 450.00,
        "hgsOgs": 85.50,
        "bridge": 20.00,
        "fuel": 344.50
      }
    },
    "history": [
      {
        "id": 1233,
        "routeKey": "rou_123456",
        "isActive": false,
        "totalCost": 440.00,
        "kilometer": 451.5,
        "totalMinutes": 355
      }
    ],
    "summary": {
      "totalVersions": 2,
      "hasActiveRoute": true,
      "historyCount": 1
    }
  }
}
POST /route/change-active

Change the active version of a route by activating a historical version.

Request Body

json
{
  "routeKey": "rou_123456",
  "routeId": 1233
}

Parameters

Field Type Required Description
routeKey string Yes The route key identifier
routeId integer Yes ID of the route version to activate

Response Example

json
{
  "status": true,
  "data": {
    "message": "Aktif rota başarıyla değiştirildi",
    "activeRoute": {
      "id": 1233,
      "routeKey": "rou_123456",
      "fromLat": 41.0082,
      "fromLng": 28.9784,
      "toLat": 39.9334,
      "toLng": 32.8597,
      "vehicleTypeId": 5,
      "vehicleTypeName": "Tır",
      "isDelete": 0,
      "totalCost": 440.00,
      "kilometer": 451.5,
      "totalMinutes": 355
    }
  }
}
Note: This operation runs within a transaction. When a route is activated (isDelete=0), all other routes with the same routeKey are deactivated (isDelete=1).

Usage Statistics

GET /usage/my-stats

Get your own API usage statistics.

Query Parameters

Parameter Type Default Description
period integer 7 Number of days (1-365)
groupBy string day Grouping: hour, day, month

Response Example

json
{
  "status": true,
  "data": {
    "accessKey": "us-JNMSZ8V...L1H8",
    "period": {
      "days": 7,
      "startDate": "2024-12-18T10:00:00.000Z",
      "endDate": "2024-12-25T10:00:00.000Z"
    },
    "summary": {
      "totalRoutes": 1500,
      "totalDistance": "25000.50",
      "totalCost": "15000.75",
      "avgDistance": "16.67",
      "avgCost": "10.00",
      "uniqueRoutes": 120
    },
    "dailyUsage": [
      {
        "period": "2024-12-25",
        "totalRoutes": 50,
        "totalDistance": "850.25",
        "totalCost": "500.50"
      }
    ],
    "vehicleTypes": [
      {
        "vehicleType": "Kamyon",
        "count": 800,
        "totalDistance": "15000.00",
        "totalCost": "9000.00"
      }
    ],
    "routeTypes": [
      {
        "routeType": "fast",
        "count": 900,
        "avgDistance": "17.50",
        "avgCost": "10.50"
      }
    ]
  }
}

Overall Statistics (Admin)

GET /usage/overall

Get overall system usage statistics. Requires admin privileges.

Admin Only: This endpoint requires admin access privileges.

Query Parameters

Parameter Type Default Description
period integer 7 Number of days (1-365)

Response Example

json
{
  "status": true,
  "data": {
    "period": {
      "days": 7,
      "startDate": "2024-12-18T10:00:00.000Z",
      "endDate": "2024-12-25T10:00:00.000Z"
    },
    "keys": [
      {
        "keyName": "Production Key 1",
        "accessKey": "us-JNMSZ8V...L1H8",
        "totalRoutes": 5000,
        "totalDistance": "85000.00",
        "totalCost": "45000.00",
        "lastUsed": "2024-12-25T09:45:00.000Z"
      },
      {
        "keyName": "Development Key",
        "accessKey": "us-A8M4P1...7WYE",
        "totalRoutes": 1500,
        "totalDistance": "25000.00",
        "totalCost": "15000.00",
        "lastUsed": "2024-12-25T08:30:00.000Z"
      }
    ]
  }
}

Additional Endpoint

GET /usage/key/:accessKey

Get usage statistics for a specific access key. Requires admin privileges.

Parameters and response format are the same as /usage/my-stats.

Error Handling

All errors follow a consistent format:

json
{
  "status": false,
  "error": {
    "message": "Error description",
    "code": "ERROR_CODE",
    "statusCode": 400
  }
}

Common Error Codes

Status Code Error Code Description
401 UNAUTHORIZED Invalid or missing access key
429 RATE_LIMIT_EXCEEDED Too many requests
500 INTERNAL_ERROR Server error

SDKs (Coming Soon)

We're working on official SDKs to make integration even easier. Stay tuned for:

  • JavaScript/TypeScript SDK - Full type support and promise-based API
  • Python SDK - Pythonic interface with async support
  • PHP SDK - PSR-compliant package via Composer
  • Go SDK - Idiomatic Go client with context support
  • Java SDK - Maven/Gradle compatible package

Meanwhile, you can use the REST API directly with any HTTP client library.

Best Practices

1. Implement Retry Logic

Use exponential backoff for transient failures:

javascript
async function retryRequest(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      await new Promise(r => setTimeout(r, Math.pow(2, i) * 1000));
    }
  }
}

2. Cache Frequently Used Routes

Implement client-side caching for repeated route queries to reduce API calls and improve performance.

3. Handle Rate Limits Gracefully

Monitor rate limit headers and implement queuing when approaching limits.

4. Use Webhook Notifications

For long-running operations, consider using webhooks instead of polling.