[L016]Document Parsing

post
https://connect.patsnap.com/rd-llm/v1/documents/doc_parsing
Try in Sandbox

Run layout detection and OCR on the uploaded file. The file type is inferred from the filename extension. Supported types: png, jpg, jpeg, pdf, doc, docx, ppt, pptx, xls, and xlsx. Each file must not exceed 20 MB or 200 pages; a request times out if processing exceeds 300 seconds and returns the image link is a signed link with a validity period of 7 days. output_format is optional and defaults to markdown.

Request Parameters

List of parameters supported by this API endpoint

NameTypeExampleDescription
file
Required
filemaximum 20MB
File to parse. Supported types: png, jpg, jpeg, pdf, doc, docx, ppt, pptx, xls, and xlsx. Each file must not exceed 20 MB or 200 pages.
output_format
stringmarkdown
Output format: both returns structured JSONL data and Markdown; jsonl returns structured JSONL data only; markdown returns Markdown only. The returned image link is a signed link with a validity period of 7 days. Defaults to markdown if not specified.
Options
bothboth returns structured JSONL data and Markdown
jsonljsonl returns structured JSONL data only
markdownmarkdown returns Markdown only

Response Schema

Structure of the API response data

Field NameTypeExampleDescription
data
Required
objectPlease check the form: DocumentParseResponse
Data payload for Document Parsing.
state
Required
stringsuccess
Execution state; success indicates that parsing completed successfully.
results
Required
arrayPlease check the form: DocumentResultItem
Structured JSONL data; each element represents one document region. An empty array is returned when output_format=markdown.
url
string<uri>https://oss.example.com/doc/0_2.png?sign=...
URL of the cropped region image, primarily for chemical structures, figures, equations, and tables; null when unavailable. The returned image link is a signed link with a validity period of 7 days.
bbox
Required
array[ 0.16, 0.18, 0.37, 0.2, 0.9 ]
Normalized coordinates [x1, y1, x2, y2, confidence], with every value ranging from 0 to 1.
page
Required
integer<int32>-
Zero-based page index; 0 represents the first page.
type
Required
stringtext
Original region type produced by the layout model.
markdown
stringTECHNICAL FIELD The present disclosure relates to...
Complete Markdown summary. Returned when output_format is both or markdown; omitted when output_format=jsonl.
file_type
Required
stringpdf
Input file type inferred from the uploaded filename extension.
total_pages
Required
integer<int32>12
Total number of pages; always 1 for an image.
status
Required
stringsuccess
The request completed successfully.
error_msg
Required
stringsuccess
Always success on success.
error_code
Required
integer<int32>-
Always 0 on success.

Success Response Example

Example of a successful API response

JSON
{
  "data": {
    "state": "success",
    "results": [
      {
        "url": "https://oss.example.com/doc/0_2.png?sign=...",
        "bbox": [
          0.16,
          0.18,
          0.37,
          0.2,
          0.9
        ],
        "page": 0,
        "type": "text"
      }
    ],
    "markdown": "TECHNICAL FIELD\n\nThe present disclosure relates to...",
    "file_type": "pdf",
    "total_pages": 12
  },
  "status": true,
  "error_msg": "success",
  "error_code": 0
}

Error Codes

List of possible error codes returned by this endpoint

Business Errors

Error CodeDescription
68300004Invalid parameter!
68300005Search api failure!
68300006Analytic basic access error!
68300007Bad request!
68300008Service error, please try again later!
68300010The file does not comply with upload specifications!

Platform Errors

Error CodeDescription
67200000API call exceeds the total limit set by the platform!
67200001API call exceeds the total limit set by the platform!
67200002The current call rate is too fast, exceeding the current configuration limit QPS!
67200003The key and secret parameters for applying for the token are incorrect or the client has been disabled!
67200004The requested api does not have permission. Please contact our support personnel!
67200005Insufficient account balance/number of calls!
67200006The client has exceeded the activation validity period!
67200007The current call exceeds the configured usage limit of the day!
67200008Please check if the required apikey in the query parameter has been transmitted!
67200009The apikey does not match the passed bearerToken. Please check if a valid token is being used!
67200012The request is illegal!
67200100The current server status is busy, request response timeout!
67200101The API requested currently does not exist. Please check the request path!

HTTP Status Codes

Status CodeDescription
0Success
400Invalid request, missing file, empty file, or unsupported file format
413File exceeds 20 MB or the document exceeds 200 pages
500Internal server error; error_code is INTERNAL_ERROR
502Downstream processing failed; error_code may be OCR_FAILED, LAYOUT_DETECTION_FAILED, PDF_PARSE_FAILED, or DOCUMENT_CONVERSION_FAILED
504Request processing exceeded 300 seconds; error_code is GATEWAY_TIMEOUT

Performance Metrics

Expected performance characteristics for this endpoint

Normal Response Time

5000 ms

Max Response Time

10000 ms