{
  "openapi": "3.0.1",
  "info": {
    "title": "Document to JSON Extractor (Arabic and English)",
    "description": "PDF, DOCX, image or plain text in, structured JSON out, with the page and paragraph anchor for every value so a person can verify it. Arabic and English: Hijri dates, Arabic-Indic digits, right to left order and Arabic clause numbering all handled. Pass a JSON Schema to get exactly your fields.",
    "version": "0.1",
    "x-build-id": "5zONxG2iD4QnlMAev"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/omargnagy~document-to-json-extractor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-omargnagy-document-to-json-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/omargnagy~document-to-json-extractor/runs": {
      "post": {
        "operationId": "runs-sync-omargnagy-document-to-json-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/omargnagy~document-to-json-extractor/run-sync": {
      "post": {
        "operationId": "run-sync-omargnagy-document-to-json-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": [
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "Mode",
            "enum": [
              "analyze",
              "extract"
            ],
            "type": "string",
            "description": "analyze = return the normalised text, paragraph anchors, language mix and clause segmentation. extract = return exactly the fields named in your JSON Schema, each with an anchor. Any other value is refused.",
            "default": "analyze"
          },
          "sample": {
            "title": "Bundled sample",
            "enum": [
              "none",
              "english-services-agreement",
              "arabic-services-agreement",
              "english-invoice-scan"
            ],
            "type": "string",
            "description": "Run against a document bundled inside this actor, which needs no URL and no upload. Choose 'No bundled sample' when you supply your own document below. Exactly one document source must be given, so leave this on 'No bundled sample' if you set documentUrl, keyValueStoreRecordKey, documentText or documentBase64.",
            "default": "none"
          },
          "documentUrl": {
            "title": "Document URL",
            "type": "string",
            "description": "Direct http or https link to a PDF, DOCX, image or text file. Required when you are not using a bundled sample, a key-value store record, inline text or base64. A key-value store record URL is an ordinary URL and works here."
          },
          "keyValueStoreRecordKey": {
            "title": "Key-value store record key",
            "type": "string",
            "description": "Key of a record in this run's own default key-value store, for a file you uploaded to the run. Required when you are not using a bundled sample, a URL, inline text or base64. To read a record in a different store, pass its record URL as documentUrl instead, because this actor runs with limited permissions and does not read other stores."
          },
          "documentText": {
            "title": "Inline text",
            "type": "string",
            "description": "Paste the document text directly. Useful for a quick test and for text you already extracted elsewhere. Required when you are not using a bundled sample, a URL, a record key or base64."
          },
          "documentBase64": {
            "title": "Base64 file",
            "type": "string",
            "description": "The document itself, base64 encoded, for callers that hold the bytes and have nowhere to host them. Required when you are not using a bundled sample, a URL, a record key or inline text."
          },
          "fileName": {
            "title": "File name",
            "type": "string",
            "description": "Optional. Helps format detection when the source carries no name, for example with base64 input. The bytes are trusted first, so this only matters for an ambiguous file."
          },
          "schema": {
            "title": "JSON Schema of the fields to extract",
            "type": "object",
            "description": "Required when mode is extract, and ignored when mode is analyze. A JSON Schema object whose properties name the fields you want. Supported property types are string, number, integer, boolean and array of string. Two optional extensions per property: x-keywords is a list of extra terms to look for in either script, and x-pattern is a regular expression whose first capture group becomes the value. Nested objects are refused rather than answered with nulls."
          },
          "ocr": {
            "title": "Read images with OCR",
            "type": "boolean",
            "description": "When on, an image input is read with the bundled Tesseract data. When off, an image input is refused instead of returning nothing. This has no effect on PDF, DOCX or text input, and scanned PDF pages are never rasterised.",
            "default": true
          },
          "ocrLanguages": {
            "title": "OCR languages",
            "type": "array",
            "description": "Which bundled language models OCR uses. Only eng and ara are bundled, and any other value is refused. Used only when the input is an image.",
            "default": [
              "eng",
              "ara"
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}