{
  "openapi": "3.0.1",
  "info": {
    "title": "Branch Coverage Drift Audit by Region and Category",
    "description": "Compare two dated branch-directory snapshots by region and category to find coverage gaps, missing branches and sampling drift.",
    "version": "0.1",
    "x-build-id": "uUn0OFcqqZknNguis"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/practical_ai_lab_jp~pal-maps-region-category-coverage-drift-audit/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-practical_ai_lab_jp-pal-maps-region-category-coverage-drift-audit",
        "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/practical_ai_lab_jp~pal-maps-region-category-coverage-drift-audit/runs": {
      "post": {
        "operationId": "runs-sync-practical_ai_lab_jp-pal-maps-region-category-coverage-drift-audit",
        "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/practical_ai_lab_jp~pal-maps-region-category-coverage-drift-audit/run-sync": {
      "post": {
        "operationId": "run-sync-practical_ai_lab_jp-pal-maps-region-category-coverage-drift-audit",
        "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": [
          "authorizationConfirmed",
          "baselineDate",
          "currentDate"
        ],
        "properties": {
          "authorizationConfirmed": {
            "title": "I am authorized to analyze both datasets",
            "type": "boolean",
            "description": "Confirm that both snapshots are your own or otherwise authorized business directory data. Nothing is scraped by this Actor.",
            "default": true
          },
          "baselineDate": {
            "title": "Baseline snapshot date",
            "type": "string",
            "description": "ISO date (YYYY-MM-DD) of the older snapshot.",
            "default": "2026-01-31"
          },
          "currentDate": {
            "title": "Current snapshot date",
            "type": "string",
            "description": "ISO date (YYYY-MM-DD) of the newer snapshot. Must be later than the baseline date.",
            "default": "2026-04-30"
          },
          "baselineRecords": {
            "title": "Baseline records (inline JSON)",
            "type": "array",
            "description": "Array of branch objects from the older snapshot. Use this or Baseline dataset ID."
          },
          "currentRecords": {
            "title": "Current records (inline JSON)",
            "type": "array",
            "description": "Array of branch objects from the newer snapshot. Use this or Current dataset ID."
          },
          "baselineDatasetId": {
            "title": "Baseline dataset ID (optional)",
            "type": "string",
            "description": "ID of an existing Apify dataset you own, used instead of inline baseline records."
          },
          "currentDatasetId": {
            "title": "Current dataset ID (optional)",
            "type": "string",
            "description": "ID of an existing Apify dataset you own, used instead of inline current records."
          },
          "maxRecordsPerSnapshot": {
            "title": "Max records per snapshot",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Upper bound on records read per snapshot (hard cap 50000) to keep memory low.",
            "default": 20000
          },
          "regionField": {
            "title": "Region field",
            "type": "string",
            "description": "Record key holding the region.",
            "default": "region"
          },
          "categoryField": {
            "title": "Category field",
            "type": "string",
            "description": "Record key holding the business category.",
            "default": "category"
          },
          "idField": {
            "title": "Branch ID field",
            "type": "string",
            "description": "Record key with a stable branch ID. If empty in a record, name plus address is used.",
            "default": "branchId"
          },
          "nameField": {
            "title": "Name field",
            "type": "string",
            "description": "Record key holding the branch name.",
            "default": "name"
          },
          "addressField": {
            "title": "Address field",
            "type": "string",
            "description": "Record key holding the branch address.",
            "default": "address"
          },
          "minBaselineSample": {
            "title": "Minimum baseline sample",
            "minimum": 1,
            "type": "integer",
            "description": "Cells or regions with fewer baseline branches are labelled low_sample and not flagged. The default of 10 is a heuristic; the sample input lowers it to 3 for demonstration.",
            "default": 3
          },
          "gapPercentThreshold": {
            "title": "Gap threshold (% of baseline missing)",
            "minimum": 1,
            "maximum": 100,
            "type": "number",
            "description": "A cell is a coverage gap when at least this share of its baseline branches is missing.",
            "default": 30
          },
          "minMissingBranches": {
            "title": "Minimum missing branches for a gap",
            "minimum": 1,
            "type": "integer",
            "description": "Absolute number of missing branches required in addition to the percentage threshold.",
            "default": 2
          },
          "shareShiftThresholdPoints": {
            "title": "Category share shift threshold (points)",
            "minimum": 1,
            "maximum": 100,
            "type": "number",
            "description": "Flags share_drift when a category's share within a region moves by at least this many percentage points.",
            "default": 10
          },
          "regionDriftThreshold": {
            "title": "Region category-mix shift threshold",
            "minimum": 0.01,
            "maximum": 1,
            "type": "number",
            "description": "Flags sampling_drift when the total variation distance between category mixes reaches this value (0.01 to 1).",
            "default": 0.15
          },
          "maxMissingBranchRows": {
            "title": "Max missing-branch rows",
            "minimum": 0,
            "maximum": 5000,
            "type": "integer",
            "description": "Caps the number of individual missing-branch rows written to the dataset.",
            "default": 500
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}