{
  "openapi": "3.1.1",
  "info": {
    "title": "Ohmforge Impedance Calculator API",
    "version": "1.0.0",
    "summary": "Complex impedance of R, L, C series/parallel networks: |Z|, phase, admittance, resonance.",
    "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://ohmforgeimpedancecalculator.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Complex impedance of R, L, C series/parallel networks: |Z|, phase, admittance, resonance.",
        "description": "Type a small network such as R100 + (L10m || C1u) and a frequency. The calculator returns the complex impedance (R + jX), magnitude and phase, the admittance G + jB, the equivalent inductance or capacitance at that frequency, Q, every resonance of the network, an |Z| and phase plot over frequency and the reactance of each part – checked against Ohmforge's AC simulator.\n\nMethodology:\n- Each element becomes a complex impedance: Z_R = R, Z_L = jωL, Z_C = 1/(jωC) with ω = 2πf. Series groups add impedances, parallel groups add admittances (Y = 1/Z). Complex division uses Smith's algorithm for numerical robustness.\n- Admittance Y = 1/Z = G + jB. The equivalent part at the frequency is L = X/ω for X > 0 or C = −1/(ωX) for X < 0; Q = |X| / R of the series equivalent.\n- Resonances are frequencies where the reactance X changes sign (zero phase): found on a 50-points-per-decade scan from 1 mHz to 100 GHz and refined by bisection. A minimum of |Z| (X from − to +) is a series resonance, a maximum (X from + to −) a parallel resonance.\n- Cross-check: the network is driven by a 1 A AC current source in Ohmforge's AC analysis, so the simulated node voltage equals Z; the relative difference is reported.\n\nIdeal parts: real inductors have winding resistance and self-resonance, capacitors have ESR and ESL, and both change with frequency, temperature and (for ceramics) DC bias.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "ohmforge_impedance_calculator",
        "x-owner-app": "ohmforge",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OhmforgeImpedanceCalculatorInput"
              },
              "examples": {
                "example1": {
                  "summary": "R100 + (L10m || C1u) at 1 kHz",
                  "value": {
                    "network": "R100 + (L10m || C1u)",
                    "frequency": 1000
                  }
                },
                "example2": {
                  "summary": "Series RLC at resonance (≈ 5.03 kHz)",
                  "value": {
                    "network": "R10 + L1m + C1u",
                    "frequency": 5033
                  }
                },
                "example3": {
                  "summary": "Speaker crossover branch at 3 kHz",
                  "value": {
                    "network": "(R8 + L0.42m) || (C6.6u + R2.2)",
                    "frequency": 3000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OhmforgeImpedanceCalculatorResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "OhmforgeImpedanceCalculatorInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "network": {
            "title": "Network",
            "description": "Elements R<value>, L<value>, C<value>; + = series, || (or //) = parallel, parentheses group. || binds tighter than +.",
            "type": "string",
            "maxLength": 2000,
            "default": "R100 + (L10m || C1u)"
          },
          "frequency": {
            "title": "Frequency",
            "type": "number",
            "minimum": 0.000001,
            "maximum": 1000000000000,
            "default": 1000,
            "x-unit": "Hz"
          }
        },
        "required": []
      },
      "OhmforgeImpedanceCalculatorResult": {
        "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": [
              "network",
              "frequency",
              "real",
              "imaginary",
              "magnitude",
              "phaseDeg",
              "resonances",
              "simulatorCheck"
            ],
            "additionalProperties": false,
            "properties": {
              "network": {
                "type": "string",
                "description": "Canonical form of the network with element names."
              },
              "expression": {
                "type": "string"
              },
              "frequency": {
                "type": "number"
              },
              "real": {
                "type": "number"
              },
              "imaginary": {
                "type": "number"
              },
              "magnitude": {
                "type": "number"
              },
              "phaseDeg": {
                "type": "number"
              },
              "conductance": {
                "type": "number"
              },
              "susceptance": {
                "type": "number"
              },
              "admittanceMagnitude": {
                "type": "number"
              },
              "equivalent": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "type": "string"
                  },
                  "value": {
                    "type": "number"
                  }
                }
              },
              "q": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "elements": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "value": {
                      "type": "number"
                    },
                    "reactance": {
                      "type": "number"
                    }
                  }
                }
              },
              "resonances": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "frequency": {
                      "type": "number"
                    },
                    "type": {
                      "type": "string"
                    },
                    "magnitude": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "null = unbounded (parallel resonance of ideal, lossless L and C)."
                    }
                  }
                }
              },
              "sweep": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "frequencies": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  },
                  "magnitude": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  },
                  "phaseDeg": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "simulatorCheck": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "simulatedMagnitude": {
                    "type": "number"
                  },
                  "simulatedPhaseDeg": {
                    "type": "number"
                  },
                  "relativeError": {
                    "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"
              }
            }
          }
        }
      }
    }
  }
}