{
  "openapi": "3.0.1",
  "info": {
    "title": "PDF Text Extractor - Markdown, RAG Chunks, OCR & Metadata",
    "description": "Extract clean text or Markdown from PDF (and DOCX) URLs for AI agents and RAG: reading order across columns, de-hyphenation, header/footer removal, page ranges, per-page output or token-sized chunks with overlap, metadata, links, scanned-page detection and optional OCR. One item per document.",
    "version": "1.0",
    "x-build-id": "jDWqTybvDID5Kjsh1"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/artificially~pdf-text-extractor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-artificially-pdf-text-extractor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/artificially~pdf-text-extractor/runs": {
      "post": {
        "operationId": "runs-sync-artificially-pdf-text-extractor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/artificially~pdf-text-extractor/run-sync": {
      "post": {
        "operationId": "run-sync-artificially-pdf-text-extractor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "urls"
        ],
        "properties": {
          "urls": {
            "title": "Document URLs (PDF or DOCX)",
            "type": "array",
            "description": "Required. One public URL per entry pointing to a PDF (or a Word .docx) file. Redirects are followed, so signed download links work (e.g. SAM.gov attachment URLs like https://sam.gov/api/prod/opps/v3/opportunities/resources/files/{resourceId}/download that 303-redirect to S3). arXiv abstract pages (https://arxiv.org/abs/1706.03762) and bare arXiv IDs (1706.03762) are mapped to the PDF automatically; Google Drive file links, Dropbox share links and GitHub blob links are converted to direct downloads. Duplicate URLs are processed once. Example: [\"https://arxiv.org/pdf/1706.03762\", \"https://www.irs.gov/pub/irs-pdf/fw9.pdf\"].",
            "items": {
              "type": "string"
            }
          },
          "outputFormat": {
            "title": "Output format",
            "enum": [
              "text",
              "markdown"
            ],
            "type": "string",
            "description": "\"text\" returns clean plain text (paragraphs separated by blank lines, lists as \"- item\", tables as \"cell | cell\" rows). \"markdown\" returns Markdown with # headings (detected from font size and section numbering like \"3.1\"), lists and best-effort pipe tables. Use markdown for LLMs and RAG when document structure matters.",
            "default": "text"
          },
          "splitBy": {
            "title": "Split content by",
            "enum": [
              "document",
              "page",
              "chunk"
            ],
            "type": "string",
            "description": "How the extracted content is returned. There is always ONE dataset item per document. \"document\": the whole text in the text/markdown field. \"page\": a pages array [{page, text}] (text/markdown field is null). \"chunk\": a chunks array [{index, text, pageStart, pageEnd, section, tokenEstimate}] ready for embedding in a vector database (text/markdown field is null).",
            "default": "document"
          },
          "chunkSize": {
            "title": "Chunk size (tokens)",
            "minimum": 100,
            "maximum": 8000,
            "type": "integer",
            "description": "Only used when splitBy is \"chunk\". Target chunk size in tokens (1 token is estimated as 4 characters, so 1000 tokens is about 4000 characters). Chunks break at paragraph and sentence boundaries and start a new chunk at headings. Example: 500 for small-context embedding models, 1000 as a general default.",
            "default": 1000
          },
          "chunkOverlap": {
            "title": "Chunk overlap (tokens)",
            "minimum": 0,
            "maximum": 4000,
            "type": "integer",
            "description": "Only used when splitBy is \"chunk\". How many tokens of the end of the previous chunk are repeated at the start of the next one, so context is not lost at boundaries. Max half of chunkSize. Example: 100.",
            "default": 100
          },
          "includeMetadata": {
            "title": "Include document metadata",
            "type": "boolean",
            "description": "Add a metadata object: title, author, subject, keywords, creator, producer, createdAt, modifiedAt (ISO 8601), pdfVersion, isEncrypted, isTagged, hasForm. Not available for DOCX (null).",
            "default": true
          },
          "extractLinks": {
            "title": "Extract links",
            "type": "boolean",
            "description": "Add a links array [{url, page}] with every clickable link (PDF link annotations, DOCX hyperlinks) and every http(s) URL written in the text, de-duplicated.",
            "default": false
          },
          "compactOutput": {
            "title": "Compact output (for AI agents)",
            "type": "boolean",
            "description": "Return slim items with only url, fileName, fileType, title, pageCount, language, charCount, needsOcr, truncated and the content (text/markdown, pages or chunks). Best for AI agents and MCP clients with limited context.",
            "default": false
          },
          "pageRange": {
            "title": "Page range",
            "type": "string",
            "description": "Extract only these pages (1-based). Comma-separated pages and ranges; an open range runs to the last page. Examples: \"1-5\", \"1-3,8,10-12\", \"20-\". Leave empty for all pages (up to maxPages). Applies to every PDF in the run."
          },
          "maxPages": {
            "title": "Max pages per document",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Stop after this many pages per document (applied after pageRange). Protects run time on very long files. Example: 20 to read only the beginning of long reports.",
            "default": 200
          },
          "removeHeadersFooters": {
            "title": "Remove repeated headers and footers",
            "type": "boolean",
            "description": "Drop lines at the top or bottom of pages that repeat on at least 40% of pages (running titles, document IDs, \"Page 3 of 20\", bare page numbers). Needs 3 or more pages. Recommended for RAG so chunks are not polluted.",
            "default": true
          },
          "ocr": {
            "title": "OCR scanned pages",
            "type": "boolean",
            "description": "Run OCR (Tesseract) on pages that have no text layer (scanned or image-only). Pages that already have text are never OCRed. Charged per OCR page (see Pricing). Needs at least 1024 MB memory; slower (several seconds per page). When off, scanned documents are reported in FAILED_DOCUMENTS as needs_ocr and are not charged.",
            "default": false
          },
          "ocrLanguage": {
            "title": "OCR language",
            "type": "string",
            "description": "Tesseract language code(s) of the scanned documents, joined with + for several. Examples: \"eng\", \"deu\", \"fra\", \"spa\", \"eng+deu\".",
            "default": "eng"
          },
          "ocrMaxPages": {
            "title": "Max OCR pages per document",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Upper limit of pages sent to OCR in one document, to keep time and cost predictable. Example: 5 to OCR only the first scanned pages.",
            "default": 20
          },
          "pdfPassword": {
            "title": "PDF password",
            "type": "string",
            "description": "Password used to open password-protected PDFs (applied to every PDF in the run that asks for one). PDFs that are only permission-protected (no password needed to open) are extracted without it."
          },
          "maxFileSizeMb": {
            "title": "Max file size (MB)",
            "minimum": 1,
            "maximum": 500,
            "type": "integer",
            "description": "Files larger than this are skipped (listed as too_large in FAILED_DOCUMENTS, not charged). Downloads are streamed and stopped as soon as the limit is passed.",
            "default": 50
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}