English
English
Appearance
English
English
Appearance
/public/account/telegram/sessionReturns the current state of a Telegram session, including the latest QR code. Call it repeatedly (every 2 to 5 seconds works well) after Create Session Telegram: show qrcode to the user while isConnected is false, ask for the password when isPasswordRequired turns true, and move on once isConnected is true.
Authorization: Basic Base64(AccessKey:SecretKey))| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Session token returned by Create Session Telegram. |
curl -X GET "https://api.repliz.com/public/account/telegram/session?token=a2ee814b0a49d6a55d07a73db97578387e1cb226e16f88715459c4935d0a0edfb5ead48bf964931758db4f476738766fc98bf0181672039791e2b92e1e77347c86fc5cab9f8051a3a8ebbdde7db3dee9" \
-H "Authorization: Basic $(echo -n 'YOUR_ACCESS_KEY:YOUR_SECRET_KEY' | base64)"import axios from 'axios';
const response = await axios.get(
'https://api.repliz.com/public/account/telegram/session',
{
params: {
token:
'a2ee814b0a49d6a55d07a73db97578387e1cb226e16f88715459c4935d0a0edfb5ead48bf964931758db4f476738766fc98bf0181672039791e2b92e1e77347c86fc5cab9f8051a3a8ebbdde7db3dee9',
},
auth: {
username: 'YOUR_ACCESS_KEY',
password: 'YOUR_SECRET_KEY',
},
},
);
console.log(response.data);const credentials = btoa('YOUR_ACCESS_KEY:YOUR_SECRET_KEY');
const response = await fetch(
'https://api.repliz.com/public/account/telegram/session?token=a2ee814b0a49d6a55d07a73db97578387e1cb226e16f88715459c4935d0a0edfb5ead48bf964931758db4f476738766fc98bf0181672039791e2b92e1e77347c86fc5cab9f8051a3a8ebbdde7db3dee9',
{
headers: {
Authorization: `Basic ${credentials}`,
},
},
);
const data = await response.json();
console.log(data);{
"id": "6a38d93d824af0f1182e7486",
"generatedId": "",
"name": "",
"username": "",
"phone": "",
"sessionId": "533e6fca-8c88-48c0-86c2-438d43fbc986",
"isConnected": false,
"qrcode": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAABlBMVEX///8AAABVwtN+AAAE/UlEQVR42uyZMY61OhKFy3LgDG8A4W0QIHlLhGR2RsiWLBGwDSM2YDIHls+o4L9vWpNemmDeb6l1peaTmq6yT53jS3/Xv2sJoFKvO6Km7XWUngySKHRGC4RngEANqaWzWUSFOkyIKpngqO352TvAiqZViymkjw1VzgLwlaam7d3+HGCyFvBnpJEsKlm/F9LxXaDtKUoks3nA80uaQKl9DgjUcINXANsSJXRUaV99Qz968dsAUNt+3Ne5...",
"isPasswordRequired": false,
"passwordHint": "",
"picture": ""
}{
"id": "6a38d93d824af0f1182e7486",
"generatedId": "",
"name": "",
"username": "",
"phone": "",
"sessionId": "533e6fca-8c88-48c0-86c2-438d43fbc986",
"isConnected": false,
"qrcode": "",
"isPasswordRequired": true,
"passwordHint": "Repliz",
"picture": ""
}{
"id": "6a38d93d824af0f1182e7486",
"generatedId": "5123456789",
"name": "Repliz",
"username": "repliz",
"phone": "6281234567890",
"sessionId": "533e6fca-8c88-48c0-86c2-438d43fbc986",
"isConnected": true,
"qrcode": "",
"isPasswordRequired": false,
"passwordHint": "",
"picture": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..."
}{
"code": 404,
"message": "session not found"
}{
"code": 401,
"message": "unauthorized"
}| Field | Type | Description |
|---|---|---|
isConnected | boolean | true once the login is complete. Stop polling and send the token to Connect Telegram, or to Reconnect Telegram for an existing account. |
qrcode | string | The current QR code as a base64-encoded PNG, without a data: prefix. Empty right after the session is created, while the password is required, and after the login. |
isPasswordRequired | boolean | true after the scan when the account has Two-Step Verification. Ask the user for the password and send it to Password Session Telegram, then keep polling. |
passwordHint | string | The password hint the user set in Telegram, to show next to the password field. Empty when there is none. |
generatedId | string | Telegram user ID of the account that logged in. Empty until the login is complete. |
name | string | Display name of that account. Empty until the login is complete. |
username | string | Telegram username of that account, without @. Empty until the login is complete, and stays empty if the account has no username. |
phone | string | Phone number of that account. Empty until the login is complete. |
picture | string | Profile photo of that account as a data: URI. Empty until the login is complete, and stays empty if the account has no photo. |
id | string | Internal session identifier. You don't need it; use token for every call. |
sessionId | string | Internal session identifier. You don't need it; use token for every call. |
To display the QR code, prefix the value with data:image/png;base64, and use it as an image source:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDol..." alt="Scan with Telegram" />The user scans it in the Telegram app under Settings → Devices → Link Desktop Device.
The QR code keeps changing
Telegram replaces the QR code about every 30 seconds, so update the image on every poll instead of showing the first code. If nobody scans it within about three minutes, the session is deleted and this endpoint returns 404 session not found. Create a new session to show a fresh code.