Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
帳獸 API 頻率限制規則、回應標頭與超限處理
X-RateLimit-Limit
3600
X-RateLimit-Remaining
3597
X-RateLimit-Reset
1738915200
HTTP/1.1 200 OK Content-Type: application/json X-RateLimit-Limit: 3600 X-RateLimit-Remaining: 3597 X-RateLimit-Reset: 1738915200
429 Too Many Requests
{ "message": "Too Many Requests" }
Retry-After
HTTP/1.1 429 Too Many Requests Retry-After: 60 Content-Type: application/json
async function requestWithRetry(url, options, maxRetries = 3) { for (let attempt = 0; attempt < maxRetries; attempt++) { const response = await fetch(url, options); if (response.status === 429) { const retryAfter = parseInt(response.headers.get('Retry-After') || '60'); console.log(`頻率限制,等待 ${retryAfter} 秒後重試...`); await new Promise(resolve => setTimeout(resolve, retryAfter * 1000)); continue; } return response; } throw new Error('超過最大重試次數'); }
function requestWithRetry(string $url, array $data = [], int $maxRetries = 3) { for ($attempt = 0; $attempt < $maxRetries; $attempt++) { $response = Http::withToken(config('services.zangsho.token')) ->get($url, $data); if ($response->status() === 429) { $retryAfter = (int) $response->header('Retry-After', 60); Log::info("頻率限制,等待 {$retryAfter} 秒後重試..."); sleep($retryAfter); continue; } return $response; } throw new \RuntimeException('超過最大重試次數'); }
/customers/batch