← All tool references

Travel & Auto · execute

Gas Mileage Calculator

Estimate gallons, pump cost, and cost per mile for a trip using distance, vehicle MPG, and fuel price.

Open public tool

Overview

Category
Travel & Auto
API mode
execute
Processing
client-side
Privacy
no-data-stored

Public descriptor

The descriptor is available without an API key and supplies this tool’s metadata, schemas, modes, and examples.

GET /api/v1/tools/gas-mileage-calculator

View this descriptor as JSON

Execute availability

This tool has an execute route defined by its descriptor. Server-side execution is currently unavailable, so requests return api_not_launched.

POST /api/v1/tools/gas-mileage-calculator/execute

Authentication is not issued during the preview. A bearer API key is planned for execution after launch.

Input schema

object object; additional properties are not accepted.

distance · number · required
Enter the route distance you expect to travel, rather than a straight-line distance.
mpg · number · required
Enter the vehicle’s expected miles per gallon under the driving conditions you expect.
price_per_gallon · number · required
Enter the expected price per gallon at the pump.
{
    "type": "object",
    "properties": {
        "distance": {
            "type": "number",
            "description": "Enter the route distance you expect to travel, rather than a straight-line distance."
        },
        "mpg": {
            "type": "number",
            "description": "Enter the vehicle’s expected miles per gallon under the driving conditions you expect."
        },
        "price_per_gallon": {
            "type": "number",
            "description": "Enter the expected price per gallon at the pump."
        }
    },
    "required": [
        "distance",
        "mpg",
        "price_per_gallon"
    ],
    "additionalProperties": false
}

Output schema

On a successful execution, schema values appear in data.result.values.

gallons · number
Estimated fuel volume.
cost · number
Estimated cost.
mpg · number
Economy used or derived.
{
    "type": "object",
    "properties": {
        "gallons": {
            "type": "number",
            "description": "Estimated fuel volume."
        },
        "cost": {
            "type": "number",
            "description": "Estimated cost."
        },
        "mpg": {
            "type": "number",
            "description": "Economy used or derived."
        }
    },
    "additionalProperties": false
}

300-mile weekend trip

The request body follows the published input schema. The response below shows the success-envelope shape returned after execution is available.

curl -X POST "https://utilitypages.org/api/v1/tools/gas-mileage-calculator/execute" \
  -H "Content-Type: application/json" \
  -d '{
    "distance": 300,
    "mpg": 28,
    "price_per_gallon": 3.5
}'
{
    "ok": true,
    "data": {
        "slug": "gas-mileage-calculator",
        "result": {
            "values": {
                "gallons": 10.71000000000000085265128291212022304534912109375,
                "cost": 37.5,
                "mpg": 28
            },
            "display": {
                "display": "10.71"
            },
            "warnings": [],
            "assumptions": [],
            "steps": []
        }
    },
    "meta": [],
    "request_id": "req_example_123"
}

Errors

api_not_launched · 503
Returned by the current launch gate for every execute request.
invalid_json · 400
Returned when an enabled execute request does not contain valid JSON.
validation_failed · 422
Returned when a request does not satisfy the input schema.
browser_interaction_required · 422
Returned for browser capability tools instead of inventing a server-side result.
tool_not_found · 404
Returned when a requested descriptor slug does not exist.
execution_failed · 503
Returned when an enabled server-side execution cannot complete.