You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用YouTube API上传视频遇uploadLimitExceeded错误,配额未用尽原因排查

YouTube API触发uploadLimitExceeded错误的原因排查

问题场景

通过Node.js服务器+googleapis包、OAuth2认证调用YouTube API程序化上传视频,2024年7月3-4日多次返回uploadLimitExceeded错误,但账号每日API配额(220K)远未耗尽。

上传代码片段

const getAuth = async () => {
    const oAuth2Client = new google.auth.OAuth2(youtubeApiClientId, youtubeApiClientSecret, youtubeRedirectUrl);
    oAuth2Client.setCredentials({
        refresh_token: youtubeApiRefreshToken,
    });
    await oAuth2Client.refreshAccessToken();
    return oAuth2Client;
};

const uploadVideo = async ({ videoAsset, fileAccessToken }) => {
    const fileName = `recording_${videoAsset._id.toString()}.${videoAsset.zoomDetails.fileType}`;
    try {
        await downloadRecording(videoAsset.zoomDetails.downloadUrl, fileAccessToken, fileName);
        const auth = await getAuth();
        const service = google.youtube({ version: 'v3', auth });
        const params = {
            auth,
            part: 'snippet,status',
            requestBody: {
                snippet: {
                    title: getValidYoutubeTitle(videoAsset),
                    defaultLanguage: langCode,
                },
                status: {
                    privacyStatus: 'unlisted',
                },
            },
            media: {
                body: fs.createReadStream(fileName),
            },
        };
        const response = await service.videos.insert(params);
        return response;
    } catch (error) {
        // handle errors
    }
};

错误响应示例

{
    "error": {
        "code": 400,
        "message": "The user has exceeded the number of videos they may upload.",
        "errors": [
            {
                "message": "The user has exceeded the number of videos they may upload.",
                "domain": "youtube.video",
                "reason": "uploadLimitExceeded"
            }
        ]
    }
}

可能的触发原因

  • 独立于API配额的上传数量限制:YouTube对单个用户账号有每日上传视频数量上限,这个限制和220K的请求配额是完全独立的维度——哪怕请求次数没超,实际成功上传的视频数达标就会触发该错误。
  • 短时间高频上传触发速率限制:即使单日总上传数没到上限,若短时间内连续发起大量上传请求(比如几分钟内批量上传多个视频),YouTube的反滥用机制会触发临时速率限制,返回该错误。
  • 关联账号本身受限:如果OAuth2绑定的YouTube账号存在违规记录、上传历史异常(比如曾上传违规内容),可能被平台单独限制上传数量,和API配额无关。
  • 无效/失败请求被计入统计:若存在多次失败的上传请求(比如视频格式不合法但未被捕获),这类请求可能被YouTube计入上传次数统计,导致实际有效上传数未达标,但统计值触发了限制。
  • API参数或版本的隐性限制:当前使用的YouTube API v3可能存在特定场景下的限制逻辑,比如未正确设置视频必填属性(如描述、分类),导致请求被判定为无效,但错误提示被统一归类为上传超限。

内容的提问来源于stack exchange,提问作者fullstack

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 06:11:16