{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/zh/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"速率限制","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"速率限制","__idx":0},"children":["速率限制"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["MoreLogin API 强制执行速率限制，以确保公平使用和系统稳定性。"]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"限制","__idx":1},"children":["限制"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"API类型"},"children":["API类型"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"速率限制"},"children":["速率限制"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"时间窗口"},"children":["时间窗口"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["本地API"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["120 个请求"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["每分钟"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["开放API"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["120 个请求"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["每分钟"]}]}]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"速率限制响应","__idx":2},"children":["速率限制响应"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["当您超过速率限制时，API 将返回："]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["HTTP 状态"]},"：",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["429 Too Many Requests"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"code\": 429,\n  \"msg\": \"Rate limit exceeded\",\n  \"data\": null,\n  \"requestId\": \"...\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"最佳实践","__idx":3},"children":["最佳实践"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"1-实施带退避的重试","__idx":4},"children":["1. 实施带退避的重试"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import time\nimport requests\n\ndef api_request_with_retry(url, payload, max_retries=3):\n    for attempt in range(max_retries):\n        response = requests.post(url, json=payload)\n        if response.status_code == 429:\n            wait_time = 2 ** attempt  # 1s, 2s, 4s\n            print(f\"Rate limited. Retrying in {wait_time}s...\")\n            time.sleep(wait_time)\n            continue\n        return response\n    raise Exception(\"Max retries exceeded\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"2-批量操作","__idx":5},"children":["2. 批量操作"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["不要进行单独的 API 调用，而是在可用时使用批处理端点："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"# Bad: 100 individual calls\nfor env_id in env_ids:\n    requests.post(f\"{BASE}/api/env/start\", json={\"envId\": env_id})\n\n# Good: Use batch endpoints\nrequests.post(f\"{BASE}/api/env/updateGroup/batch\", json={\n    \"envIds\": env_ids,\n    \"groupId\": \"target-group\"\n})\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"3-缓存响应","__idx":6},"children":["3. 缓存响应"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["对于不经常更改的数据（例如时区列表、平台列表），在本地缓存响应："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"# Cache timezone/language data — it rarely changes\ntimezone_data = requests.post(f\"{BASE}/api/env/advanced/timezone\").json()\n# Reuse timezone_data for subsequent profile creations\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"监控您的使用情况","__idx":7},"children":["监控您的使用情况"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["跟踪您的 API 调用频率。如果您始终接近极限，请考虑："]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["在每分钟内均匀分布请求"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["使用网络钩子（即将推出）而不是轮询"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["将多个操作组合成批量调用"]}]}]},"headings":[{"value":"速率限制","id":"速率限制","depth":1},{"value":"限制","id":"限制","depth":2},{"value":"速率限制响应","id":"速率限制响应","depth":2},{"value":"最佳实践","id":"最佳实践","depth":2},{"value":"1. 实施带退避的重试","id":"1-实施带退避的重试","depth":3},{"value":"2. 批量操作","id":"2-批量操作","depth":3},{"value":"3. 缓存响应","id":"3-缓存响应","depth":3},{"value":"监控您的使用情况","id":"监控您的使用情况","depth":2}],"frontmatter":{"seo":{"title":"速率限制"}},"lastModified":"2026-06-10T11:47:34.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/zh/api-reference/getting-started/rate-limits","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}