← All tool references

Math · not_available

Weighted Average Calculator

Calculate an average using value and weight pairs.

Open public tool

Overview

Category
Math
API mode
not_available
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/weighted-average-calculator

View this descriptor as JSON

Execute availability

This tool is documented as a browser capability. Its execute route does not produce a server-side result; when execution is enabled, it responds with browser_interaction_required and points callers to the public tool page.

POST /api/v1/tools/weighted-average-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.

pairs · string · required
Enter one value | weight pair per line.
{
    "type": "object",
    "properties": {
        "pairs": {
            "type": "string",
            "description": "Enter one value | weight pair per line."
        }
    },
    "required": [
        "pairs"
    ],
    "additionalProperties": false
}

Output schema

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

weighted_average · number
Weighted average calculated by the tool.
weight_total · number
Total weight calculated by the tool.
item_count · number
Items calculated by the tool.
rows · array
Weighted terms calculated by the tool.
{
    "type": "object",
    "properties": {
        "weighted_average": {
            "type": "number",
            "description": "Weighted average calculated by the tool."
        },
        "weight_total": {
            "type": "number",
            "description": "Total weight calculated by the tool."
        },
        "item_count": {
            "type": "number",
            "description": "Items calculated by the tool."
        },
        "rows": {
            "type": "array",
            "description": "Weighted terms calculated by the tool."
        }
    },
    "additionalProperties": false
}

Weighted Average Calculator worked example

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/weighted-average-calculator/execute" \
  -H "Content-Type: application/json" \
  -d '{
    "pairs": "80|20\n92|35\n75|15\n88|30"
}'
{
    "ok": true,
    "data": {
        "slug": "weighted-average-calculator",
        "result": {
            "values": {
                "weighted_average": 85.849999999999994315658113919198513031005859375,
                "weight_total": 100,
                "item_count": 4,
                "rows": [
                    {
                        "value": 80,
                        "weight": 20,
                        "weighted_term": 1600
                    },
                    {
                        "value": 92,
                        "weight": 35,
                        "weighted_term": 3220
                    },
                    {
                        "value": 75,
                        "weight": 15,
                        "weighted_term": 1125
                    },
                    {
                        "value": 88,
                        "weight": 30,
                        "weighted_term": 2640
                    }
                ]
            },
            "display": {
                "display": "85.85"
            },
            "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.