{
  "openapi": "3.1.1",
  "info": {
    "title": "Ohmforge Resistor Network Calculator API",
    "version": "1.0.0",
    "summary": "Series/parallel resistor networks: total resistance, power per part, best E-series combinations.",
    "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://ohmforgeresistornetwork.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Series/parallel resistor networks: total resistance, power per part, best E-series combinations.",
        "description": "Two jobs in one: find the combination of up to three standard resistors (E6 to E192) that comes closest to a resistance you cannot buy, or evaluate a series/parallel expression such as 100 + (220 || 330) with the voltage, current and power of every resistor at a given voltage.\n\nMethodology:\n- Evaluate: series resistances add, parallel conductances add (1/R = Σ 1/Ri). The applied voltage is divided along series branches in proportion to their resistance and appears in full across each parallel branch; P = V² / R per resistor.\n- Find: one part = the nearest series value. Two parts: every series value a below (series) or above (parallel) the target is tried with the two series neighbours of the exact partner (T − a, or 1/(1/T − 1/a)). Three parts: every pair a ≤ b with the exact third value for a + b + c, a ∥ b ∥ c, (a + b) ∥ c and (a ∥ b) + c, again rounded down and up. Values span target/100 … target·100 (target/10 … target·10 for the first two parts of three-part E48 … E192 combinations).\n- Ranking: smallest |error|, then fewer parts. The best result for 1, 2 and 3 parts is listed separately so you can see what an extra resistor buys.\n\nNominal values only: the tolerance of each part (5 % for E24, 1 % for E96) usually exceeds the combination error, so measure or use tighter-tolerance parts where accuracy matters. Check the power rating of every resistor.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "ohmforge_resistor_network",
        "x-owner-app": "ohmforge",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OhmforgeResistorNetworkInput"
              },
              "examples": {
                "example1": {
                  "summary": "Make 1234 Ω from E12 parts",
                  "value": {
                    "mode": "find",
                    "target": "1234",
                    "series": "E12",
                    "maxParts": "3"
                  }
                },
                "example2": {
                  "summary": "12.5 Ω from E24 (two parts)",
                  "value": {
                    "mode": "find",
                    "target": "12.5",
                    "series": "E24",
                    "maxParts": "2"
                  }
                },
                "example3": {
                  "summary": "100 + (220 || 330) at 10 V",
                  "value": {
                    "mode": "evaluate",
                    "expression": "100 + (220 || 330)",
                    "voltage": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OhmforgeResistorNetworkResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "OhmforgeResistorNetworkInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "Task",
            "type": "string",
            "enum": [
              "find",
              "evaluate"
            ],
            "default": "find"
          },
          "target": {
            "title": "Target resistance",
            "description": "For \"find\": engineering notation, e.g. 1234, 2k15, 12.5.",
            "type": "string",
            "maxLength": 32,
            "default": "1234"
          },
          "series": {
            "title": "Standard resistor series",
            "type": "string",
            "enum": [
              "E6",
              "E12",
              "E24",
              "E48",
              "E96",
              "E192"
            ],
            "default": "E24"
          },
          "maxParts": {
            "title": "Resistors at most",
            "type": "string",
            "enum": [
              "1",
              "2",
              "3"
            ],
            "default": "3"
          },
          "expression": {
            "title": "Network expression",
            "description": "For \"evaluate\": values joined with + (series) and || or // (parallel); parentheses group; || binds tighter than +.",
            "type": "string",
            "maxLength": 2000,
            "default": "100 + (220 || 330)"
          },
          "voltage": {
            "title": "Voltage across the network",
            "description": "For \"evaluate\": used for the current and power of each resistor.",
            "type": "number",
            "minimum": 0,
            "maximum": 100000,
            "default": 10,
            "x-unit": "V"
          }
        },
        "required": []
      },
      "OhmforgeResistorNetworkResult": {
        "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": [
              "mode"
            ],
            "additionalProperties": false,
            "properties": {
              "mode": {
                "type": "string"
              },
              "target": {
                "type": "number"
              },
              "series": {
                "type": "string"
              },
              "combinations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "expression": {
                      "type": "string"
                    },
                    "shape": {
                      "type": "string"
                    },
                    "values": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    },
                    "ohms": {
                      "type": "number"
                    },
                    "errorPercent": {
                      "type": "number"
                    },
                    "parts": {
                      "type": "integer"
                    }
                  }
                }
              },
              "bestByParts": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "parts": {
                      "type": "integer"
                    },
                    "expression": {
                      "type": "string"
                    },
                    "ohms": {
                      "type": "number"
                    },
                    "errorPercent": {
                      "type": "number"
                    }
                  }
                }
              },
              "expression": {
                "type": "string"
              },
              "totalResistance": {
                "type": "number"
              },
              "voltage": {
                "type": "number"
              },
              "totalCurrent": {
                "type": "number"
              },
              "totalPower": {
                "type": "number"
              },
              "resistors": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "ohms": {
                      "type": "number"
                    },
                    "voltage": {
                      "type": "number"
                    },
                    "current": {
                      "type": "number"
                    },
                    "power": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}