ID
API & MCPDokumentasi

Platform Agen & API Road User Tools

Hitung waktu perjalanan

Hitung durasi perjalanan dari jarak dan kecepatan rata-rata.

Antarmuka

POST
Titik akhir REST/api/v1/journey-time
MCP
Nama alatcalculate_journey_time

Permintaan

Kirim permintaan sebagai JSON. Klien MCP meneruskan bidang yang sama dengan argumen alat.

cURLshell
curl -X POST https://roaduser.tools/api/v1/journey-time \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "content-type: application/json" \
  -d '{
  "distance": {
    "value": 250,
    "unit": "km"
  },
  "speed": {
    "value": 100,
    "unit": "kmh"
  }
}'
Permintaan tubuhjson
{
  "distance": {
    "value": 250,
    "unit": "km"
  },
  "speed": {
    "value": 100,
    "unit": "kmh"
  }
}

Respon

REST membungkus hasil perhitungan dalam amplop keberhasilan standar. MCP mengembalikan data penghitungan yang sama dengan keluaran alat terstruktur.

JSON
{
  "ok": true,
  "data": {
    "totalSeconds": 9000,
    "totalHours": 2.5,
    "duration": {
      "hours": 2,
      "minutes": 30,
      "seconds": 0
    },
    "formatted": "2:30:00"
  }
}

Skema

Definisi di bawah ini menunjukkan Skema JSON lengkap yang digunakan untuk memvalidasi masukan dan menjelaskan keluaran.

Skema input

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "distance": {
      "type": "object",
      "additionalProperties": false,
      "description": "Journey distance. Must be finite and non-negative.",
      "properties": {
        "value": {
          "type": "number"
        },
        "unit": {
          "type": "string",
          "enum": [
            "km",
            "mi",
            "m"
          ]
        }
      },
      "required": [
        "value",
        "unit"
      ]
    },
    "speed": {
      "type": "object",
      "additionalProperties": false,
      "description": "Average speed. Must be finite and greater than zero.",
      "properties": {
        "value": {
          "type": "number"
        },
        "unit": {
          "type": "string",
          "enum": [
            "kmh",
            "mph",
            "ms",
            "kn"
          ]
        }
      },
      "required": [
        "value",
        "unit"
      ]
    }
  },
  "required": [
    "distance",
    "speed"
  ]
}

Skema output

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "totalSeconds": {
      "type": "number",
      "description": "Total duration in seconds, full precision."
    },
    "totalHours": {
      "type": "number",
      "description": "Total duration in decimal hours."
    },
    "duration": {
      "type": "object",
      "additionalProperties": false,
      "description": "Duration split into whole hours, minutes, and seconds.",
      "properties": {
        "hours": {
          "type": "number"
        },
        "minutes": {
          "type": "number"
        },
        "seconds": {
          "type": "number"
        }
      },
      "required": [
        "hours",
        "minutes",
        "seconds"
      ]
    },
    "formatted": {
      "type": "string",
      "description": "H:MM:SS presentation of the duration."
    }
  },
  "required": [
    "totalSeconds",
    "totalHours",
    "duration",
    "formatted"
  ]
}
Dokumentasi API & MCP