{
  "openapi": "3.0.1",
  "info": {
    "title": "AI Structured Data Extractor: URL to JSON",
    "description": "Turn web pages or text into structured JSON without selectors. Give URLs and the fields you want, a JSON Schema or a sentence. Get one validated row per page, or a list from listing pages. Numbers as numbers, missing as null. About $0.005 per page all in.",
    "version": "0.1",
    "x-build-id": "LdGDTqr0RIWPlvMNW"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/opstoolkit~ai-structured-extractor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-opstoolkit-ai-structured-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/opstoolkit~ai-structured-extractor/runs": {
      "post": {
        "operationId": "runs-sync-opstoolkit-ai-structured-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/opstoolkit~ai-structured-extractor/run-sync": {
      "post": {
        "operationId": "run-sync-opstoolkit-ai-structured-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",
        "properties": {
          "urls": {
            "title": "Page URLs",
            "type": "array",
            "description": "Pages to read, as a list of objects with a url key. Example: [{\"url\": \"https://example.com/product/42\"}]. Each page is fetched with a plain HTTP request after checking robots.txt. Pages that need a login or a browser come back as a free row that says why. Give at least one of urls, texts or datasetId. Up to 2,000 per run.",
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "texts": {
            "title": "Texts or HTML",
            "type": "array",
            "description": "Optional. Text, markdown or HTML you already have, one string per page. Example: [\"<h1>Acme Pro</h1><p>Price: $49</p>\"]. Nothing is fetched. Billed as 'text extracted'. Use this for pages that need a browser: render them elsewhere, then paste the HTML here.",
            "items": {
              "type": "string"
            }
          },
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "Optional. The ID of an Apify dataset whose rows hold the text, for example the output of Website to Markdown or Image and PDF OCR. Example: \"aBcDeFgHiJkLmNoPq\". Needs 'Field with the text' too. Rows read are capped by Max pages."
          },
          "field": {
            "title": "Field with the text",
            "type": "string",
            "description": "Name of the dataset field that holds the text, markdown or HTML. Example: markdown (Website to Markdown output) or text (OCR output). Required with datasetId, ignored otherwise. If the row also has a url field, it is copied to the output."
          },
          "fields": {
            "title": "Fields to extract",
            "type": "array",
            "description": "The fields you want back, one per item: a name, or name: type, with an optional hint after a dash. Types: string, number, integer, boolean, date, url, email, list. Example: [\"title\", \"price: number - price in GBP\", \"in_stock: boolean\"]. Ignored when you give a JSON Schema. If you give neither, write instructions and the model picks the keys.",
            "items": {
              "type": "string"
            }
          },
          "schema": {
            "title": "JSON Schema (optional)",
            "type": "object",
            "description": "A JSON Schema object, used instead of the field list when you need nested objects, enums or per-field descriptions. Example: {\"type\":\"object\",\"properties\":{\"title\":{\"type\":\"string\"},\"price\":{\"type\":\"number\"}},\"required\":[\"title\"]}. The model's answer is checked against it. Fields the page does not state come back as null, so 'required' means the key is present, not that the page had it."
          },
          "instructions": {
            "title": "Instructions",
            "type": "string",
            "description": "Optional plain English guidance for the model. Example: \"Only the main product, not the related ones. Prices in USD.\" With no fields and no schema, the model picks the keys from this text, so describe what you want, for example \"company name, founding year and headquarters city\"."
          },
          "mode": {
            "title": "One record or a list",
            "enum": [
              "single",
              "list"
            ],
            "type": "string",
            "description": "single: one record per page (product page, article, company page). list: a list of records from one page (category page, table, directory), returned as an items array in the row. Default: single.",
            "default": "single"
          },
          "model": {
            "title": "AI model",
            "enum": [
              "openai/gpt-4.1-nano",
              "google/gemini-3.1-flash-lite",
              "openai/gpt-5-mini"
            ],
            "type": "string",
            "description": "Model that reads the page, one of openai/gpt-4.1-nano (default, cheapest, fine for clearly labelled pages), google/gemini-3.1-flash-lite (messy pages), openai/gpt-5-mini (best accuracy). All run through Apify's AI proxy and the model cost is billed to your Apify account at cost. Replaced by customModel when that is set.",
            "default": "openai/gpt-4.1-nano"
          },
          "customModel": {
            "title": "Other OpenRouter model",
            "type": "string",
            "description": "Optional, advanced. Any model ID from openrouter.ai/models, for example x-ai/grok-4.3. It replaces the AI model choice above. Apify's proxy only allows models with zero data retention, so some IDs are refused and the run fails with a message. Leave empty to use the AI model setting."
          },
          "maxTokensPerPage": {
            "title": "Page size limit (tokens)",
            "minimum": 500,
            "maximum": 60000,
            "type": "integer",
            "description": "Longest page text sent to the model, in tokens (about 4 characters each). A whole number from 500 to 60000. Longer pages are cut here, the content after the cut is not read, and the row says so. Raise it for long pages, lower it to spend less. Default: 6000.",
            "default": 6000
          },
          "maxPages": {
            "title": "Max pages",
            "minimum": 1,
            "maximum": 2000,
            "type": "integer",
            "description": "Most URLs, texts and dataset rows read in this run. A whole number from 1 to 2000, for example 50. The rest are skipped, with a warning in the log. Default: 100.",
            "default": 100
          },
          "maxConcurrency": {
            "title": "Pages in parallel",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "How many pages are processed at the same time. A whole number from 1 to 20. Requests to one website are still spaced at least half a second apart. Default: 5.",
            "default": 5
          },
          "includeLinks": {
            "title": "Keep links in the page text",
            "type": "boolean",
            "description": "When true, link addresses stay in the page text so the model can return URLs (needed for url fields and detail links in list mode). Set false to send fewer tokens when you need no links. Default: true.",
            "default": true
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}