Skip to main content

Process Strokes

Process handwriting stroke coordinates directly, without rendering an image first.

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

POST v3/strokes

POST api.mathpix.com/v3/strokes

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.

info

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

Example

curl -X POST https://api.mathpix.com/v3/strokes \
-H 'app_id: APP_ID' \
-H 'app_key: APP_KEY' \
-H 'Content-Type: application/json' \
--data '{ "strokes": {"strokes": {
"x": [[131,131,130,130,131,133,136,146,151,158,161,162,162,162,162,159,155,147,142,137,136,138,143,160,171,190,197,202,202,202,201,194,189,177,170,158,153,150,148],[231,231,233,235,239,248,252,260,264,273,277,280,282,283],[273,272,271,270,267,262,257,249,243,240,237,235,234,234,233,233],[296,296,297,299,300,301,301,302,303,304,305,306,306,305,304,298,294,286,283,281,281,282,284,284,285,287,290,293,294,299,301,308,309,314,315,316]],
"y": [[213,213,212,211,210,208,207,206,206,209,212,217,220,227,230,234,236,238,239,239,239,239,239,239,241,247,252,259,261,264,266,269,270,271,271,271,270,269,268],[231,231,232,235,238,246,249,257,261,267,270,272,273,274],[230,230,230,231,234,240,246,258,268,273,277,281,281,283,283,284],[192,192,191,189,188,187,187,187,188,188,190,193,195,198,200,205,208,213,215,215,215,214,214,214,214,216,218,220,221,223,223,223,223,221,221,220]]
}}}'
Example response
{
"request_id": "cea6b8e4-0ab4-550a-c467-ce2eb00430be",
"text": "\\( 3 x^{2} \\)",
"latex_styled": "3 x^{2}",
"confidence": 1,
"confidence_rate": 1,
"is_printed": false,
"is_handwritten": true,
"image_height": 142,
"image_width": 199,
"version": "SuperNet-109p4"
}

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

metadata object (optional)

Key-value object. Supports improve_mathpix for extra privacy controls.

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

image_height integer (optional)

Height of the processed image in pixels

image_width integer (optional)

Width of the processed image in pixels

data object[] (optional)

List of Data objects

html string (optional)

Annotated HTML output

version string

Model version used for processing