Skip to main content

Rest API - Transactions

The Reporter provides you with a Rest API that gives you direct access to the test data and statistics.

For more information on the Transaction View see Transaction View.

Concepts

  • Key - Key and value construct a tag. Each test has a subset of available tags with various values that describe the test specifics. Example: {device.os : Android}

  • Project - Concept derived from the cloud. Each project has it's own resources (users, devices) and can be used to created separation of testing efforts.

  • Test - Single test execution instance.

info

The role of the user performing the Rest Operation is specified by the 'Authorization' header. For a detailed example see How To Execute Rest API.

Get Test Transactions

Returns JSON representation of existing Test Transaction with the received ID.

If it does not exist a status 404 is returned.

  • This API is available for all user roles.
GET /reporter/api/transactions/<IDs>

 ids - Comma delineated list of Transaction IDs

Response

Response Status: 200 OK

{
  "id": 744,
  "name": "Test Rail",
  "appName": "com.apple.springboard",
  "appVersion": "",
  "startTime": 1584958844127,
  "deviceUid": "00008020-00152DA11A68002E",
  "deviceName": "iPhone xs b0227",
  "deviceModel": "iPhone XS",
  "deviceOs": "iOS",
  "deviceManufacturer": "Apple",
  "deviceVersion": "13.3",
  "deviceScreen": "1125 x 2436",
  "deviceType": "PHONE",
  "networkProfile": "",
  "cpuAvg": 211.10688234412152,
  "cpuMax": 836.3230590820312,
"cpuCoreCount": 2,
  "memAvg": 553.8927731721298,
  "memMax": 622.5054931640625,

  "memTotalInBytes": 2109210624,
  "batteryAvg": 374.1950969080771,
  "batteryMax": 490.32733154296875,
  "totalUploadedBytes": 0,
  "totalDownloadedBytes": 0,
  "duration": 31283,
  "speedIndex": -1,
  "videoStart": 1584958844127,
  "videoEnd": 1584958875410,
  "userName": "admin",
  "testId": 639,
  "date": "2020-03-23",
  "projectId": 1,
  "projectName": "Default",
  "attachmentList": []
}

Delete Test Transactions

Delete the test transactions identified by the received IDs. One or more ids can be provided, separated by a comma.

Example**:** /api/transactions/3,4,23

This API is available for Cloud and Project Administrators.

DELETE /reporter/api/transactions/<ids>

ids -Comma delineated list of Transaction IDs

Comparison of Transaction's Measuresfilter

It generates a comparison of average transaction measures between the latest base key-value and older key values.

POST /reporter/api/transactions/compare?token=<accessKey>

Json Parameter

NameTypeMandatoryDescription
filterListYesFilter by given properties. Supported properties are "appName" and "deviceOs".



Example:



[



[ "appName", "=", "Bank" ], 



"and", 



[ "deviceOs", "=", "Android"]



]
baseKeyStringYesBase version to be compared against previous versions. Only "appVersion**"** is supported for baseKey.



“latest” means the maximum base key (“version”) found.
baseKeyValueStringYes
compareCountintYesHow many older versions will be used for comparison against the version provided in baseKeyValue.



For example:



baseKey: "appVersion"

baseKeyValue: "7.0.1"

compareCount: 5



5 versions below "7.0.1" will be sought, for example: "7.0", "6.9", "6.8.5", "6.1" & "5.0"
comparisonTargetsListYesList of comparisons to be performed.



Each comparison is a of JSONobject with the following properties:



* name (String, mandatory) - Transaction name to be computed.

* measure (String, mandatory - Transaction's property name to be computed then compared.

* acceptedChange (double) - Accepted % change between computed value and base value.

Response

Response Status: 200 OK

{
  "id": 56,
  "name": "newTestViewsGroup",
  "byKey": "date",
  "byKeyDesc": true,
  "groupByKey1": "device.os",
  "groupByKey2": "device.version",
  "filter": [],
  "keys": [
    "date",
    "app"
  ],
  "createdBy": "admin"
}

See Performance Pipeline for more details.

Download HAR File

Downloads the HAR file for the transaction ID.

This API is available for all user roles.

GET /reporter/api/transactions/<id>/har

Parameters

NameTypeMandatoryDescription
tokenStringYesAccess Key

See Performance Pipeline for more details.

Download Video File

Downloads the video file attached to the transaction ID received as the path parameter.

This API is available for all user roles.

GET /reporter/api/transactions/<id>/video

Parameters

NameTypeMandatoryDescription
tokenStringYesAccess Key

Code Example

The examples below use the Unirest HTTP library.  To compile and run them, use the following Maven dependency:

Maven dependency

<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>

Java Expand source

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import org.junit.Test;

import java.io.InputStream;


import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import org.junit.Assert;
import org.junit.Test;

import java.io.*;
import java.util.List;


public class APIConfluenceTransactions {
private HttpResponse<String> responseString;
private HttpResponse<InputStream> responseInputStream;

private String urlBase = "<Reporter URL>"; //TODO: modify hostname and port of your Reporter

private String user = "<User>"; //TODO: user name
private String password = "<Password>"; //TODO: user password
@Test
public void deleteMultipleTransactions() {

int from = 1;
int to = 1000;
int step = 100;


for (int start = from; start< to; start=start+ step){
System.out.println(start);
StringBuffer toDelete =new StringBuffer(start+"");
for(int i = start+1; i<start+ step; i++){
toDelete.append(","+i);
}
deleteTranactions(toDelete.toString());
}

}

private void deleteTranactions(String toDelete) {
String url = urlBase + "/api/testtx/"+toDelete;

try {
responseString = Unirest.delete(url)
.basicAuth(user, password)
.queryString("projectName","default")
.header("content-type", "application/json")
.asString();

System.out.println(responseString.getBody());

} catch (Exception e) {
e.printStackTrace();
}
}

public void testDownloadHar() throws Exception {
String url= urlBase + "/api/transactions/%d/har";
long transId = <transaction id>;
String token = <...accesToken...>

url = String.format(url, transId);
HttpResponse<InputStream> response = Unirest.get(url)
.queryString("token", token)
.asBinary();
int status = response.getStatus();
Assert.assertEquals(200, status);
if (status == 200) {
List<String> disposition = response.getHeaders().get("Content-Disposition");
String fileName = "harfile";
if (disposition != null && !disposition.isEmpty()) {
fileName = disposition.get(0).split("=")[1];
}
fileName = "/tmp/" + fileName;
saveToFile(response.getBody(), fileName);
Assert.assertTrue(new File(fileName).exists());
}
}

public void testDownloadVideo() throws Exception {
String url= urlBase + "/api/transactions/%d/video";
long transId = <transaction id>;
String token = <...accesToken...>

url = String.format(url, transId);
HttpResponse<InputStream> response = Unirest.get(url)
.queryString("token", token)
.asBinary();
int status = response.getStatus();
Assert.assertEquals(200, status);
if (status == 200) {
List<String> disposition = response.getHeaders().get("Content-Disposition");
String fileName = "videofile.mp4";
if (disposition != null && !disposition.isEmpty()) {
fileName = disposition.get(0).split("=")[1];
}
fileName = "/tmp/" + fileName;
saveToFile(response.getBody(), fileName);
Assert.assertTrue(new File(fileName).exists());
}
}

static void saveToFile(InputStream in, String fileName) throws IOException {
try (OutputStream out = new FileOutputStream(fileName)) {
byte[] buffer = new byte[1024];
int readCount;
while ((readCount = in.read(buffer)) != -1) {
out.write(buffer, 0, readCount);
}
}
}
}