[Python] YouTube Data API v3 quota calculation - How the quota is calculated?

Discussão em 'Python' iniciado por Stack, Agosto 18, 2025.

  1. Stack

    Stack Membro Participativo

    The documentation says that .list() commands should cost 1 quota, but in my script I only use .list() commands. However, the consumed quota does not match the expected number.

    I tried with a simple version to check:

    import googleapiclient.discovery
    import time

    API_KEY = "some_key"
    VIDEO_ID = "some_video_id"

    try:
    youtube = googleapiclient.discovery.build("youtube", "v3", developerKey=API_KEY)

    # Chamada inicial
    video_request = youtube.videos().list(part="liveStreamingDetails", id=VIDEO_ID)
    video_response = video_request.execute()
    print("Call 1 - videos.list (2 quotas)")

    live_chat_id = video_response["items"][0]["liveStreamingDetails"]["activeLiveChatId"]

    for i in range(10): # Exemplo: 10 loops
    live_chat_request = youtube.liveChatMessages().list(
    liveChatId=live_chat_id,
    part="snippet,authorDetails"
    )
    live_chat_request.execute()
    print(f"Call {i+2} - liveChatMessages.list (1 quota)")
    time.sleep(5)

    except Exception as e:
    print(f"Error: {e}")


    I expected a cost of 12 quotas, but got 51. How can this be, if the cost should be 1 for each request? I just want some clarification of what is spending more then expected.

    Continue reading...

Compartilhe esta Página