{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/vi/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Giới hạn tỷ lệ","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":"giới-hạn-tỷ-lệ","__idx":0},"children":["Giới hạn tỷ lệ"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["API MoreLogin thực thi các giới hạn tốc độ để đảm bảo mức sử dụng hợp lý và độ ổn định của hệ thống."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"giới-hạn","__idx":1},"children":["Giới hạn"]},{"$$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":"Loại API"},"children":["Loại API"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Giới hạn tỷ lệ"},"children":["Giới hạn tỷ lệ"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Cửa sổ"},"children":["Cửa sổ"]}]}]},{"$$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 cục bộ"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["120 yêu cầu"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["mỗi phút"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API mở"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["120 yêu cầu"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["mỗi phút"]}]}]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"phản-hồi-giới-hạn-tỷ-lệ","__idx":2},"children":["Phản hồi giới hạn tỷ lệ"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Khi bạn vượt quá giới hạn tốc độ, API sẽ trả về:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Trạng thái 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":"thực-tiễn-tốt-nhất","__idx":3},"children":["Thực tiễn tốt nhất"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"1-triển-khai-thử-lại-với-backoff","__idx":4},"children":["1. Triển khai Thử lại với Backoff"]},{"$$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-hoạt-động-hàng-loạt","__idx":5},"children":["2. Hoạt động hàng loạt"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Thay vì thực hiện các lệnh gọi API riêng lẻ, hãy sử dụng điểm cuối hàng loạt khi có sẵn:"]},{"$$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-phản-hồi-bộ-đệm","__idx":6},"children":["3. Phản hồi bộ đệm"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Đối với dữ liệu không thay đổi thường xuyên (ví dụ: danh sách múi giờ, danh sách nền tảng), hãy lưu trữ phản hồi cục bộ:"]},{"$$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":"giám-sát-việc-sử-dụng-của-bạn","__idx":7},"children":["Giám sát việc sử dụng của bạn"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Theo dõi tần suất lệnh gọi API của bạn. Nếu bạn liên tục đạt đến giới hạn, hãy cân nhắc:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Trải đều các yêu cầu trong từng phút"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Sử dụng webhooks (sắp ra mắt) thay vì bỏ phiếu"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Kết hợp nhiều thao tác thành các cuộc gọi hàng loạt"]}]}]},"headings":[{"value":"Giới hạn tỷ lệ","id":"giới-hạn-tỷ-lệ","depth":1},{"value":"Giới hạn","id":"giới-hạn","depth":2},{"value":"Phản hồi giới hạn tỷ lệ","id":"phản-hồi-giới-hạn-tỷ-lệ","depth":2},{"value":"Thực tiễn tốt nhất","id":"thực-tiễn-tốt-nhất","depth":2},{"value":"1. Triển khai Thử lại với Backoff","id":"1-triển-khai-thử-lại-với-backoff","depth":3},{"value":"2. Hoạt động hàng loạt","id":"2-hoạt-động-hàng-loạt","depth":3},{"value":"3. Phản hồi bộ đệm","id":"3-phản-hồi-bộ-đệm","depth":3},{"value":"Giám sát việc sử dụng của bạn","id":"giám-sát-việc-sử-dụng-của-bạn","depth":2}],"frontmatter":{"seo":{"title":"Giới hạn tỷ lệ"}},"lastModified":"2026-06-10T11:47:34.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/vi/api-reference/getting-started/rate-limits","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}