{
  "openapi": "3.1.1",
  "info": {
    "title": "Solution, Gas Law & pH Calculator API",
    "version": "1.0.0",
    "summary": "Molarity, dilution, mass ↔ moles ↔ particles, ideal gas with partial pressures, pH and buffers.",
    "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://prooflinesolutioncalculator.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Molarity, dilution, mass ↔ moles ↔ particles, ideal gas with partial pressures, pH and buffers.",
        "description": "One calculator for the everyday quantities of solution chemistry, with units you type yourself (250 mL, 0.1 M, 25 °C, 1 atm): molarity from mass and volume or any of the three from the other two, dilutions with C1·V1 = C2·V2, mass, moles and particles of a formula, the ideal gas law solved for any variable with Dalton partial pressures of a mixture, and the pH of strong and weak acids and bases (exact quadratic and full charge balance) and of buffers (Henderson–Hasselbalch checked against the exact result). Part of the Proofline math notebook.\n\nMethodology:\n- Quantities are read with their units and converted to mol, g, L, Pa and K. Molar masses come from the formula (CIAAW standard atomic weights) or the number you give.\n- Molarity c = n / V with V the final volume of solution; dilution conserves the solute, C1·V1 = C2·V2; particles N = n·N_A with the exact Avogadro constant.\n- Ideal gas: p·V = n·R·T with the exact molar gas constant R = 8.314462618… J/(mol·K), solved for the empty quantity. Mixtures: mole fractions xᵢ = nᵢ / n and partial pressures pᵢ = xᵢ·p (Dalton).\n- pH at 25 °C with Kw = 1.0 × 10⁻¹⁴: strong acids and bases from the charge balance [H⁺] = c + Kw/[H⁺]; weak acids and bases from the textbook quadratic x² + K·x − K·c = 0 and from the full charge balance including water, solved by bisection; the shortcut √(K·c) is shown with the 5 % check. Buffers: Henderson–Hasselbalch pKa + log([A⁻]/[HA]) next to the exact charge balance [H⁺] + c(A⁻) = [A⁻] + [OH⁻].\n\nDilute-solution model: activities are taken as concentrations, so pH values above about 0.1 M ionic strength and below pH 1 are approximate. Real gases deviate from the ideal gas law at high pressure. Nothing here is advice on handling chemicals safely.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "proofline_solution_calculator",
        "x-owner-app": "proofline",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProoflineSolutionCalculatorInput"
              },
              "examples": {
                "example1": {
                  "summary": "Molarity of 5.844 g NaCl in 250 mL",
                  "value": {
                    "mode": "molarity",
                    "formula": "NaCl",
                    "solute": "5.844 g",
                    "volume": "250 mL"
                  }
                },
                "example2": {
                  "summary": "Dilute 12 M hydrochloric acid to 500 mL of 1 M",
                  "value": {
                    "mode": "dilution",
                    "c1": "12 M",
                    "c2": "1 M",
                    "v2": "500 mL"
                  }
                },
                "example3": {
                  "summary": "Molecules in a spoon of water (18 g)",
                  "value": {
                    "mode": "amount",
                    "formula": "H2O",
                    "quantity": "18 g"
                  }
                },
                "example4": {
                  "summary": "Volume of 1 mol of gas at 0 °C and 1 atm",
                  "value": {
                    "mode": "gas",
                    "pressure": "1 atm",
                    "temperature": "0 °C",
                    "gasAmount": "1 mol"
                  }
                },
                "example5": {
                  "summary": "Partial pressures of dry air at 1 atm",
                  "value": {
                    "mode": "gas",
                    "pressure": "1 atm",
                    "temperature": "25 °C",
                    "mixture": "N2 = 0.7808 mol, O2 = 0.2095 mol, Ar = 0.0093 mol, CO2 = 0.0004 mol"
                  }
                },
                "example6": {
                  "summary": "pH of 0.1 M acetic acid",
                  "value": {
                    "mode": "ph",
                    "solutionType": "weak-acid",
                    "phConcentration": "0.1 M",
                    "constant": "Ka 1.8e-5"
                  }
                },
                "example7": {
                  "summary": "Acetate buffer with a 1.5 : 1 ratio",
                  "value": {
                    "mode": "ph",
                    "solutionType": "buffer",
                    "phConcentration": "0.1 M",
                    "conjugate": "0.15 M",
                    "constant": "pKa 4.76"
                  }
                },
                "example8": {
                  "summary": "pH of 0.02 M barium hydroxide",
                  "value": {
                    "mode": "ph",
                    "solutionType": "strong-base",
                    "phConcentration": "0.02 M",
                    "equivalents": 2
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProoflineSolutionCalculatorResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "ProoflineSolutionCalculatorInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "mode": {
            "title": "Calculation",
            "type": "string",
            "enum": [
              "molarity",
              "dilution",
              "amount",
              "gas",
              "ph"
            ],
            "default": "molarity"
          },
          "formula": {
            "title": "Formula of the solute or gas",
            "description": "Gives the molar mass for conversions between mass and moles (molarity, amount, gas).",
            "type": "string",
            "maxLength": 200,
            "default": ""
          },
          "molarMass": {
            "title": "Molar mass (instead of a formula)",
            "type": "number",
            "minimum": 0,
            "x-unit": "g/mol"
          },
          "solute": {
            "title": "Solute (mass or amount)",
            "description": "Molarity: leave exactly one of solute, volume and concentration empty — that one is calculated.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "volume": {
            "title": "Volume of solution",
            "description": "Molarity: the final volume of the solution in L, mL, µL, dm3 or cm3.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "concentration": {
            "title": "Concentration",
            "description": "Molarity: M, mM, µM, mol/L or g/L.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "c1": {
            "title": "C1 (stock concentration)",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "v1": {
            "title": "V1 (volume of stock)",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "c2": {
            "title": "C2 (final concentration)",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "v2": {
            "title": "V2 (final volume)",
            "description": "Dilution: leave exactly one of C1, V1, C2 and V2 empty.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "quantity": {
            "title": "Quantity",
            "description": "A mass (g), an amount (mol) or a number of particles (1.5e23 molecules).",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "pressure": {
            "title": "Pressure",
            "description": "Pa, kPa, bar, atm, mmHg, torr or psi. Gas law: leave exactly one of pressure, volume, amount and temperature empty.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "gasVolume": {
            "title": "Volume of gas",
            "description": "L, mL or m3.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "temperature": {
            "title": "Temperature",
            "description": "K, °C or °F.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "gasAmount": {
            "title": "Amount of gas",
            "description": "mol, or a mass with the formula. Leave empty to use the sum of the mixture.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "mixture": {
            "title": "Gas mixture (optional)",
            "description": "Each gas with an amount or a mass: mole fractions and partial pressures (Dalton’s law).",
            "type": "string",
            "maxLength": 2000,
            "default": ""
          },
          "solutionType": {
            "title": "Solution",
            "type": "string",
            "enum": [
              "strong-acid",
              "strong-base",
              "weak-acid",
              "weak-base",
              "buffer"
            ],
            "default": "weak-acid"
          },
          "phConcentration": {
            "title": "Acid or base concentration",
            "description": "pH: the concentration of the acid or base; for a buffer the concentration of the weak acid HA. M, mM or mol/L.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "constant": {
            "title": "Ka, pKa, Kb or pKb",
            "description": "A bare number is Ka for acids and buffers and Kb for bases; write pKa 4.76 or Kb 1.8e-5 to be explicit.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "conjugate": {
            "title": "Conjugate base concentration (buffer)",
            "type": "string",
            "maxLength": 60,
            "default": ""
          },
          "equivalents": {
            "title": "H⁺ or OH⁻ per formula unit (strong)",
            "description": "For example 2 for Ba(OH)2.",
            "type": "integer",
            "minimum": 1,
            "maximum": 4,
            "default": 1
          }
        },
        "required": []
      },
      "ProoflineSolutionCalculatorResult": {
        "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",
            "additionalProperties": false,
            "required": [
              "mode",
              "molarity",
              "dilution",
              "amount",
              "gas",
              "ph"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "molarity",
                  "dilution",
                  "amount",
                  "gas",
                  "ph"
                ]
              },
              "molarity": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "solved",
                  "molarMass",
                  "moles",
                  "massG",
                  "volumeL",
                  "molarity",
                  "massConcentration"
                ],
                "properties": {
                  "solved": {
                    "type": "string",
                    "enum": [
                      "solute",
                      "volume",
                      "concentration"
                    ]
                  },
                  "molarMass": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "moles": {
                    "type": "number"
                  },
                  "massG": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "volumeL": {
                    "type": "number"
                  },
                  "molarity": {
                    "type": "number"
                  },
                  "massConcentration": {
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                }
              },
              "dilution": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "solved",
                  "unit",
                  "c1",
                  "v1L",
                  "c2",
                  "v2L",
                  "solventL",
                  "factor"
                ],
                "properties": {
                  "solved": {
                    "type": "string",
                    "enum": [
                      "c1",
                      "v1",
                      "c2",
                      "v2"
                    ]
                  },
                  "unit": {
                    "type": "string",
                    "enum": [
                      "M",
                      "g/L"
                    ]
                  },
                  "c1": {
                    "type": "number"
                  },
                  "v1L": {
                    "type": "number"
                  },
                  "c2": {
                    "type": "number"
                  },
                  "v2L": {
                    "type": "number"
                  },
                  "solventL": {
                    "type": "number"
                  },
                  "factor": {
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                }
              },
              "amount": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "molarMass",
                  "moles",
                  "massG",
                  "particles",
                  "atoms"
                ],
                "properties": {
                  "molarMass": {
                    "type": "number"
                  },
                  "moles": {
                    "type": "number"
                  },
                  "massG": {
                    "type": "number"
                  },
                  "particles": {
                    "type": "number"
                  },
                  "atoms": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "element",
                        "atoms",
                        "moles"
                      ],
                      "properties": {
                        "element": {
                          "type": "string"
                        },
                        "atoms": {
                          "type": "number"
                        },
                        "moles": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              },
              "gas": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "solved",
                  "pressurePa",
                  "volumeL",
                  "moles",
                  "temperatureK",
                  "massG",
                  "densityGL",
                  "molarVolumeL",
                  "mixture"
                ],
                "properties": {
                  "solved": {
                    "type": "string",
                    "enum": [
                      "pressure",
                      "volume",
                      "amount",
                      "temperature"
                    ]
                  },
                  "pressurePa": {
                    "type": "number"
                  },
                  "volumeL": {
                    "type": "number"
                  },
                  "moles": {
                    "type": "number"
                  },
                  "temperatureK": {
                    "type": "number"
                  },
                  "massG": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "densityGL": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "molarVolumeL": {
                    "type": "number"
                  },
                  "mixture": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "formula",
                        "moles",
                        "moleFraction",
                        "partialPressurePa"
                      ],
                      "properties": {
                        "formula": {
                          "type": "string"
                        },
                        "moles": {
                          "type": "number"
                        },
                        "moleFraction": {
                          "type": "number"
                        },
                        "partialPressurePa": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              },
              "ph": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "type",
                  "concentration",
                  "conjugate",
                  "equivalents",
                  "constant",
                  "pH",
                  "pOH",
                  "hydronium",
                  "hydroxide",
                  "quadraticPH",
                  "approxPH",
                  "hendersonPH",
                  "ionizationPercent",
                  "pKw"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "strong-acid",
                      "strong-base",
                      "weak-acid",
                      "weak-base",
                      "buffer"
                    ]
                  },
                  "concentration": {
                    "type": "number"
                  },
                  "conjugate": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "equivalents": {
                    "type": "integer"
                  },
                  "constant": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "additionalProperties": false,
                    "required": [
                      "kind",
                      "K",
                      "pK"
                    ],
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "Ka",
                          "Kb"
                        ]
                      },
                      "K": {
                        "type": "number"
                      },
                      "pK": {
                        "type": "number"
                      }
                    }
                  },
                  "pH": {
                    "type": "number"
                  },
                  "pOH": {
                    "type": "number"
                  },
                  "hydronium": {
                    "type": "number"
                  },
                  "hydroxide": {
                    "type": "number"
                  },
                  "quadraticPH": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "approxPH": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "hendersonPH": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "ionizationPercent": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "pKw": {
                    "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"
              }
            }
          }
        }
      }
    }
  }
}