Skip to content

Latest commit

 

History

History
398 lines (226 loc) · 23.9 KB

File metadata and controls

398 lines (226 loc) · 23.9 KB

aaPanel Linux Panel API Documentation

Foreword

Through the aaPanel API, you can fully control all the functions of the aaPanel Linux panel. In fact, all the functions used after the user logs in to the panel are also docked through the same interface, which means that if you are familiar with the browser debugger, you can easily Complete a third-party front-end docking against the operational parameters of the aaPanel Linux panel.

Signature algorithm

api_sk $\mathbf { \tau } = \mathbf { \tau }$ Interface key (obtained in the panel settings page - API interface) request_time $\mathbf { \tau } = \mathbf { \tau }$ Uinx timestamp of current request time ( php: time() / python: time.time() ) request_token $\mathbf { \tau } = \mathbf { \tau }$ md5(string(request_time) $^ +$ md5(api_sk)) PHP Example: $request_token $\mathbf { \tau } = \mathbf { \tau }$ md5($request_time . ‘’ . md5($api_sk))

signature:

Parameter nameParameter valueDescription
request_timeCurrentuinx timestamp[Must]
request_tokenmd5(string(request_time)+md5(api_sk))[Must]
Other parametersOther parameters required by the functional interface [Optional]

Precautions:

  1. Please use the POST method to request the API interface.
  2. In order to ensure the efficiency of the request, please save the cookie and attach a cookie on each request.
  3. For panel security considerations, be sure to add an IP whitelist
  4. All response content is unified into Json data format

DEMO download

PHP-Demo: https://www.bt.cn/api_demo_php.zip

System status related interface

Get system basic statistics

URI address:/system?action $\mid =$ GetSystemTotal

Incoming parameters:No

Response:

FieldField value exampleDescription
systemCentOS Linux 7.5.1804 (Core)Operating system information
version6.8.2Panel version
time0天23小时45分钟The time since the last boot to the present
cpuNum2CPU core number
cpuRealUsed2.01CPU usage (percentage)
memTotal1024Physical memory capacity (MB)
memRealUsed300Used physical memory (MB)
memFree724Available physical memory (MB)
memCached700Cached memory (MB)
memBuffers100System buffer (MB)

Response content example:

"cpuRealUsed": 0.85,
"memTotal": 1741,
"system": "CentOS Linux 7.5.1804 (Core)",
"memRealUsed": 691,
"cpuNum": 6,
"memFree": 189,
"version": "6.8.1",
"time": "0\u592923\u5c0f\u65f657\u5206\u949f",
"memCached": 722,
"memBuffers": 139,
"isuser": 0

Get disk partition information

URI address:/system?action $\mid =$ GetDiskInfo

Incoming parameters:No

Response:

FieldField value exampleDescription
[].path/Partition mount point
[].inodes["8675328","148216","8527112", "2%"]Partition Inode Usage Information [Total, Used,Available, Usage]
[].size["8.3G","4.0G", "4.3G", "49%"]Partition capacity usage information [total, used,available, usage]

Response content example:

