Pricing
API Documentation
Help Documents menu

API Documentation

Updated on: 2023-09-19 18:15

WeTest REST API

WeTest CloudTesting Project provides a powerful and useful API for users to manage all aspects of mobile automatic test. With the API, you can access our device farm, test runs, detail results, and integrate to your CI/CD environment.The full API is available here.

SecretId:SecretKey
Before running the following API in your local terminal or script, you should paste the credentials SecretId:SecretKey in the code, you can obtain them from Account Settings on our website.

Manage File Resource

1.Upload App

  • URI:/v1/platform/upload/storage
  • Description:upload app
  • Method:POST
  • Input Parameters
Params Source Type Required Description
project query string Yes project id, obtain it from project settings
name query string Yes app name with extension(.aab, .apk, .ipa)
data form-data file Yes absolute local path of your app file
  • Output Parameters
{
  "data": {
    "fid": string,  // app hash id used for submit test 
  },
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> --request POST "https://api.paas.wetest.net/cloudtest/v1/platform/upload/storage?project=<project>&name=<name>" --form "data=@/user/demo-app.apk" 

2.Get App

  • URI:/v1/platform/upload/info
  • Description:get uploaded app
  • Method:GET
  • Input Parameters
Params Source Type Required Description
fid query string Yes app hash id (optional with hash)
hash query string Yes app md5 hash (optional with fid)
project query string Yes project id, obtain it from project settings(share script in project)
  • Output Parameters
{
  "msg": "string",
  "ret": int,
  "data": {
    "fid": "string",        // app hash id
    "size": int,            // app size (bytes)
    "md5": "string",        // app md5 hash
    "url": "string",        // app download url
    "name": "string",       // app name
    "package": "string",    // app package
    "version": "string",    // app version
    "icon_url": "string"    // icon download url
  }
}
  • Sample Request
curl -u <SecretId>:<SecretKey> "https://api.paas.wetest.net/cloudtest/v1/platform/upload/info?fid=<fid>&project=<project>"

3.Delete App

  • URI:/v1/platform/upload/info/<fid>
  • Description:delete uploaded app
  • Method:DELETE
  • Input Parameters
Params Source Type Required Description
fid path string Yes App hash id
  • Output Parameters
{
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> --request DELETE "https://api.paas.wetest.net/cloudtest/v1/platform/upload/info/<fid>"

4.Upload Script

  • URI:/v1/scripts
  • Description:upload script
  • Method:POST
  • Input Parameters
Params Source Type Required Description
file form-data file Yes script file
project query string No project id, obtain it from project settings(share script in project)
  • Output Parameters
{
  "script": {
    "script_id": int,        // script id used for submit test 
    "size": int,             // script size (bytes)
    "script_url": "string",  // script download url
  },
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> --request POST "https://api.paas.wetest.net/cloudtest/v1/scripts" --form "file=@/user/demo-script.zip" 

5.Get script information by script ID

  • URI:/v1/scripts/<script_id>
  • Description:Get script information by id
  • Method:GET
  • Input Parameters
Params Source Type Required Description
script_id path string Yes Script id
project query string No project id, obtain it from project settings(share script in project)
  • Output Parameters
{
  "script": {
    "script_id": int,      // script id used for submit test 
    "user": "string",      // upload user id
    "size": int,           // script size (bytes) 
    "script_url": "string",// script download url
    "project": "string"    // script upload project
  },
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> "https://api.paas.wetest.net/cloudtest/v1/scripts/<script_id>"

6.Delete script

  • URI:/v1/scripts/<script_id>
  • Description:delete uploaded script
  • Method:DELETE
  • Input Parameters
Params Source Type Required Description
script_id path string Yes Script id
  • Output Parameters
{
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> --request DELETE "https://api.paas.wetest.net/cloudtest/v1/scripts/<script_id>"

Manage Device

1.Get Cloud List

  • URI:/v1/users/clouds

  • Description: get device farm list

  • Method:GET

  • Input Parameters

  • Output Parameters

{
  "clouds": [{
    "cloud_id": int,
    "cloud_name": "string",
  }],
  "msg": "string",
  "ret": int // 0 for success
}
  • Sample Request
curl -u <SecretId>:<SecretKey> "https://api.paas.wetest.net/cloudtest/v1/users/clouds"

2.Get Devices

  • URI:/v1/clouds/<cloud_id>/devices
  • Description:
    • Get devices list by in specific cloud farm
  • Method:GET
  • Input Parameters
Params Source Type Required Description
cloud_id path int Yes Device Farm id
  • Output Parameters
{
  "devices": [{
    "cloud_id": int,             // Device Farm ID
    "cpu_total": int,            // device cpu core number
    "device_id": int,            // device ID
    "device_state": "string",    // device state
    "device_state_code": int,    // device state code
    "location": "string",        // device location
    "manufacture": "string",     // manufacture
    "model": "string",           // model name
    "model_id": int,             // model ID
    "ram": int,                  // ram
    "resolution": "string",      // resolution
    "test_id": int,              // current test ID
    "version": "string",         // system version
  }],
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> "https://api.paas.wetest.net/cloudtest/v1/clouds/<cloud_id>/devices"

3.Get Custom Model List

  • URI:/v1/model/list

  • Description: Get custom model list

  • Method:GET

  • Input Parameters
    | Params | Source | Type | Required | Description |
    | ------------ | ------ | ------ | ---- | --------------------------------------------------------------------------------------------------- |
    | project | query | string | Yes | which project does the model list belong to |

  • Output Parameters

{
  "count": int,             // list count
  "data": [{
    "id": int,              // list ID
    "name": "string",       // list name
    "cloud_name": "string", // device farm name
    "device_type": int,     // device type 0 for android 1 for ios
    "model_count": int,     // model or device count in this list 
    "cloud_id": int,        // device farm id
    "filter_type": int      // saved as device or model dimension. 1 for model list 2 for device list
  }], 
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> "https://api.paas.wetest.net/cloudtest/v1/model/list?project=<project>"

Submit Test

1.Submit Automation Test

  • URI:/v1/tests/automation
  • Description:Submit the automation test.
  • Method:POST
  • Common Input Parameters
Params Source Type Required Description
project body string Yes project ID,obtain it from project settings
app_hash_id body string Yes Target App ID
script_id body int No Target script ID, Whether it is necessary depends on the param “frame_type”
frame_type body string Yes - “appium”: script required
- “game_loop”: no script required
default value is “appium”
max_test_runtime body int Yes The time out period of the entire test, The default is 1800 seconds.
max_device_runtime body int Yes The time out period of the each device. The default is 600 seconds.
cloud_id body int Yes Device farm id.
device_number body int Yes Target device quantity
devices body int array No Choose device ID or model ID for submit test. Mix device ID and model ID are not allowed.
device_choose_type body string No Target device strategy, device ID or model ID.
- “deviceids”: choose device group by device ID
- “modelids”: choose device group by model ID
default value is “deviceids”
scenarios(Game Loop only) body string No Game Loop Test only, if you want to run multiple loops (aka scenarios) at a time or select specific loops to run, enter the loop numbers in this “scenarios” param. For example, when you enter “1-3, 5”, Test runs loops 1, 2, 3, and 5. By default (if you don’t enter anything in this param), Test only runs loop 1.
scenario_labels(Game Loop only) body string No For Game Loop Test only, you can label your scenarios in your AndroidManifest.xml file
resign(iOS only) body bool No iOS only, Whether your ipa need to be re-signed
  • Output Parameters
{
  "msg": "string",
  "ret": int,
  "test_info": {
    "test_id": int // test ID
  }
}
  • Sample Request
curl -u <SecretId>:<SecretKey> --request POST "https://api.paas.wetest.net/cloudtest/v1/tests/automation" 
-d '{
  "app_hash_id": <app_id>,
  "cloud_id":<cloud_id>,
  "script_id": <script_id>,
  "frame_type":<frame_type>
  "max_test_runtime": 1800,
  "device_number": 2,
  "project": <project>
}'

2.Cancel Test

  • URI:/v1/tests/<test_id>/cancelation
  • Description:Cancel test
  • Method:POST
  • Input Parameters
Params Source Type Required Description
test_id path int Yes test id, obtain it from report
  • Output Parameters
 {
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> --request POST "https://api.paas.wetest.net/cloudtest/v1/tests/<test_id>/cancelation"

Manage Test Result

1. Get Test Status

  • URI:/v1/tests/<test_id>/status
  • Description:get the test status
  • Method:GET
  • Input Parameters
Params Source Type Required Description
test_id path int Yes test id, you can get it from report
  • Output Parameters
 {
  "msg": "string",
  "ret": int,
  "test_status": {
    "finished": bool,        // whether the task is finished
    "start_time": "string",  // test start time
    "end_time": "string",    // test end time
    "test_id": int,          // test ID
      "status_code": int,    // test status,0 for testing,1 for fnished, 2 for canceled,3 for test timeout
      "status":"string"      // test status description
  }
}
  • Sample Request
curl -u <SecretId>:<SecretKey>  "https://api.paas.wetest.net/cloudtest/v1/tests/<test_id>/status"

2.Get Results of Devices in Test

  • URI:/v1/tests/<test_id>/devices
  • Description: get results of tested devices
  • Method:GET
  • Input Parameters
Params Source Type Required Description
test_id path int Yes test id, you can get it from report
log query bool No default is false. whether to return the log
image query bool No default is false. whether to return the image url
error query bool No default is false. whether to return the error information
  • Output Parameters
{
  "devices": [{
    // test ID
    "test_id": int,
    // device ID
    "device_id": int,
    // submit time of device
    "start_time": "string",
    // start time of device
    "device_start_time": "string",
    // queuing time of device, the unit is seconds
    "wait_time": 0,
    // end time of device
    "end_time": "string",
    // if parameter error is set to true,return error details
    "errors": [{
      "content": "string",
      "description": "string",
      "error_time": "string",
      "level": "string"
    }], 
    // if parameter image is set to true,return image details
    "images": [{
      "image_name": "string",
      "image_time": "string",
      "image_url": "string"
    }],
    // if parameter log is set to true,return mobile log,script log and video
    "mobile_log_url": "string",
    "script_log_url": "string",
    "test_video_url": "string",
    // if test is functional test,reture tested case details on this device
    "case_stat": {
      "case_total": int,    // number of total case
      "case_success": int,  // number of successful case 
      "case_fail": int,     // number of failed case 
      "case_timeout": int   // number of timeout case 
    },
    // device detail information
    "model": "string",
    "version": "string",
    "manufacture":"string",
    "ram":int,
    "cpu_ghz":float,
    "cpu_total":int,
    // Description of device result. If it is a functional test, you don't need to pay much attention to this information. You should focus on case results.
    "result": "string",
    // device result code
    // 0 for running, 1 for passed, 2 for has compatibility error, 3 for untest(caused by device exception, 4 for timeout, 5 for system canceled, 6 for user canceled
    "result_code": 0,
    // device process cost
    "cost_info":[{
      "process_name":"string", // process name means what device is doing
      "cost":int,              // cost time, unit is seconds
      "start_time":"string",   // start time of this process
      "end_time":"string"      // end time of this process
    }],
  }],
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey>  "https://api.paas.wetest.net/cloudtest/v1/tests/<test_id>/devices?log=<log>&image=<image>&error=<error>"

3.Get Specific Device Result Of Test

  • URI:/v1/tests/<test_id>/devices/<device_id>
  • Description: get test result by device id
  • Method:GET
  • Input Parameters
Params Source Type Required Description
test_id path int Yes test id, obtain it in report
device_id path int Yes device id, obtain it in report
log query bool No default is false. Return the log down url
image query bool No default is false. Return the screenshoot download url
error query bool No default is false. Return the error info
  • Output Parameters
{
  "device": {
    // test ID
    "test_id": int,
    // device ID
    "device_id": int,
    // submit time of device
    "start_time": "string",
    // start time of device
    "device_start_time": "string",
    // queuing time of device, the unit is seconds
    "wait_time": 0,
    // end time of device
    "end_time": "string",
    // if parameter error is set to true,return error details
    "errors": [{
      "content": "string",
      "description": "string",
      "error_time": "string",
      "level": "string"
    }],
    // if parameter image is set to true,return image details
    "images": [{
      "image_name": "string",
      "image_time": "string",
      "image_url": "string"
    }],
    // if parameter log is set to true,return mobile log,script log and video
    "mobile_log_url": "string",
    "script_log_url": "string",
    "test_video_url": "string",
    // if test is functional test,reture tested case details on this device
    "case_stat": {
      "case_total": int,    // number of total case
      "case_success": int,  // number of successful case 
      "case_fail": int,     // number of failed case 
      "case_timeout": int   // number of timeout case 
    },
    // device detail information
    "model": "string",
    "version": "string",
    "manufacture":"string",
    "ram":int,
    "cpu_ghz":float,
    "cpu_total":int,
    // Description of device result. If it is a functional test, you don't need to pay much attention to this information. You should focus on case results.
    "result": "string",
    // device result code
    // 0 for running, 1 for passed, 2 for has compatibility error, 3 for untest(caused by device exception, 4 for timeout, 5 for system canceled, 6 for user canceled
    "result_code": 0,
    // device process cost
    "cost_info":[{
      "process_name":"string", // process name means what device is doing
      "cost":int,              // cost time, unit is seconds
      "start_time":"string",   // start time of this process
      "end_time":"string"      // end time of this process
    }],
  },
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey>  "https://api.paas.wetest.net/cloudtest/v1/tests/<test_id>/devices/<device_id>?log=<log>&image=<image>&error=<error>"

4.Get Performance Info by Device ID

  • URI:/v1/tests/<test_id>/devices/<device_id>/metrics
  • Description: get performance info by device id
  • Method:GET
  • Input Parameters
Params Source Type Required Description
test_id path int Yes test id, obtain it in report
device_id path int Yes device id, obtain it in report
type query string Yes only support “perf” value now
  • Response:200
{ 
  "data":[{
    "cpu_app": 8.0,         // CPU occupancy of tested app
    "cpu_total": 13.51,     // total CPU occupancy
    "fps": int,             // FPS
    "ios_memory": int,      // memory data of iOS app (MB)
    "label": "",            // Used to mark a piece of performance data
    "mem_native_pss": int,  // memory data of Android app (MB)
    "mem_pss": int,         // memory data of Android app (MB)
    "net_in": int,          // KB/s
    "net_out": int,         // KB/s
    "timestamp": int        // unix timestamp
  }],
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey>  "https://api.paas.wetest.net/cloudtest/v1/tests/<test_id>/devices/<device_id>/metrics?type=perf"

5.Get Summary Information Of Test

  • URI:/v1/tests/<test_id>/result
  • Description: get summary of the test
  • Method:GET
  • Input Parameters
Params Source Type Required Description
test_id path int Yes test id, obtain it in report
  • Output Parameters
{
  "msg": "string",
  "ret": int,
  "test_result": {
    // start time of test
    "start_time": "string",
    // end time of test
    "end_time": "string",
    // test frame type
    "frame_type_code": int, 
    // test frame type
    "frame_type": "string",
    // report url to view details of test result
    "report_url": "string",
    // test status,0 for testing,1 for finished,2 for canceled,3 for timeout
    "status_code": int,
    // test status description
    "status":"string",
    "test_id": int,
    "test_type": "string",
    "test_type_code": int,
    // tested app info
    "app_info": {
      "app_type": "android",
      "icon_url": "string",
      "name": "string",
      "package": "string",
      "size": int,
      "version": "string"
    },
    // result of device dimension
    "result_stat": {
      "total_device_number": int,
      "pass_device_number": int,
      "exception_device_number": int,
      "in_process_device_number": int,
      "fist_start_device_time": "string",
      // maximum waiting time
      "max_wait_time": int,
      // minimum waiting time
      "min_wait_time": int,
      // last device launched time
      "last_start_device_time": "string",
      "pass_rate": float,
      "exception_rate": float,
    }
  }
}
  • Sample Request
curl -u <SecretId>:<SecretKey>  "https://api.paas.wetest.net/cloudtest/v1/tests/<test_id>/result"

Manage Project

1.Get project list

  • URI:/v1/users/projects

  • Description: return project list, you have to specify the project id when submitting the test.

  • Method:GET

  • Input Parameters

  • Output Parameters

{
  "projects": [{
    "project_id": "string",   // project id used for submit test
    "project_name": "string"  // project name
  }],
  "msg": "string",
  "ret": int
}
  • Sample Request
curl -u <SecretId>:<SecretKey> "https://api.paas.wetest.net/cloudtest/v1/users/projects"