Handling errors and plan limits in the DiskWala and TeraBox APIs
APIPANEL.IN developer guide · Updated November 2026
A production integration spends most of its error-handling code on a few cases: a bad token, an exhausted plan, a link that has no files and a temporary network failure. Each needs a different reaction, and retrying the wrong one wastes requests. This guide describes how the DiskWala API and the TeraBox API report each case.
How errors look
Successful calls return 200. Errors return a 4xx or 5xx status and, in most cases, a JSON body with a detail field describing the problem:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
{"detail": "API call limit exceeded"}
Decide what to do mainly from the status code, and log the detail text. The one case where the text matters is 429 on the TeraBox API (see below).
Status codes and what to do
| Status | Meaning | Retry? |
|---|---|---|
400 | The link is not one the service accepts, is broken, or has no files ("Invalid resource provided", "Invalid or unsupported URL domain", "Broken link or no files"). | No. Check the link. |
401 | Missing or invalid token. | No. Check the header and token. |
403 | Invalid token for this service, subscription expired or, on TeraBox, account suspended. | No. Check the token or renew the plan. |
404 | DiskWala API: "No downloadable files found for this link". | No. |
410 | A returned download or stream link has expired. | List the sharing link again for fresh links. |
429 | "API call limit exceeded": your plan's request limit is used up. TeraBox API only: "Rate limit exceeded, slow down" means too many requests in a short time. | Plan limit: no, renew or upgrade. Rate limit: yes, after a pause. |
5xx | A temporary problem in the API or with the file host (including 503 "try again"). | Yes, a few times with back-off. |
Request limits, bandwidth and plan periods
Each plan is a one-time payment that gives a fixed number of API requests for a fixed number of days. It does not renew automatically, so you are never charged again without buying a new plan. Some plans also include a bandwidth allowance for downloads. Three things follow from that:
- "API call limit exceeded" is about your plan, not a burst. Waiting does not help. Your code should stop sending requests for that service and alert you.
- Plans end on a date. When the period ends, requests fail with
403even if requests are left. Track the end date shown on your dashboard. - Services are separate. Running out on DiskWala does not affect TeraBox, and the reverse. Handle each service's errors on their own.
The dashboard shows remaining requests, bandwidth and the plan's end date for each service.
Retrying safely
Retry only what can succeed on a second try: network errors, timeouts, 5xx responses and the TeraBox rate-limit 429. Use exponential back-off with a cap so a short outage does not turn into a burst of requests.
import random
import time
import requests
RETRYABLE = {500, 502, 503, 504}
def call(session, url, params, attempts=4):
for i in range(attempts):
try:
r = session.get(url, params=params, timeout=60)
except (requests.ConnectionError, requests.Timeout):
r = None
slow_down = r is not None and r.status_code == 429 and "slow down" in r.text
if r is not None and r.status_code not in RETRYABLE and not slow_down:
return r # success, or an error that a retry will not fix
if i == attempts - 1:
break
time.sleep(min(30, 2 ** i) + random.random()) # 1s, 2s, 4s ... plus jitter
raise RuntimeError("API unavailable, try again later")
Then branch on the final status:
r = call(session, BASE + "/", {"url": link})
if r.status_code == 200:
files = r.json()
elif r.status_code in (400, 404):
raise RuntimeError(f"Link problem: {r.text[:200]}")
elif r.status_code in (401, 403):
raise RuntimeError("Token or plan problem: check the dashboard")
elif r.status_code == 429:
raise RuntimeError("Request limit reached: renew or upgrade the plan")
else:
raise RuntimeError(f"Request failed ({r.status_code}): {r.text[:200]}")
Timeouts and large files
- Always set a timeout. Listing a sharing link involves the file host, so allow tens of seconds rather than one or two.
- For downloads, stream the body to disk and set the timeout per read, not for the whole transfer: a 2 GB file legitimately takes minutes.
- If a download stops part-way, request the link again. If the link has expired, list the sharing link again first.
Avoid spending requests you do not need
- Cache the result of listing a sharing link for a short time instead of listing the same link for every user who asks.
- Do not call
/healthbefore each request; use it only for monitoring. - Validate links on your side first (the domain and the
surlparameter) so typing mistakes do not reach the API.
Still stuck? The API Playground shows the full request and response, which is usually the fastest way to see what is wrong. Signed-in customers can also open a support ticket from the dashboard.