-
Notifications
You must be signed in to change notification settings - Fork 171
API For Python Script
In the latest update of the python proxy installer script I added the API support. In this page we will learn how to use it and which commands can be executed as API.
Good question. Imagine you are writing a MTProto bot or website. You need to continuously add and revoke secrets. And you do not want to write a wrapper for it. In this case you can use the API that this scripts provides for you.
API calls are just running this script with specific arguments.
The script always return this result on any api call:
{
"ok":boolen,
"msg":object
}
With this method you can list all of the users and secrets.
bash MTProtoProxyInstall.sh list
{
"ok":true,
"msg":{
"User1" : "69c6a98d57c08c4e89084bf5b2897090",
"User2" : "9cd7c782a297a4e8668e82e0b4ff4f6d"
}
}
Note that the this is the base secret, that does not include the ee
for fake tls or dd
or the mask address.
Script will return this result if no secrets exist:
{
"ok":false,
"msg":"You have no secrets"
}
To get a secret run script with list <username>
argument.
For example if you want to get the secret of a user named user1, run script like this:
bash MTProtoProxyInstall.sh list user1
{
"ok":true,
"msg":"54ad29de7f1ba75d0338b21949b67a2c"
}
Note that the this is the base secret, that does not include the ee
for fake tls or dd
or the mask address.
The script will return an error if the username does not exists, or there are no secrets at all.
bash MTProtoProxyInstall.sh 4 <USERNAME> <SECRET>
If you do not pass the <SECRET>
then the script will generate a random secret for you.
{
"ok":true,
"msg":{
"link":"tg://proxy?server=ip&port=Port&secret=TheSecretInFakeTLSFormat",
"secret":"8564ca0eb7e9f973c2f465972fe4aa4e"
}
}
Note that the tg link is always in fake tls format.
This method returns an error message if the secret you provided is not a valid secret.
bash MTProtoProxyInstall.sh 5 <USERNAME>
{
"ok":true,
"msg":""
}
This method returns error if the username does not exists.
bash MTProtoProxyInstall.sh 6 <USERNAME> <LIMIT>
Where the limit is a the number of allowed users.
You either gotta remove the limits of a user or set/change limits of a user.
If you want to remove the limit, just omit the limit parameter when running the script. For example if you want to remove the limits of the user1
, run the script like this:
bash MTProtoProxyInstall.sh 6 user1
If you want to declare a limit, pass the number of allowed users to the script. For example if you want to limit the user2
, that only 3 people can connect to it, run the script like this:
bash MTProtoProxyInstall.sh 6 user2 3
{
"ok":true,
"msg":""
}
bash MTProtoProxyInstall.sh 7 <USERNAME> <DATE>
Date must be in format of dd/mm/yyyy
You can either remove the expiry date or set/change it.
To change the expiry date of the user u1
to 29/11/2020 run the script like this:
bash MTProtoProxyInstall.sh 7 u1 "29/11/2020"
To remove the expiry date of the user u2
run the script like this:
bash MTProtoProxyInstall.sh 7 u2
{
"ok":true,
"msg":""
}