# JSON host API

`node scripts/cli.mjs request.json [--out new-result.json]` or `-` for UTF-8 stdin. Exclusive output creation refuses existing files. Exit codes: 0 success, 2 request/model error, 1 IO error, 64 CLI usage.

Request: `{candidates:[IDs], ballots:[{weight:integer,ranking:[[first-rank IDs],[second-rank IDs]]}], method:...}`.

| method | result |
| --- | --- |
| audit (default) | schulze and ranked_pairs reports |
| schulze | winners, strengths, witnesses |
| ranked_pairs | winners, ordered lock decisions |
| irv | winners, rounds, needs_tiebreak; optional tie_order candidate permutation |
| irv_possible | possible_winners, explored_states, witnesses; optional max_states default 65535 |

All successful outputs include canonical candidates, total_weight, pairwise matrix and strict condorcet winner set. Errors: `{ok:false,code:"invalid"|"limit"|"json",error:string}`. A legitimate unresolved tie is successful computation, not malformed input. Requests are limited to 3,000,000 UTF-16 units. Examples in examples/ are complete requests.
