{
  "openapi": "3.1.1",
  "info": {
    "title": "Ohmforge Voltage Divider Calculator API",
    "version": "1.0.0",
    "summary": "Solve Vout, Vin, R1 or R2 of a divider, with load, power per resistor and E-series pairs.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://ohmforgevoltagedivider.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Solve Vout, Vin, R1 or R2 of a divider, with load, power per resistor and E-series pairs.",
        "description": "Solves any one unknown of a two-resistor voltage divider (Vout, Vin, R1 or R2), optionally with a load resistance on the output. Returns currents, the power in each resistor, the output (Thevenin) resistance and how far the load pulls the output down, checks the result with Ohmforge's DC simulator and lists the closest standard E-series resistor pairs with their error.\n\nMethodology:\n- Unloaded: Vout = Vin · R2 / (R1 + R2). With a load RL the bottom leg becomes R2 ∥ RL = R2·RL / (R2 + RL); the same formula is rearranged for Vin, R1 or R2 (R2 = 1 / (1/R2eff − 1/RL) with R2eff = R1·Vout / (Vin − Vout)).\n- Power: P(R1) = I² · R1 with the input current I = Vin / (R1 + R2 ∥ RL); P(R2) = Vout² / R2. The output resistance seen by the load is R1 ∥ R2.\n- The circuit is then solved with Ohmforge's DC operating point (Modified Nodal Analysis) as an independent check of the formula.\n- E-series pairs: for every R2 of the chosen IEC 60063 series between 100 Ω and 1 MΩ (widened to include your values) the exact R1 is computed and its two neighbouring series values are tried; pairs whose total resistance is within ×3 of the solved R1 + R2 come first (same current level), then they are ranked by |Vout error| and closeness of the total to R1 + R2.\n\nNominal values only: real resistors deviate by their tolerance (and drift with temperature), and the source and load must be resistive and constant. A divider is not a power supply: for loads that draw significant or changing current use a regulator or a buffer.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "ohmforge_voltage_divider",
        "x-owner-app": "ohmforge",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OhmforgeVoltageDividerInput"
              },
              "examples": {
                "example1": {
                  "summary": "12 V with 10k / 4.7k",
                  "value": {
                    "solveFor": "vout",
                    "vin": 12,
                    "r1": "10k",
                    "r2": "4.7k",
                    "series": "E24"
                  }
                },
                "example2": {
                  "summary": "R2 for 3.3 V from 5 V with R1 = 10k",
                  "value": {
                    "solveFor": "r2",
                    "vin": 5,
                    "vout": 3.3,
                    "r1": "10k",
                    "series": "E96"
                  }
                },
                "example3": {
                  "summary": "Loaded divider: 10k / 10k into a 22k load",
                  "value": {
                    "solveFor": "vout",
                    "vin": 9,
                    "r1": "10k",
                    "r2": "10k",
                    "rload": "22k",
                    "series": "E12"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OhmforgeVoltageDividerResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "OhmforgeVoltageDividerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "solveFor": {
            "title": "Solve for",
            "type": "string",
            "enum": [
              "vout",
              "vin",
              "r1",
              "r2"
            ],
            "default": "vout"
          },
          "vin": {
            "title": "Input voltage Vin",
            "description": "Ignored when you solve for Vin.",
            "type": "number",
            "minimum": 0.000001,
            "maximum": 100000,
            "default": 12,
            "x-unit": "V"
          },
          "vout": {
            "title": "Output voltage Vout",
            "description": "Target output; ignored when you solve for Vout.",
            "type": "number",
            "minimum": 0.000001,
            "maximum": 100000,
            "x-unit": "V"
          },
          "r1": {
            "title": "R1 (top, Vin to Vout)",
            "description": "Engineering notation: 4.7k, 4k7, 1M. Ignored when you solve for R1.",
            "type": "string",
            "maxLength": 32,
            "default": "10k"
          },
          "r2": {
            "title": "R2 (bottom, Vout to ground)",
            "description": "Ignored when you solve for R2.",
            "type": "string",
            "maxLength": 32,
            "default": "4.7k"
          },
          "rload": {
            "title": "Load resistance (optional)",
            "description": "Resistance connected from Vout to ground, e.g. the input of the next stage. Empty = no load.",
            "type": "string",
            "maxLength": 32
          },
          "series": {
            "title": "Standard resistor series",
            "type": "string",
            "enum": [
              "E6",
              "E12",
              "E24",
              "E48",
              "E96",
              "E192"
            ],
            "default": "E24"
          }
        },
        "required": []
      },
      "OhmforgeVoltageDividerResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "required": [
              "solveFor",
              "vin",
              "vout",
              "r1",
              "r2",
              "ratio",
              "pairs",
              "simulatedVout"
            ],
            "additionalProperties": false,
            "properties": {
              "solveFor": {
                "type": "string"
              },
              "vin": {
                "type": "number"
              },
              "vout": {
                "type": "number"
              },
              "voutUnloaded": {
                "type": "number"
              },
              "r1": {
                "type": "number"
              },
              "r2": {
                "type": "number"
              },
              "rload": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "ratio": {
                "type": "number"
              },
              "inputCurrent": {
                "type": "number"
              },
              "r2Current": {
                "type": "number"
              },
              "loadCurrent": {
                "type": "number"
              },
              "p1": {
                "type": "number"
              },
              "p2": {
                "type": "number"
              },
              "pLoad": {
                "type": "number"
              },
              "outputResistance": {
                "type": "number"
              },
              "loadDropPercent": {
                "type": "number"
              },
              "simulatedVout": {
                "type": "number",
                "description": "Vout from Ohmforge's DC operating point of the same circuit (cross-check)."
              },
              "series": {
                "type": "string"
              },
              "pairs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "r1": {
                      "type": "number"
                    },
                    "r2": {
                      "type": "number"
                    },
                    "vout": {
                      "type": "number"
                    },
                    "errorPercent": {
                      "type": "number"
                    },
                    "totalResistance": {
                      "type": "number"
                    }
                  }
                }
              },
              "netlist": {
                "type": "string"
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}