I want to write a program that gets the list of the latest chats that I had in telegram and their not in my contacts. I tried telethon but I couldn't do it for the users that are not in my contacts
If by "latest chats" you refer to "recent open conversations with other users, groups, or channels you've joined", then you're looking for client.iter_dialogs
:
# Print all dialog IDs and the title, nicely formatted
async for dialog in client.iter_dialogs():
print('{:>14}: {}'.format(dialog.id, dialog.title))