GramJS

photos.GetUserPhotos

Returns the list of user photos.

Example

const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.photos.GetUserPhotos({
      userId: "username",
      offset: 43,
      maxId: 0,
      limit: 100,
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.photos.Photos = await client.invoke(
    new Api.photos.GetUserPhotos({
      userId: "username",
      offset: 43,
      maxId: 0,
      limit: 100,
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
userIdInputUserUser ID
offsetintNumber of list elements to be skipped
maxIdlongIf a positive value was transferred, the method will return only photos with IDs less than the set one
limitintNumber of list elements to be returned

Result

photos.Photos

Possible errors

CodeTypeDescription
400MAX_ID_INVALIDThe provided max ID is invalid
400USER_ID_INVALIDThe provided user ID is invalid

Can bots use this method?

Yes