Telegram Bot API
🌐 English

getFile

Category: Files · Bot API 10.3 · Official documentation

Gets file info for downloading.

Returns: On success, returns File.

Parameters

ParameterTypeRequiredDescription
file_idStringYesFile ID of the file

Parameter descriptions are concise summaries; see the official documentation for the full text.

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