getFile
Gets file info for downloading.
Returns: On success, returns File.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file_id | String | Yes | File ID of the file |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/getFile" \
-H "Content-Type: application/json" \
-d '{"file_id":"FILE_ID"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/getFile",
json={
"file_id": "FILE_ID"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/getFile`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"file_id": "FILE_ID"
}),
});
console.log(await res.json());
Step-by-step guide: Telegram Bot API Limits: Rate Limits, 429 Errors, File Sizes and Message Length