The developer tool provides two interfaces, the command line and the HTTP service, for external call. The developer can login, preview, upload and so on through the command line or the HTTP request instruction tool.
# HTTP V2
Upgrade Instructions : Since
1.02.202003092, the CLI & HTTP interface upgradev2version. In thev2-version, the older command is still available, but is deprecated and will be removed in the future. Use the v2 command.The v2 version adds cloud development management operation support, optimized command form, increased detailed state prompts, support for long-time command execution, and support for nationalization (Chinese and English choices).
The http service is automatically opened after the tool starts, and the HTTP service port number is logged in the user directory. You can determine whether the tool is installed / started by checking the user catalog, checking whether there are ports files in the user's directory, and trying to connect.
Port Number File Location:
MacOS: '~ / Library / Application Support / WeChat Developer Tools / / Default /.ide'
Windows: '~ / AppData / Local / WeChat Developer Tools / User Data / / Default /.ide'
Note: MD5 calculation rule: MD5 (`${installPath} ${nwVersion}`)
macOS: installPath == "/Applications/wechatwebdevtools.app/Contents/MacOS", nwVersion == '';
Windoes: installPath = = 'WeChat The path where the developer tool.exe is located', nwVersion is the value of latestNw in a version file (JSON format) in the installPath directory
# Interface index
URL path prefixes for all interfaces require/ v2
| classification | Effect | interface |
|---|---|---|
| log in | Login Tool | /login |
| Whether or not to log in to the tool | /islogin | |
| Weixin Mini Program Code | preview | /preview |
| Upload code | /upload | |
| Automatic preview | /autopreview | |
| Building npm | /buildnpm | |
| Clear the cache | /cleancache | |
| Tools Window | Startup Tool | /open |
| Close the project window | /close | |
| Turn off the tool | /quit | |
| Reconstruct file listening | /resetfileutils | |
| Cloud development | Cloud development operations | /cloud |
| Operations related to cloud environments | /cloud/env | |
| Cloud Function Related Operations | /cloud/functions | |
| View list of cloud environments | /cloud/env/list | |
| View a list of cloud functions | /cloud/functions/list | |
| View Cloud Function Information | /cloud/functions/info | |
| Upload cloud function | /cloud/functions/deploy | |
| Incremental upload cloud function | /cloud/functions/inc-deploy | |
| Download Cloud Functions | /cloud/functions/download |
# Common project options
General URL parameters
| parameter | Introductions |
|---|---|
| project | Project Path |
| appid | Weixin Mini Program AppID or Third Party Platform AppID.If a project is provided, this option ignores |
| ext-appid | Third Party Platform AppID was developed when it was developed.If a project is provided, this option ignores |
# Interface documentation
# Login Tool
Interface definition:
Path:/v2/login
HTTP method: GET
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| qr-format | no | Specifies the login binary code return format, optionally image, base64, terminal, default image. Image format is png |
| qr-output | no | Specify the file path to write QR code data in the file. If specified, the QR code will be written to the file of the specified path, if not specified, it will be returned as the request appropriate body |
| result-output | no | Specify the path of the output login result file |
Examples:
# 登录,返回图片格式的二维码
http://127.0.0.1:端口号/v2/login
# 登录,取 base64 格式二维码
http://127.0.0.1:端口号/v2/login?qr-format=base64
# 登录,取 base64 格式二维码,并写入 /Users/username/logincode.txt
http://127.0.0.1:端口号/v2/login?qr-format=base64&qr-output=%2FUsers%2Fusername%2Flogincode.txt
# 登录,并写入登录结果到 /Users/username/loginresult.json
http://127.0.0.1:端口号/v2/login?result-output=%2FUsers%2Fusername%2Floginresult.json
# Are you already logged into the tool?
Interface definition:
Path:/v2/islogin
HTTP method: GET
Example
http://127.0.0.1:端口号/v2/islogin
# preview
Interface definition:
URL:/v2/preview
HTTP method: GET
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| project | yes | Preview the items in the specified path. If the project is open, the project is automatically refreshed. If the project is not created, automatically create and preview the project |
| qr-format | no | Specifies the login binary code return format, optionally image, base64, terminal, default image. Image format is png |
| qr-output | no | Specify the file path to write QR code data into the file. If specified, the QR code will be written to the file of the specified path, if not specified, it will be returned as the request appropriate body |
| info-output | no | Once specified, additional information about this preview will be output to the specified path in JSON format, such as code package size, subpackage size information. |
| compile-condition | no | Specifies a custom compile condition, which is a json character string. The condition specifies two fields,pathNamefor the open page, for the home page, ` for the page arguments |
Examples:
# 预览路径为 /Users/username/demo 的项目,返回图片格式的二维码
http://127.0.0.1:端口号/v2/preview?project=%2FUsers%2Fusername%2Fdemo
# 预览路径为 /Users/username/demo 的项目,返回 base64 格式的二维码
http://127.0.0.1:端口号/v2/preview?project=%2FUsers%2Fusername%2Fdemo&qr-format=base64
# 预览路径为 /Users/username/demo 的项目,返回 base64 格式的二维码,并写入 /Users/username/logincode.txt
http://127.0.0.1:端口号/v2/preview?project=%2FUsers%2Fusername%2Fdemo&qr-format=base64&qr-output=%2FUsers%2Fusername%2Flogincode.txt
# 预览路径为 /Users/username/demo 的项目,返回图片格式的二维码,并将预览信息输出至 /Users/username/info.json
http://127.0.0.1:端口号/v2/preview?project=%2FUsers%2Fusername%2Fdemo&info-output=%2Users%2username%2info.json
# 预览路径为 /Users/username/demo 的项目,指定自定义编译条件,启动页为 pages/index/index,参数为 x=1&y=2
http://127.0.0.1:端口号/v2/preview?project=%2FUsers%2Fusername%2Fdemo&compile-condition={"pathName":"pages/index/index","query":"a3=1"}
# Upload code
Interface definition:
URL:/v2/upload
HTTP method: GET
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| project | yes | Project Path |
| version | yes | Version number |
| desc | no | Version Notes for this upload |
| info-output | no | After specified, the additional information will be exported to the specified path in JSON format, such as code package size, subcontract size information. |
Examples:
# 上传路径为 /Users/username/demo 的项目,指定版本号为 v1.0.0
http://127.0.0.1:端口号/v2/upload?project=%2FUsers%2Fusername%2Fdemo&version=v1.0.0
# 上传路径为 /Users/username/demo 的项目,指定版本号为 v1.0.0,并带上备注
http://127.0.0.1:端口号/v2/upload?project=%2FUsers%2Fusername%2Fdemo&version=v1.0.0&desc=test
# 上传路径为 /Users/username/demo 的项目,指定版本号为 v1.0.0,并将上传信息输出至 /Users/username/info.json
http://127.0.0.1:端口号/v2/upload?project=%2FUsers%2Fusername%2Fdemo&version=v1.0.0&info-output=%2Users%2username%2info.json
# Automatic preview
Interface definition:
URL:/autopreview
HTTP method: GET
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| project | yes | Specify the items in the path. If the project is open, the project is automatically refreshed. If the project is not created, create it automatically and preview it automatically |
| info-output | no | After specified, the additional information of this automatic preview will be output to the specified path in json format, such as code package size and subpackage size information. |
Examples:
# 自动预览路径为 /Users/username/demo 的项目,返回图片格式的二维码,并将预览信息输出至 /Users/username/info.json
http://127.0.0.1:端口号/v2/autopreview?project=%2FUsers%2Fusername%2Fdemo&info-output=%2Users%2username%2info.json
# Building npm
Interface definition:
URL:/buildnpm
HTTP method: GET
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| project | yes | Project Path |
| compile-type | no | Compile type,miniprogram(default) orplugin |
Examples:
# 构建路径为 /Users/username/demo 的项目
http://127.0.0.1:端口号/v2/buildnpm?project=%2FUsers%2Fusername%2Fdemo&compile-type=miniprogram
# Startup Tool
Interface definition:
URL:/open
HTTP method: GET
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| project | no | Open an item in the specified path. If the project is open, the project is automatically refreshed. If the project is not created, the project is automatically created and opened. If you do not fill in, display the tool window |
Examples:
# 打开工具
http://127.0.0.1:端口号/v2/open
# 打开/刷新项目
http://127.0.0.1:端口号/v2/open?project=项目全路径
NOTE:
- The project path must contain the correctly formatted project.config.json with the AppID and projectname fields.
- The project path requires URL encode
# Close the project window
Interface definition:
URL:/close
HTTP method: GET
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| project | yes | Specify the items in the path. |
Example
http://127.0.0.1:端口号/v2/close?project=%2FUsers%2Fusername%2Fdemo
Note: When the item is closed, there is a pop-up hint if it is blocked; If not blocked, it will shut down after 3 seconds
# Turn off the tool
Interface definition:
URL:/quit
HTTP method: GET
Example
http://127.0.0.1:端口号/v2/quit
Note: When you close the developer tools, there is a pop-up asking whether to block them; If not blocked, it will shut down after 3 seconds
# Reconstruct file listening
Reset the tool's internal file cache to re-listen to the project files.
URL:/resetfileutils
HTTP method: GET
Example
http://127.0.0.1:端口号/v2/resetfileutils?project=%2FUsers%2Fusername%2Fdemo
# Clear tool cache
Interface definition:
URL:/cleancache
HTTP method: GET
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| project | yes | Preview the items in the specified path. If the project is open, the project is automatically refreshed. If the project is not created, automatically create and preview the project |
| clean | yes | Specifies the type of cache to clear. Optional values are storage, file, seeion, auth, network, compile, all |
Example
http://127.0.0.1:端口号/v2/cleancache?clean%3Dstorage%26project%3D%2FUsers%2Fxxx%2Fminiprogram-10
# Cloud development operations
In cloud development commands, unless otherwise specified, you can specify theprojectoption orAppID(if it is Third Party Platform then addext-appid)Specify items in either manner.
# View list of cloud environments
GET /v2/cloud/env/list
Examples:
# 通过 project 查看
http://127.0.0.1:端口号/v2/cloud/env/list?project=%2FUsers%2Fusername%2Fdemo
# 通过 appid 查看
http://127.0.0.1:端口号/v2/cloud/env/list?appid=wx1111111111111
# View a list of cloud functions
GET /v2/cloud/functions/list
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| env | yes | Cloud Environment ID |
Examples:
# 通过 --project 查看环境 test-123 下的线上云函数
http://127.0.0.1:端口号/v2/cloud/?env=test-123&project=%2FUsers%2Fusername%2Fdemo
# 通过 --appid 查看环境 test-123 下的线上云函数
http://127.0.0.1:端口号/v2/cloud/?env=test-123&appid=wx1111111111111
# View Cloud Function Information
GET /v2/cloud/functions/info
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| env | yes | Cloud Environment ID |
| names | yes | Cloud function name, and multiple cloud functions are separated by comma |
Examples:
# 通过 --project 查看环境 test-123 下的云函数 aaa, bbb 的信息
http://127.0.0.1:端口号/v2/cloud/functions/info?env=test-123&names=aaa,bbb&project=%2FUsers%2Fusername%2Fdemo
# 通过 --appid 查看环境 test-123 下的云函数 aaa, bbb 的信息
http://127.0.0.1:端口号/v2/cloud/functions/list?env=test-123&names=aaa,bbb&appid=wx1111111111111
# Upload cloud function
GET /v2/cloud/functions/deploy
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| env | yes | Cloud Environment ID |
| names | no | Cloud function name, and multiple cloud functions are separated by comma. The folder with the same name will be found in the "cloudfunctionRoot" directory specified in project.config.json. If used, the project option must be provided |
| paths | no | The directory paths for cloud functions that need to be deployed are separated by spaces. The function directory name is considered to be the function name. With this option, the cloud functions directory structure does not have to follow the way it must be in project.config.json "cloudfunctionRoot" |
| remote-npm-install | no | Cloud installation dependency, node_modules will not upload after specifying the option |
Examples:
# 上传云函数根目录下名为 func_a, func_b 的两个云函数至云环境 ENVID,开启云端安装依赖
http://127.0.0.1:端口号/v2/cloud/functions/deploy?env=ENVID&remote-npm-install&names=func_a,func_b&project=%2Faaa%2Fbbb%2Fccc
# 指定绝对路径目录上传,开启云端安装依赖
http://127.0.0.1:端口号/v2/cloud/functions/deploy?env=ENVID&remote-npm-install&paths=%2Fa%2Fb%2Ffunc_a,%2Fx%2Fy%2Ffunc_b&appid=APPID
# Incremental upload cloud function
GET /v2/cloud/functions/inc-deploy
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| env | yes | Cloud Environment ID |
| name | no | The name of the cloud function that needs to be updated, with which the path option should not be used. The folder with the same name will be found in the "cloudfunctionRoot" directory specified in project.config.json. If used, the project option must be provided |
| path | no | Cloud function directory, which should not use the name option. The function directory name is considered to be the function name. With this option, the cloud functions directory structure does not have to follow the way it must be in project.config.json "cloudfunctionRoot" |
| file | no | The relative file / directory path needs to be incrementally updated. The path must be the path of the relative cloud function directory |
Examples:
# 增量上传,指定云函数名
http://127.0.0.1:端口号/v2/cloud/functions/inc-deploy?env=ENVID&name=func_a&file=index.js&project=%2Faaa%2Fbbb%2Fccc
# 增量上传,指定云函数路径
http://127.0.0.1:端口号/v2/cloud/functions/inc-deploy?env=ENVID&path=%2Faaa%2Ffunc_a&file=index.js&appid=APPID
# Download Cloud Functions
GET /v2/cloud/functions/download
| URL Parameters | Required to fill in | Introductions |
|---|---|---|
| env | yes | Cloud Environment ID |
| name | no | Cloud Function Name |
| path | no | Where to store after download |
Examples:
# 下载云函数 func_a 至 /xxx/yyy 目录
http://127.0.0.1:端口号/v2/cloud/functions/download?env=ENVID&name=func_a&path=%2Fxxx%2Fyyy&appid=APPID