LocusAPI
Problems API / Reference
POST

/public/grade

Grade a student's answer to a problem you fetched. The token binds the call to that exact problem; the answer key is loaded and compared server-side by a computer algebra system.

Base
https://api.locusmath.org/public
Auth
x-api-key header (or Authorization: Bearer)
Billing
Included with the serve - grade calls do not count against your quota (the per-minute burst still applies)
curl -X POST "https://api.locusmath.org/public/grade" \
  -H "x-api-key: <your-key>" \
  -H "Content-Type: application/json" \
  -d '{"submission_token": "<from the problem>", "user_input": "2x + 3"}'

Request body

FieldDescription
submission_tokenThe token from the fetched problem. Valid for 31 days, and the problem stays gradeable that whole window even if the corpus rotates underneath. Expired or malformed tokens return 400 - refetch the problem for a fresh one.
user_inputThe student's answer in the normalized string form the widget emits (for plain math entry: the expression, e.g. 2x+3 or x = 4). Max 10 KB; larger returns 400.

Response

{ "is_correct": true }

Equivalent forms count: 0.5x and x/2 grade the same. There is no partial credit signal - grading is boolean per problem (multi-part problems grade all parts together).

Why token-gated grading

Because the answer never crosses the wire, a student inspecting your site's network traffic finds nothing to leak - and you never store or sync answer keys. A client can only grade problems it was actually served. Grading is included with the problem serve - grade calls do not count against your quota.