[ {"path": "/", "inodes": ["8675328", "148216", "8527112", "2%"], "size": ["8.3G", "4.0G", "4.3G", "49%"]

},
{ "path": "/www", "inodes": ["655360", "295093", "360267", "46%"], "size": ["9.8G", "3.7G", "5.6G", "40%"]
}

Get real-time status information (CPU, memory, network, load)

URI address:/system?action $\mid =$ GetNetWork

Incoming parameters:NoResponse:

FieldField value exampleDescription
downTotal446326699Total reception (number of bytes)
upTotal77630707Total transmission (number of bytes)
downPackets1519428Total collection (a)
upPackets175326Total delivery (a)
down36.22Downstream traffic (KB)
up72.81Upstream traffic (KB)
cpu[1.87, 6]CPU real-time information [usage rate, core number]
mem{memFree:189,memTotal: 1741,memCached: 722,memBuffers:139,memRealUsed: 691}Memory real-time information
load{max: 12, safe: 9,one:0, five: 0.01, limit: 12, fifteen: 0.05}Load real-time information one: 1 minute five:5 minutes fifteen:10 minutes

Response content example:
{ "load": {"max": 12, "safe": 9.0, "one": 0.01, "five": 0.02, "limit": 12, "fifteen": 0.05}, "down": 8.77, "downTotal": 453078627, "mem": {"memFree": 189, "memTotal": 1741, "memCached": 722, "memBuffers": 140, "memRealUsed": 690}, "up": 4.33, "upTotal": 78070942, "upPackets": 177930, "downPackets": 1548192, "cpu": [0.23, 6]
}

Check for installation tasks

URI address:/ajax?action=GetTaskCount
传入参数:无
Incoming parameters:No
Response:0

Check panel update

URI address:/ajax?action $\mathbf { \tau } =$ UpdatePanel

ParameternameParameter valueDescription
checktrueForce check for updates[Optional]
forcetruePerform an update [Optional]

Response content:

Field Field value exampleDescription
statustrueGet state true|false
version6.3.1Latest version number
updateMsgstringUpgrade Instructions

Response content example:
{ "status": true, "version": "6.3.1", "updateMsg": "Upgrade Instructions"
}

Website management

Get a list of websites

URI address:/data?action $\mid =$ getData&table $\mathrel { \mathop : } =$ sites

Parameter nameParameter valueDescription
p1Current page [optional]
limit15Number of rows retrieved [must pass]
type-1Classification ID,-1: Sub-category O: Default classification [Optional]
orderid descSorting rules Use id descending order: id desc Use name ascending order: name desc [Optional]
tojsget_site_listPaginated JS callback, if not passed,construct URl paging connection [Optional]
searchwwwSearch content [optional]

Response content:

FieldField value exampleDescription
dataSite list data
pagePaging data
wheretype_id=0Data query condition

Response content example:
{ "data": [ {

"status": "1", "ps": "bbb.com", "domain": 1, "name": "bbb.com", "addtime": "2018-12-14 16:14:03", "path": "/www/wwwroot/bbb.com", "backup_count": 0, "edate": "0000-00-00", "id": 64 } ], "where": "type_id=0", "page": "

<span class $\mathrel { \mathop : }$ Pcurrent'>1\u51711\u6761\u6570\u636e
" }

Get website classification

URI address:/site?action=get_site_types
Incoming parameters: empty
Response content example:
[ {"id": 0, "name": "\u9ed8\u8ba4\u5206\u7c7b"}
]

Get a list of installed PHP versions

URI address:/site?action=GetPHPVersion
Incoming parameters: empty
Response content example:
[ {"version": "00", "name": "\u7eaf\u9759\u6001"}, {"version": "56", "name": "PHP-56"}, {"version": "72", "name": "PHP-72"}
]

Create a website

URI address:/site?action=AddSite

Parameter nameParameter valueDescription
webname{"domain":"w1.hao.com","domainlist":[],"count":0}Website main domain name and domain name list Please pass JSON [Must]
path/www/wwwroot/w1.hao.comRoot directory [Must]
type_id0Classification mark[Must]
typePHPProject type Please pass PHP [Must]
version72PHP version Please select from the PHP version list [Must]
port80Website port [Must]
pstestWebsite Remarks [Must]
ftptrue|falseWhether to create FTP[Must]
ftp_usernamew1_hao_comFTP username must be passed when you want to create FTP
ftp_passwordWCBZ6cH87raERzXcFTP password must be passed when you want to create FTP
sql codeingtrue|false utf8|utf8mb4|gbk|big5Whether to createa database [Must] Database character set must pass when you want to create a database
datauserw1_hao_comDatabase username and name must be passed when you want to create a database
datapasswordPdbNjJy5hBA346ARDatabase password must be passed when you want to create a database

Response content:

FieldField value exampleDescription
siteStatustrue|falseWhether the website was created successfully
ftpStatustrue|falseWhether FTP is successfully created
ftpUserw2_hao_comFTP username
ftpPasssRxmY6xCn6zEsFtGFTP password
databaseStatustrue |falseWhether the database was created successfully
databaseUserw2_hao_comDatabase username and name
databasePassPdbNjJy5hBA346ARDatabase password

Response content example: {

"ftpStatus": true,
"databaseUser": "w2_hao_com",
"databaseStatus": true,
"ftpUser": "w2_hao_com",
"databasePass": "PdbNjJy5hBA346AR",
"siteStatus": true,
"ftpPass": "sRxmY6xCn6zEsFtG"

Delete website

URI address:/site?action $\mid =$ DeleteSite

Parameter nameParameter valueDescription
id66Website ID [Must]
webnamew2_hao_comSite name [Must]
ftp1Whether to delete the associated FTP,if you do not delete, please do not pass this parameter [Optional]
database1Whether to delete the associated database, if you do not delete, please do not pass this parameter [Optional]
path1Whether to delete the website root directory, if you do not delete,please do not pass this parameter [Optional]

Response content:

FieldField value exampleDescription
statustrue|falseWhether the operation is successful
msgsuccessfully deleted!Prompt content

Response content example:
{ "status": true, "msg": "\u7ad9\u70b9\u5220\u9664\u6210\u529f!"
}

Stop website

URI address:/site?action=SiteStop

Parameter name Parameter valueDescription
id66Website ID [Must]
namew2.hao.comWebsite name (main domain) [Must]

Response content example:
{ "status": true, "msg": "\u7ad9\u70b9\u5220\u9664\u6210\u529f!"
}

Start website

URI address:/site?action $\vDash$ SiteStart

Parameter nameParameter valueDescription
id66Website ID [Must]
namew2.hao.comWebsite name (main domain) [Must]

Response content example:
{ "status": true, "msg": "\u7ad9\u70b9\u5df2\u542f\u7528"
}

Website expiration time

URI 地址:/site?action=SetEdate

Parameter name Parameter valueDescription
id66Website ID[Must]
edate2019-01-01Expiration time Permanent: 0000-00-00 [Must]

Response content example:
{ "status": true, "msg": "\u7ad9\u70b9\u5df2\u542f\u7528"
}

Modify website notes

URI address:/data?action $\mid =$ setPs&table=sites

Parametername Parameter valueDescription
id66Website ID [Must]
pstestRemarks [Must]

Response content example:
{ "status": true, "msg": "\u4fee\u6539\u6210\u529f"
}

Get a list of website backups

URI address:/data?action $\mid =$ getData&table=backup

Parameter nameParameter valueDescription
p1Current page [Optional]
limit5The number of data rows retrieved per page [Must]
type0Backup type, please pass O fixed [Must]
tojsget_site_backup Paginated JS callback,if not passed, construct URl paging connection [Optional]
search66Website ID [Must]

Response content:

Parameter nameParameter valueDescription
dataBackup list data
pagePaging data
wheretype_id=0Data query condition

Response content example:

1 "data": [], "where": "pid $\scriptstyle \mathbf { = 6 5 }$ and type $\ " \mathbf { o } ^ { \prime \prime }$ ", "page": "

<span class $\mathrel { \mathop : }$ Pcurrent'>1\u51710\u6761\u6570\u636e
" }

Create a website backup

URI address:/site?action=ToBackup

Parameter nameParameter valueDescription
id66Website ID [Must]

Response content example:
{ "status": true, "msg": "\u5907\u4efd\u6210\u529f!"

Delete website backup

URI address:/site?action=DelBackup

Parameter nameParameter valueDescription
id121Backup list ID [Must]

Response content example:
{ "status": true, "msg": "\u5220\u9664\u6210\u529f"
}

Get a list of domain names for your site

URI address:/data?action $\mid =$ getData&table $\ L =$ domain

Parameter nameParameter value Description
search66Website ID [Must]
listtrueMust pass true

Response content example:

[ { "port": 80, "addtime": "2018-12-15 16:57:30", "pid": 65, "id": 73, "name": "w1.hao.com" }

Add domain name

URI address:/site?action=AddDomain

Parameter nameParameter valueDescription
id66Website ID[Must]
webnamew2.hao.comSitename[Must]
domainw4.hao.com:81The domain name to be added: port 80, the end product does not have to construct a port,and multiple domain names are separated by a newline [Must]

Response content example:
{ "status": true, "msg": "\u57df\u540d\u6dfb\u52a0\u6210\u529f!"
}

Delete domain name

URI address:/site?action $\mid =$ DelDomain

Parameter nameParameter valueDescription
id66Website ID[Must]
webnamew2.hao.comSite name [Must]
domainw4.hao.comDomain name to be deleted [Must]
port80The port of the domain name [Must]

Response content example:

{ "status": true, "msg": "\u5220\u9664\u6210\u529f"
}

Get an optional predefined pseudo-static list

URI address:/site?action=GetRewriteList

Parameter nameParameter valueDescription
siteNamew2.hao.comSite name [Must]

Response content:

Field Field value exampleDescription
rewrite[Predefined pseudo static list

Response content example: {

"rewrite": ["0.\u5f53\u524d", "EmpireCMS", "dabr", "dbshop", "dedecms", "default", "discuz", "discuzx", "discuzx2", "discuzx3", "drupal", "ecshop", "emlog", "laravel5", "maccms", "mvc", "niushop", "phpcms", "phpwind", "sablog", "seacms", "shopex", "thinkphp", "typecho", "typecho2", "weengine", "wordpress", "wp2", "zblog"] }

Get the specified predefined pseudo-static rule content (get the file content)

URI address:/files?action=GetFileBody

FieldField value exampleDescription
path/www/server/panel/vhost/rewrite/nginx/name.con fThe file to be obtained [Must]

Save pseudo static rule content (save file content)

URI address:/files?action=SaveFileBody

Field Field value exampleDescription
path/www/server/panel/vhost/rewrite/nginx/名称.confSave location [Must]
dataRule content
encodingutf-8File code, please pass it utf-8

Retrieve the root of the specified website

URI address:/data?action=getKey&table $\mathbf { \tau } =$ sites&key=path

FieldField value exampleDescription
id1Website ID [Must]

Retrieve anti-cross-hop configuration/run directory/log switch status/settable run directory list/password access status

URI 地址:/site?action=GetDirUserINI

Field Field value exampleDescription
id1Website ID [Must]
path/www/wwwroot/w1.if22.cnWebsite root directory [Must]

Response content example: {

"pass": false, #Whether to set password access "logs": true, #Whether to write access logs "userini": true, #Whether to set up anti-crossing station "runPath": { "dirs": ["/"], #List of directories that can be used to set the run directory "runPath": "/" #Current running directory } }

Set anti-crossing status (automatic reversal)

URI address:/site?action=SetDirUserINI

FieldField value exampleDescription
path/www/wwwroot/w1.if22.cnWebsite root directory [Must]

Set whether to write access logs

URI address:/site?action=logsOpen

Parameter nameParameter valueDescription
id1Website ID [Must]

Modify the website root directory

URI address:/site?action=SetPath

Parameter name Parameter valueDescription
id1Website ID [Must]
path/www/wwwroot/w1.if22.cnNew website root directory [Must]

Set whether to write access logs

URI address:/site?action $\vartriangleleft$ SetSiteRunPath

Parameter nameParameter valueDescription
id1Website ID[Must]
runPath/publicRun directory based on the root of the website

Set password access

URI address:/site?action=SetHasPwd

Parameter nameParameter valueDescription
id1Website ID [Must]
usernametestusername
passwordadminpassword

Turn off password access

URI address:/site?action=CloseHasPwd

Parameter nameParameter valueDescription
id1Website ID [Must]

Get traffic limit related configuration (only supports nginx)

URI address:/site?action=GetLimitNet

Parameter nameParameter valueDescription
id1Website ID [Must]

Enable or save traffic limit configuration (only nginx is supported)

URI 地址:/site?action $\Rightarrow$ etLimitNet

Parameter name Parameter valueDescription
id1Website ID[Must]
perserver300Concurrency restrictions [Must]
perip25Single IP limit [Must]
limit_rate512Traffic limit [Must]

Turn off traffic limits (only nginx is supported)

URI address:/site?action=CloseLimitNet

Parameter nameParameter valueDescription
id1Website ID [Must]

Take the default document information

URI address:/site?action=GetIndex

Parameter nameParameter valueDescription
id1Website ID [Must]

Set default document

URI address:/site?action $\mid =$ SetIndex

Parameter name Parameter valueDescription
id1Website ID [Must]
Indexindex.php,index.html,index.htm,default.ph p,default.htm,default.htmlDefault document,each separated by a comma [Must]

Take the content of the website configuration file (get the file content)

URI address:/files?action=GetFileBody

Parameter nameParameter valueDescription
path/www/server/panel/vhost/nginx/name.confThe file to be obtained [Must]

Save the website configuration file (save the file content)

URI address:/files?action $\scriptstyle 1 = 1$ SaveFileBody

Parameter nameParameter valueDescription
path/www/server/panel/vhost/nginx/name.confSave location [Must]
dataProfile content
encodingutf-8File encoding Please fillin utf-8