Skip to main content

POST v3/strokes

POST api.mathpix.com/v3/strokes

Process handwriting stroke coordinates directly, without generating an image first. Accepts the same options as v3/text for output formatting. Results in faster response times and smaller request payloads compared to sending rendered images.

The LaTeX of the recognized handwriting is returned inside inline delimiters \( ... \) and block mode delimiters \[ .... \]. Lines are separated with \n newline characters.

See the strokes processing guide for step-by-step examples.

info

Request limit: 512 KB JSON body (smaller than other endpoints). See Limits & Quotas for details.

Request parameters

The stroke data format uses arrays of x and y coordinates, where each sub-array represents one stroke:

{
"strokes": {
"strokes": {
"x": [[x1_stroke1, x2_stroke1, ...], [x1_stroke2, ...]],
"y": [[y1_stroke1, y2_stroke1, ...], [y1_stroke2, ...]]
}
}
}
strokes JSON

Strokes in JSON with appropriate format

strokes_session_id string (optional)

Stroke session ID returned included by app token API call

All other request params from v3/text are supported.

note

strokes_session_id must be sent along with the app_token as an auth header, see app tokens. Strokes sessions (digital ink with live updating results) are billed differently from v3/strokes requests without intermediate results, see Mathpix OCR pricing.

Response body

request_id string

Request ID, for debugging purposes

text string (optional)

Recognized text format, if such is found

latex_styled string (optional)

Math LaTeX string, if the input is a single equation

confidence number in [0,1] (optional)

Estimated probability 100% correct

confidence_rate number in [0,1] (optional)

Estimated confidence of output quality

is_printed bool (optional)

Whether printed content was detected

is_handwritten bool (optional)

Whether handwritten content was detected

auto_rotate_confidence number in [0,1] (optional)

Confidence that the input needs rotation

auto_rotate_degrees number in {0, 90, -90, 180} (optional)

Rotation angle applied

data [object] (optional)

List of Data objects

html string (optional)

Annotated HTML output

version string

Model version used for processing