Skip to main content

AppInfo Settings

The AppInfo class configures your application’s identity and metadata when connecting to Telegram.

Overview

use danog\MadelineProto\Settings;
use danog\MadelineProto\API;

$settings = new Settings;
$settings->getAppInfo()
    ->setApiId(12345)
    ->setApiHash('0123456789abcdef0123456789abcdef');

$MadelineProto = new API('session.madeline', $settings);

Properties

apiId
int|null
Your API ID from my.telegram.org
apiHash
string|null
Your API hash from my.telegram.org
deviceModel
string
Device model (auto-detected from system)
systemVersion
string
System version (auto-detected from PHP)
appVersion
string
Application version (defaults to MadelineProto version)
langCode
string
default:"en"
Language code (ISO 639-1)
systemLangCode
string
default:"en"
System language code
langPack
string
default:""
Language pack name
showPrompt
bool
default:"true"
Whether to show prompt for API credentials if not provided

Methods

setApiId

Set your Telegram API ID.
apiId
int
required
API ID from my.telegram.org
return
self
Returns self for method chaining
$settings->getAppInfo()->setApiId(12345);

getApiId

Get the configured API ID.
return
int
The API ID
throws
Exception
If API ID is not set
$apiId = $settings->getAppInfo()->getApiId();

setApiHash

Set your Telegram API hash.
apiHash
string
required
API hash from my.telegram.org
return
self
Returns self for method chaining
$settings->getAppInfo()->setApiHash('0123456789abcdef0123456789abcdef');

getApiHash

Get the configured API hash.
return
string
The API hash
throws
Exception
If API hash is not set
$apiHash = $settings->getAppInfo()->getApiHash();

hasApiInfo

Check if API credentials are configured.
return
bool
True if both API ID and hash are set
if (!$settings->getAppInfo()->hasApiInfo()) {
    throw new Exception("Please configure API credentials");
}

setDeviceModel

Set device model identifier.
deviceModel
string
required
Device model name
return
self
Returns self for method chaining
$settings->getAppInfo()->setDeviceModel('Custom Device');

getDeviceModel

Get the device model.
return
string
Device model name
$device = $settings->getAppInfo()->getDeviceModel();

setSystemVersion

Set system version identifier.
systemVersion
string
required
System version
return
self
Returns self for method chaining
$settings->getAppInfo()->setSystemVersion('Ubuntu 22.04');

getSystemVersion

Get the system version.
return
string
System version
$version = $settings->getAppInfo()->getSystemVersion();

setAppVersion

Set application version.
appVersion
string
required
Application version
return
self
Returns self for method chaining
$settings->getAppInfo()->setAppVersion('1.0.0');

getAppVersion

Get the application version.
return
string
Application version
$version = $settings->getAppInfo()->getAppVersion();

setLangCode

Set language code.
langCode
string
required
ISO 639-1 language code (e.g., ‘en’, ‘it’, ‘ru’)
return
self
Returns self for method chaining
$settings->getAppInfo()->setLangCode('it');

getLangCode

Get the language code.
return
string
Language code
$lang = $settings->getAppInfo()->getLangCode();

setSystemLangCode

Set system language code.
langCode
string
required
System language code
return
self
Returns self for method chaining
$settings->getAppInfo()->setSystemLangCode('en');

getSystemLangCode

Get the system language code.
return
string
System language code
$sysLang = $settings->getAppInfo()->getSystemLangCode();

setLangPack

Set language pack name.
langPack
string
required
Language pack identifier
return
self
Returns self for method chaining
$settings->getAppInfo()->setLangPack('android');

getLangPack

Get the language pack.
return
string
Language pack name
$pack = $settings->getAppInfo()->getLangPack();

setShowPrompt

Set whether to show API credentials prompt.
showPrompt
bool
required
Whether to show prompt if credentials are missing
return
self
Returns self for method chaining
// Disable prompt - will throw exception if credentials missing
$settings->getAppInfo()->setShowPrompt(false);

getShowPrompt

Get whether the prompt is enabled.
return
bool
True if prompt is enabled
$shouldPrompt = $settings->getAppInfo()->getShowPrompt();

Complete Example

use danog\MadelineProto\Settings;
use danog\MadelineProto\API;

$settings = new Settings;

// Configure app info
$appInfo = $settings->getAppInfo();
$appInfo->setApiId(12345);
$appInfo->setApiHash('0123456789abcdef0123456789abcdef');
$appInfo->setDeviceModel('MyBot Server');
$appInfo->setSystemVersion('Linux 5.15');
$appInfo->setAppVersion('2.0.0');
$appInfo->setLangCode('en');

// Or use method chaining
$settings->getAppInfo()
    ->setApiId(12345)
    ->setApiHash('0123456789abcdef0123456789abcdef')
    ->setDeviceModel('MyBot Server')
    ->setSystemVersion('Linux 5.15')
    ->setAppVersion('2.0.0')
    ->setLangCode('en');

// Create API instance
$MadelineProto = new API('session.madeline', $settings);

Getting API Credentials

  1. Go to my.telegram.org
  2. Log in with your phone number
  3. Go to “API development tools”
  4. Create a new application (if you haven’t already)
  5. Copy your api_id and api_hash
Never share your API hash publicly or commit it to version control. Use environment variables:
$settings->getAppInfo()
    ->setApiId((int)getenv('TELEGRAM_API_ID'))
    ->setApiHash(getenv('TELEGRAM_API_HASH'));

Auto-Detection

Some properties are auto-detected:
  • Device Model: Detected via php_uname('s') (falls back to “Web server”)
  • System Version: Detected via php_uname('r') (falls back to PHP version)
  • Language: Detected from HTTP_ACCEPT_LANGUAGE or LANG environment variable

See Also

Build docs developers (and LLMs) love