{
  "openapi": "3.0.1",
  "info": {
    "title": "Viewstats YouTube Analytics & Rankings Scraper",
    "description": "Get YouTube channel analytics and global rankings from Viewstats.com. Extract exact views, subscribers, estimated revenue, and Shorts splits in 30+ flat columns. Processes in exactly 250ms per channel, saving 95% in execution cost. Works with Google Sheets.",
    "version": "0.3",
    "x-build-id": "EW6Vz2SBRAS6Xh1Xy"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/getascraper~viewstats-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-getascraper-viewstats-scraper",
        "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/getascraper~viewstats-scraper/runs": {
      "post": {
        "operationId": "runs-sync-getascraper-viewstats-scraper",
        "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/getascraper~viewstats-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-getascraper-viewstats-scraper",
        "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": {
          "channels": {
            "title": "Channels",
            "type": "array",
            "description": "Channel handles, Viewstats URLs, YouTube URLs, or stable UC channel IDs.",
            "items": {
              "type": "object",
              "properties": {
                "url": {
                  "title": "Channel URL",
                  "type": "string",
                  "description": "A Viewstats or YouTube channel URL."
                },
                "handle": {
                  "title": "Handle",
                  "type": "string",
                  "description": "A channel handle such as @mrbeast."
                },
                "channelId": {
                  "title": "Channel ID",
                  "type": "string",
                  "description": "A stable YouTube channel ID beginning with UC."
                },
                "inputId": {
                  "title": "Input ID",
                  "type": "string",
                  "description": "Optional stable ID used in output provenance."
                }
              },
              "additionalProperties": false
            },
            "default": []
          },
          "searchQueries": {
            "title": "Channel Search Queries",
            "type": "array",
            "description": "Search Viewstats channels by name or handle, then monitor the returned channels.",
            "items": {
              "type": "object",
              "properties": {
                "query": {
                  "title": "Query",
                  "type": "string",
                  "description": "Text sent to Viewstats channel search."
                },
                "maxResults": {
                  "title": "Max Results",
                  "type": "integer",
                  "description": "Maximum channels returned for this query.",
                  "minimum": 1,
                  "maximum": 100,
                  "default": 10
                },
                "inputId": {
                  "title": "Input ID",
                  "type": "string",
                  "description": "Optional stable ID for this discovery input."
                }
              },
              "required": [
                "query"
              ],
              "additionalProperties": false
            },
            "default": []
          },
          "startUrls": {
            "title": "Channel URLs",
            "type": "array",
            "description": "Backward-compatible list of Viewstats or YouTube channel URLs.",
            "default": [],
            "items": {
              "type": "object",
              "required": [
                "url"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "title": "URL of a web page",
                  "format": "uri"
                }
              }
            }
          },
          "handles": {
            "title": "Channel Handles",
            "type": "array",
            "description": "Backward-compatible list of handles such as @mrbeast.",
            "default": []
          },
          "monitorMode": {
            "title": "Monitor Mode",
            "enum": [
              "snapshot",
              "changes"
            ],
            "type": "string",
            "description": "Snapshot emits current rows. Changes emits changed, new, reappeared, and expired rows unless unchanged rows are enabled.",
            "default": "snapshot"
          },
          "stateKey": {
            "title": "State Key",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,79}$",
            "maxLength": 80,
            "type": "string",
            "description": "Explicit key for this monitor state. Reuse it on scheduled runs to compare snapshots.",
            "default": "default"
          },
          "includeUnchanged": {
            "title": "Include Unchanged",
            "type": "boolean",
            "description": "In changes mode, also emit rows whose tracked fields did not change.",
            "default": false
          },
          "includeProfileDetails": {
            "title": "Include Profile Details",
            "type": "boolean",
            "description": "Fetch Viewstats aboutMe fields such as description, creation date, country, and primary category when available.",
            "default": false
          },
          "includeSimilarChannels": {
            "title": "Include Similar Channels",
            "type": "boolean",
            "description": "Fetch Viewstats similarity results for each channel when a stable channel ID is returned.",
            "default": false
          },
          "timeSeries": {
            "title": "Time Series",
            "type": "object",
            "description": "Optionally fetch Viewstats channel history. The endpoint controls are passed through and unavailable points are omitted.",
            "properties": {
              "enabled": {
                "title": "Enabled",
                "type": "boolean",
                "description": "Set true to request the Viewstats stats endpoint.",
                "default": false
              },
              "range": {
                "title": "Range",
                "type": "string",
                "default": "alltime",
                "description": "Viewstats range value, for example alltime."
              },
              "groupBy": {
                "title": "Group By",
                "type": "string",
                "default": "daily",
                "description": "Viewstats grouping value, for example daily."
              },
              "sortOrder": {
                "title": "Source Sort Order",
                "type": "string",
                "description": "Ordering passed to Viewstats.",
                "enum": [
                  "ASC",
                  "DESC"
                ],
                "default": "ASC"
              },
              "withRevenue": {
                "title": "With Revenue",
                "type": "boolean",
                "description": "Request estimated revenue fields from Viewstats.",
                "default": true
              },
              "withEvents": {
                "title": "With Events",
                "type": "boolean",
                "description": "Request source event fields when available.",
                "default": false
              },
              "withBreakdown": {
                "title": "With Breakdown",
                "type": "boolean",
                "description": "Request source breakdown fields when available.",
                "default": false
              },
              "withToday": {
                "title": "With Today",
                "type": "boolean",
                "description": "Request the current partial day when available.",
                "default": false
              }
            },
            "default": {
              "enabled": false
            },
            "additionalProperties": false
          },
          "sortBy": {
            "title": "Sort By",
            "enum": [
              "globalSubscribersRanking",
              "globalViewsRanking",
              "subscriberCount",
              "viewCount",
              "videoCount",
              "channelName",
              "channelId"
            ],
            "type": "string",
            "description": "Primary deterministic result ordering and rank field assignment.",
            "default": "globalSubscribersRanking"
          },
          "sortOrder": {
            "title": "Sort Order",
            "enum": [
              "asc",
              "desc"
            ],
            "type": "string",
            "description": "Ascending or descending deterministic result order.",
            "default": "asc"
          },
          "maxConcurrency": {
            "title": "Max Concurrency",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "Maximum number of channel pages processed in parallel.",
            "default": 10
          },
          "maxRequestRetries": {
            "title": "Max Retries",
            "minimum": 0,
            "type": "integer",
            "description": "Crawler retries for requests that fail outside the explicit failure path.",
            "default": 3
          },
          "maxRequestsPerCrawl": {
            "title": "Max Channels",
            "minimum": 1,
            "type": "integer",
            "description": "Safety limit for channel requests in one run.",
            "default": 100000
          },
          "forceBrowserFallback": {
            "title": "Force Browser Fallback",
            "type": "boolean",
            "description": "Use the rendered-page fallback instead of the direct HTTP API.",
            "default": false
          },
          "proxyConfiguration": {
            "title": "Proxy Configuration",
            "type": "object",
            "description": "Optional Apify proxy settings for Viewstats requests.",
            "default": {
              "useApifyProxy": false
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}