DEV Community

SEO - NT Tech Innovation
SEO - NT Tech Innovation

Posted on AI-assisted

A Tiny YouTube Data API Script to Track Your Channel Toward Monetization

Small creators check YouTube Studio ten times a day and still can't tell if they're getting closer to the Partner Program. A script that logs one row per day gives a much calmer picture. Here is a minimal version using the public YouTube Data API v3.

What it records

  • Subscriber count (rounded by YouTube for public data)
  • Total channel views
  • Total video count

Watch hours are not in the public API. You still need Studio or the YouTube Analytics API (which needs OAuth) for those.

Setup

  • Create a Google Cloud project and enable "YouTube Data API v3".
  • Create an API key and restrict it to that API.
  • Find your channel ID in Studio under Settings, Channel, Advanced.

The script

import csv, datetime, os, requests

KEY = os.environ["YT_KEY"]
CHANNEL = os.environ["YT_CHANNEL"]

r = requests.get(
    "https://www.googleapis.com/youtube/v3/channels",
    params={"part": "statistics", "id": CHANNEL, "key": KEY},
    timeout=20,
).json()
stats = r["items"][0]["statistics"]

row = [datetime.date.today().isoformat(), stats.get("subscriberCount"), stats["viewCount"], stats["videoCount"]]
new = not os.path.exists("channel_log.csv")
with open("channel_log.csv", "a", newline="") as f:
    w = csv.writer(f)
    if new:
        w.writerow(["date", "subscribers", "views", "videos"])
    w.writerow(row)
print(row)
Enter fullscreen mode Exit fullscreen mode

Run it once a day with cron. One API call per day is far below the free quota.

Reading the log

  • Look at the 7-day change, not daily noise.
  • Mark the dates you uploaded. You will see which uploads moved subscribers.
  • If subscribers are hidden on your channel, the API will not return the count.

The Philippine angle

I wrote this for Filipino creators working toward YPP, since payout and eligibility questions come up constantly. The current thresholds, peso earning ranges and policy dates are covered in this YouTube monetization Philippines guide from BoostingPH.

Written by MD Fozla Rabbi, SEO Specialist.

Top comments (0)