Prerequisites
- Python 3.8+
- A TeraBox API key — get one here from ₹1,999/month
pip install requests
Step 1 — Install the requests library
pip install requests
Step 2 — Make Your First API Call
The TeraBox API accepts a POST request with the TeraBox share URL in the body. Pass your API key in the X-API-Key header.
import requests
API_KEY = "tbx_your_api_key_here"
TERABOX_URL = "https://terabox.com/s/1LpQ_A-gXb5JSDhYmX9v2wA"
response = requests.post(
"https://api.teraboxdl.site/v1/api",
headers={"X-API-Key": API_KEY},
json={"url": TERABOX_URL},
timeout=10
)
data = response.json()
if data.get("ok"):
print("File name :", data["file_name"])
print("File size :", data["size"])
print("Download :", data["download_url"])
print("HLS stream :", data["stream_url"])
else:
print("Error:", data.get("error"))Step 3 — Parse the JSON Response
A successful response looks like this:
{
"ok": true,
"file_name": "sample-video.mp4",
"size": 524288000,
"download_url": "https://cdn.terabox.com/file/...?tk=...",
"stream_url": "https://cdn.terabox.com/hls/...m3u8",
"thumbnail": "https://cdn.terabox.com/thumb/..."
}Step 4 — Error Handling
import requests
from requests.exceptions import Timeout, ConnectionError
def get_terabox_link(share_url: str, api_key: str) -> dict:
try:
r = requests.post(
"https://api.teraboxdl.site/v1/api",
headers={"X-API-Key": api_key},
json={"url": share_url},
timeout=10
)
r.raise_for_status()
return r.json()
except Timeout:
return {"ok": False, "error": "Request timed out"}
except ConnectionError:
return {"ok": False, "error": "Connection failed"}
except requests.HTTPError as e:
if r.status_code == 429:
return {"ok": False, "error": "Daily quota exceeded — upgrade your plan"}
return {"ok": False, "error": str(e)}Using HLS Stream URLs
The stream_url field returns an m3u8 URL you can feed directly into any HLS-compatible player:
# With python-vlc import vlc player = vlc.MediaPlayer(data["stream_url"]) player.play() # Or pass to ffmpeg import subprocess subprocess.run(["ffmpeg", "-i", data["stream_url"], "output.mp4"])
Get Your TeraBox API Key
Plans start at ₹1,999/month. Instant activation. No setup fees.
View Pricing & Buy Now →