Formula weight from a chemical formula (Hill notation, IUPAC/CIAAW weights)

$0.005 USDC per call · Business, finance and compliance · POST /api/v1/formula-weight · Id formula-weight

Parses a chemical formula (parentheses, brackets, hydrate dots such as CuSO4·5H2O, an ignored charge) for a chemist or an agent that must check a molar mass, and returns the Hill-notation formula, the formula weight in g/mol from the CIAAW abridged standard atomic weights summed exactly in decimal arithmetic, and mass fractions. Pass claimedWeight and tolerance to check a stated molar mass. Elements with no standard atomic weight (technetium, promethium, elements above bismuth except thorium, protactinium and uranium) return unknown unless you supply elementWeights. A separate mode validates SMILES syntax against the OpenSMILES grammar. It does NOT compute a weight from SMILES, handle isotope or deuterium notation, or check that a compound exists.

What you get

Molar-mass arithmetic by an LLM drifts in the third decimal; this is exact against a named atomic-weight table.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/formula-weight. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/formula-weight \
  -H 'content-type: application/json' \
  -d '{"formula":"CuSO4.5H2O","claimedWeight":249.677}'

Input

FieldTypeRequiredDescription
modestring; one of "formula", "smiles"noformula (default) computes the weight; smiles validates syntax only.
formulastring; length 0..200noChemical formula, at most 200 characters. Element symbols are case-sensitive (Co is cobalt, CO is carbon monoxide). Hydrate separators: . · • *. A trailing charge such as ^2+, 2- after a bracket, or a bare + or - is ignored.
smilesstring; length 0..200noA single SMILES string without a name, at most 200 characters (mode smiles).
elementWeightsarray<object>; max 20 itemsnoCaller-chosen weights; they take precedence over the table and are the only way to weigh elements without a standard atomic weight.
claimedWeightnumber; 0..1000000000noStated molar mass to check, g/mol.
tolerancenumber; 0..1000noAllowed absolute difference from claimedWeight in g/mol. Default 0.01.

Example request body

{
  "formula": "CuSO4.5H2O",
  "claimedWeight": 249.677
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
modestring; one of "formula", "smiles"no
validbooleannoWhether the input parsed.
formulaone ofno
weightone ofno
weightExactone ofno
uncertaintyone ofno
chargeIgnoredone ofno
missingElementsarray<string>no
compositionarray<object>no
partsarray<object>noFor hydrates/adducts: each dot-separated part with its coefficient and weight.
smilesobjectnoCounts from the SMILES syntax check (mode smiles).
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the physical-ops-kit package.

Machine-readable