{
  "openapi": "3.0.1",
  "info": {
    "title": "Q&A Knowledge Extractor (Stack Exchange)",
    "description": "Extracts RAG-ready Q&A pairs from the Stack Exchange network via the official API. Returns coupled question+answer records with full attribution, license metadata, and incremental diff support for growing datasets.",
    "version": "0.1",
    "x-build-id": "qjJYchNvXCakUinM5"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/datahoeven~qa-knowledge-extractor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-datahoeven-qa-knowledge-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/datahoeven~qa-knowledge-extractor/runs": {
      "post": {
        "operationId": "runs-sync-datahoeven-qa-knowledge-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/datahoeven~qa-knowledge-extractor/run-sync": {
      "post": {
        "operationId": "run-sync-datahoeven-qa-knowledge-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": {
          "site": {
            "title": "Stack Exchange site",
            "type": "string",
            "description": "The Stack Exchange network site to query. Use the site's subdomain (e.g. 'stackoverflow', 'serverfault', 'superuser', 'askubuntu'). Full list at stackexchange.com/sites.",
            "default": "stackoverflow"
          },
          "tags": {
            "title": "Tags (AND filter)",
            "type": "array",
            "description": "Only return Q&A pairs tagged with ALL of the specified tags. Leave empty to skip tag filtering.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "query": {
            "title": "Search query",
            "type": "string",
            "description": "Free-text search term (passed as 'q' to /search/advanced). Can be combined with tags.",
            "default": ""
          },
          "acceptedOnly": {
            "title": "Accepted answers only",
            "type": "boolean",
            "description": "When enabled, only questions with an accepted answer are returned. When disabled, questions without an accepted answer get their highest-scoring answer instead.",
            "default": true
          },
          "minQuestionScore": {
            "title": "Minimum question score",
            "minimum": 0,
            "type": "integer",
            "description": "Only return Q&A pairs where the question has at least this score (upvotes minus downvotes). Useful for filtering out low-quality content.",
            "default": 0
          },
          "minAnswerScore": {
            "title": "Minimum answer score",
            "minimum": 0,
            "type": "integer",
            "description": "Only return Q&A pairs where the linked answer has at least this score. Applied after fetching; answers below this threshold are excluded.",
            "default": 0
          },
          "sort": {
            "title": "Sort order",
            "enum": [
              "votes",
              "activity",
              "creation"
            ],
            "type": "string",
            "description": "Sort questions by votes (highest-scoring first), activity (most recently active first), or creation (newest first). Note: incremental mode always overrides this to 'activity'.",
            "default": "votes"
          },
          "fromDate": {
            "title": "From date (ISO 8601)",
            "pattern": "^(\\d{4}-\\d{2}-\\d{2})?$",
            "type": "string",
            "description": "Only return Q&A pairs with activity on or after this date (ISO 8601, e.g. '2024-01-01'). Ignored when 'incremental' is enabled — the stored high-water-mark is used instead.",
            "default": ""
          },
          "incremental": {
            "title": "Incremental mode",
            "type": "boolean",
            "description": "When enabled, each run stores a high-water-mark (the latest activity date seen). Subsequent runs only fetch Q&A pairs updated after that mark, so you only pay for new or changed content.",
            "default": true
          },
          "enableChunking": {
            "title": "Enable RAG chunking",
            "type": "boolean",
            "description": "When enabled, the combined Q&A text is split into overlapping chunks on natural boundaries (paragraphs, code blocks). Each record gets a 'chunks' array ready to embed. Code blocks are never split mid-block.",
            "default": false
          },
          "chunkSize": {
            "title": "Chunk size (characters)",
            "minimum": 100,
            "maximum": 8000,
            "type": "integer",
            "description": "Target chunk size in characters when RAG chunking is enabled. Actual chunks may be slightly larger to avoid splitting code blocks.",
            "default": 1200
          },
          "chunkOverlap": {
            "title": "Chunk overlap (characters)",
            "minimum": 0,
            "maximum": 1000,
            "type": "integer",
            "description": "Number of characters to overlap between consecutive chunks when RAG chunking is enabled. Helps preserve context across chunk boundaries.",
            "default": 100
          },
          "maxItems": {
            "title": "Max Q&A pairs",
            "minimum": 0,
            "type": "integer",
            "description": "Hard limit on the number of Q&A pairs returned per run. Set to 0 for no limit. Use this to control costs on large queries.",
            "default": 0
          },
          "apiKey": {
            "title": "Stack Exchange API key",
            "type": "string",
            "description": "Optional Stack Exchange application key. Without a key the daily quota is ~300 requests/IP; with a free key it rises to ~10,000/day. Register at stackapps.com."
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Apify proxy settings. Datacenter proxies are sufficient for the Stack Exchange API.",
            "default": {
              "useApifyProxy": 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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}