The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Downloading Channel Media

Introduction

This vignette shows how to download media (photos/videos/documents) from a Telegram channel using download_channel_media().

Offline Demo (No Telegram Connection)

To keep this vignette fully reproducible, the output below is generated from a small bundled sample dataset. The commands shown are real; if you have credentials and a live session, you can run them by setting eval=TRUE in your environment.

Setup and Authentication

library(telegramR)
library(dplyr)

# Replace these with your own API ID and Hash
api_id <- 123456
api_hash <- "0123456789abcdef0123456789abcdef"

client <- TelegramClient$new("my_session", api_id, api_hash)
client$start()

Download Media

# Download media into ./downloads
media <- download_channel_media(
  client,
  "telegram",
  limit = 200,
  media_types = c("photo", "video"),
  start_date = "2025-01-01",
  end_date = "2025-02-01",
  out_dir = tempdir()
)
# Inspect results
media
#> # A tibble: 2 × 9
#>   message_id channel_id channel_username channel_title date               
#>        <dbl>      <dbl> <chr>            <chr>         <dttm>             
#> 1      28508 1149277960 ShrikeNews       Шрайк Ньюс    2026-03-06 11:22:24
#> 2      28495 1149277960 ShrikeNews       Шрайк Ньюс    2026-03-06 08:48:16
#> # ℹ 4 more variables: media_type <chr>, file_path <chr>,
#> #   original_filename <chr>, error <chr>
photo_path <- media %>% 
  filter(media_type == "photo") %>% 
  slice(1) %>% 
  pull(file_path)

# In a real session with downloaded files, display the photo:
# knitr::include_graphics(file.path("..", photo_path))
cat("Photo path:", photo_path, "\n")
#> Photo path: NA
cat("(Photo display omitted in offline demo — run with eval=TRUE and real credentials to download.)\n")
#> (Photo display omitted in offline demo — run with eval=TRUE and real credentials to download.)

Common Columns

The result is a tibble with one row per downloaded media item. Typical columns include:

Tips

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.