Skip to main content

messages.getHistory

Returns the message history in a peer. Results are ordered by date (descending).

func (c *Client) MessagesGetHistory(ctx context.Context, request *MessagesGetHistoryRequest) (MessagesMessagesClass, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.MessagesGetHistory(ctx, &tg.MessagesGetHistoryRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // MessagesMessagesClass
return nil
})

Parameters

NameTypeRequiredDescription
PeerInputPeerClassyesTarget peer
OffsetIDintyesOnly return messages starting from the specified message ID
OffsetDateintyesOnly return messages sent before the specified date
AddOffsetintyesNumber of list elements to be skipped, negative values are also accepted.
LimitintyesNumber of results to return
MaxIDintyesIf a positive value was transferred, the method will return only messages with IDs less than max_id
MinIDintyesIf a positive value was transferred, the method will return only messages with IDs more than min_id
Hashint64yesResult hash

Returns

MessagesMessagesClass

Possible errors

CodeTypeDescription
400CHANNEL_INVALIDThe provided channel is invalid.
406CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
400CHAT_ID_INVALIDThe provided chat id is invalid.
400CHAT_NOT_MODIFIEDNo changes were made to chat information because the new information you passed is identical to the current information.
400FROZEN_PARTICIPANT_MISSINGThe current account is frozen, and cannot access the specified peer.
400MSG_ID_INVALIDInvalid message ID provided.
500NEED_DOC_INVALID
400PEER_ID_INVALIDThe provided peer id is invalid.
400TAKEOUT_INVALIDThe specified takeout ID is invalid.
500VOLUME_MOVE_INVALID

References