Skip to content
anpulora.

Working with .session and .json

The .session file is the account's authorization for code: libraries such as Telethon connect with it without any login code. The .json next to it tells you which app and device the account was created with — use those values and the account will keep looking the same.

What the .json contains

The most important fields are app_id and app_hash (the API application the account belongs to), device, sdk and app_version (the device model, operating system and app version Telegram has seen so far), lang_pack and system_lang_pack (language settings) and twoFA — the same cloud password as in 2FA.txt. When you connect with different parameters, Telegram sees a new “device” on an existing authorization; that is exactly what you want to avoid.

Connecting with Telethon

The .session files we deliver are in Telethon's format (an SQLite file). A minimal example: read the .json, pass its values to the client, connect, check who you are and disconnect. If you work with Pyrogram or another library, convert the session with a tool you trust instead of logging in again.

import json
from telethon import TelegramClient

cfg = json.load(open("+573001234567.json", encoding="utf-8-sig")) client = TelegramClient( "+573001234567", # имя .session без расширения / file name without .session api_id=cfg["app_id"], api_hash=cfg["app_hash"], device_model=cfg.get("device"), system_version=cfg.get("sdk"), app_version=cfg.get("app_version"), system_lang_code=cfg.get("system_lang_pack", "en-US"), )

async def main(): await client.connect() me = await client.get_me() print(me.id, me.phone) await client.disconnect() # disconnect — not log_out()

client.loop.run_until_complete(main())

Rules that keep the account alive

  • Never call log_out() or terminate other sessions from code: it destroys the authorization that the files contain.
  • Use the .session or the tdata, not both at the same time — they are one key.
  • Keep one connection per account; do not run the same .session in two scripts.
  • Disconnect cleanly when the job is done.
  • Mass actions in the first day — joining dozens of groups, sending many messages, adding hundreds of contacts — are the fastest way to get a new account limited. Start slowly.

Proxies

Telethon accepts a proxy through the proxy argument. A stable address, ideally in the account's country, is a sensible choice; frequent changes of IP in the first hours are not. A proxy is not required for the account to work.

FAQ

The client asks for a phone number or code. Why?

The library did not find the .session file — check the name you pass (without the .session extension) and the working directory. If the file is found but not authorized, contact support within the 2-hour guarantee.

Can I use my own api_id?

Technically yes, but then Telegram sees the authorization coming from a different application. Using the values from the .json is the safer option.

Where is the 2FA password?

In 2FA.txt and in the twoFA field of the .json. You only need it when you log in to the account on a new device.

Need an account?

Checked before delivery, tdata + session + 2FA or login by code. 2-hour guarantee.