marker
(document conversion and structured extraction), and ocr
endpoints. All Datalab converters can be accessed via a /api/v1/{converter_name}
endpoint.
(Note: for detailed tutorials, check out our Recipes section)
Submit a Request
cURL
request_id
is a unique identifier for the job you can use it to get a result.
Get a Result
Authentication
All requests to the Datalab API must include anX-API-Key
header with your API key.
The API always accepts JSON in request bodies and returns JSON in response bodies. You will need to send the content-type: application/json
header in requests. Data is uploaded as a multipart/form-data
request, with the file included as a file
field.
Marker
You can submit PDFs for conversion using the Marker API. In general, the marker endpoint is available at/api/v1/marker
.
Here is an example request in Python:
multipart/form-data
. You can see a full list of parameters and descriptions in the API reference.
The request will return the following:
request_check_url
, like this:
status
field will be set to complete
, and you will get an object that looks like this:
False
, you will get an error code along with the response.
All response data will be deleted from datalab servers an hour after the processing is complete, so make sure to get your results by then.
We have a more detailed guide for Marker here under Recipes.
Structured Extraction
Structured Extraction is an output mode ofmarker
that lets you provide the fields you care about extracting from a PDF. After conversion, marker
will check to see if you passed in a page_schema
parameter and use it to run extraction.
We have a detailed guide on how you can run Structured Extraction with our API, including tips for handling long documents and other edge cases in our Recipes here.
OCR
The OCR endpoint at/api/v1/ocr
will run OCR on a given page and return detailed character and positional information.
Here is an example request in python:
request_check_url
, as seen above in the marker section.
The final response will look like this:
False
, you will get an error code along with the response.
All response data will be deleted from datalab servers an hour after the processing is complete, so make sure to get your results by then.
Response fields
status
- indicates the status of the request (complete
, orprocessing
).success
- indicates if the request completed successfully.True
orFalse
.error
- If there was an error, this is the error message.page_count
- number of pages we ran ocr on.pages
- a list containing one dictionary per input page. The fields are:text_lines
- the detected text and bounding boxes for each linetext
- the text in the lineconfidence
- the confidence of the model in the detected text (0-1)polygon
- the polygon for the text line in (x1, y1), (x2, y2), (x3, y3), (x4, y4) format. The points are in clockwise order from the top left.bbox
- the axis-aligned rectangle for the text line in (x1, y1, x2, y2) format. (x1, y1) is the top left corner, and (x2, y2) is the bottom right corner.chars
- the individual characters in the linetext
- the text of the characterbbox
- the character bbox (same format as line bbox)polygon
- the character polygon (same format as line polygon)confidence
- the confidence of the model in the detected character (0-1)bbox_valid
- if the character is a special token or math, the bbox may not be valid
page
- the page number in the fileimage_bbox
- the bbox for the image in (x1, y1, x2, y2) format. (x1, y1) is the top left corner, and (x2, y2) is the bottom right corner. All line bboxes will be contained within this bbox.