Skip to end of metadata
Go to start of metadata

Analytics API BETA

The API methods for Sauce Labs are in BETA while we launch this new feature. If you have any problems with using the Analytics API, please contact support@saucelabs.com.


Global Query Parameters

start

required unless "time_range" given

date in RFC3339 format (YYYY-MM-DDTHH:MM:SSZ)
or Unix time (the number of seconds since January 1, 1970 UTC)

Specifies a start point in time from which data is queried.

Must be lower than "end" value.
"end - start" must be less than or equal to 14 days.

end

required unless "time_range" given

date in RFC3339 format (YYYY-MM-DDTHH:MM:SSZ)
or Unix time (the number of seconds since January 1, 1970 UTC) 

Specifies an end point in time to which data is queried.

Must be greater than "start" value.
"end - start" must be less than or equal to 14 days.

time_range

optional

duration with unit, e.g. "-6h", "-1d", "-5m"

Specifies a time range relative to the current time.

Allowed units: d – day, h – hour, m – minute, s – second.

scope

optional

string with value "me" | "organization" | "single", default me

Specifies a scope of "owner" parameter.

me – data belonging to user sending the request
organization – data from the whole user's organization
single – arbitrary user from user's organization 

owner

required for scope equal "single", otherwise optional

string, multiple occurrences allowed

Values for Owner filter.

Should be specified only if scope is equal to "single".
Value must be a username from user's organization.

status

optional

string with value "passed" | "errored" | "failed" | "complete",
multiple occurrences allowed 

Values for Status filter.

If multiple "status" params are passed, they will be joined with OR operator.

pretty

optional 

any value

If present the output will be pretty-printed JSON.
By default, the output is compressed JSON.


Test Trends

Return various test metrics divided into buckets. A bucket contains data grouped by an interval specified in query params.

GET /rest/v1/analytics/trends/tests
Parameters

interval

required

duration with unit, e.g. "6h", "1d", "5m"

Specifies a length of a bucket in the response.

Allowed units: d – day, h – hour, m – minute, s – second.
Minimal interval is "5s", i.e. 5 seconds.

os

optional

string, multiple occurrences allowed

Specifies values for the OS filter.

browser

optional

string, multiple occurrences allowed

Specifies values for the Browser filter.


Example of selecting a test trends from March 1st, 2017 to March 2nd, 2017 divided into buckets of 1-hour length and filtered with the OS field equal to Linux:

curl -u USERNAME:ACCESS_KEY "https://saucelabs.com/rest/v1/analytics/trends/tests?interval=1h&start=2017-03-01T12:00:00Z&end=2017-03-02T12:00:00Z&os=Linux&pretty"
Response:
 Click here to expand...
{
  "meta": {
    "status": 200
  },
  "buckets": [
    {
      "timestamp": "2017-03-09T12:00:00.000Z",
      "count": 204,
      "aggs": {
        "os": [
          {
            "name": "OS X El Capitan (10.11)",
            "count": 98
          },
          {
            "name": "Windows 7",
            "count": 65
          },
          {
            "name": "Linux",
            "count": 41
          }
        ],
        "owner": [
          {
            "name": "a-team",
            "count": 204
          }
        ],
        "status": [
          {
            "name": "complete",
            "count": 133
          },
          {
            "name": "passed",
            "count": 58
          },
          {
            "name": "failed",
            "count": 12
          },
          {
            "name": "errored",
            "count": 1
          }
        ]
      }
    },
    // more buckets...
  ],
  "metrics": {
    "os": {
      "Linux": 163,
      "OS X El Capitan (10.11)": 356,
      "Windows 7": 229
    },
    "owner": {
      "a-team": 748
    },
    "status": {
      "complete": 496,
      "errored": 2,
      "failed": 44,
      "passed": 206
    }
  }
}


Error Aggregations

Aggregate all errors that occurred in a given time range.

GET /rest/v1/analytics/trends/errors
Parameters

os

optional

string, multiple occurrences allowed

Specifies values for the OS filter.

browser

optional

string, multiple occurrences allowed

Specifies values for the Browser filter.


Example of selecting all errors occurred in any tests in user's organization from March 1st, 2017 to March 2nd, 2017.

curl -u USERNAME:ACCESS_KEY "https://saucelabs.com/rest/v1/analytics/trends/errors?start=2017-03-01T12:00:00Z&end=2017-03-02T12:00:00Z&scope=organization&pretty"
Response:
 Click here to expand...
{
  "meta": {
    "status": 200
  },
  "buckets": [
    {
      "name": "Selenium didn't complete your last command on time.\nFor help, please check https://wiki.saucelabs.com/display/DOCS/Common+Error+Messages",
      "count": 1,
      "items": [
        {
          "id": "8f5nf6370061122bb6ah4ee10a2c966d",
          "owner": "USERNAME",
          "ancestor": "USERNAME",
          "name": "TestScreenshot",
          "creation_time": "2017-03-01T17:47:35Z",
          "end_time": "2017-03-01T17:54:03Z",
          "status": "errored",
          "error": "Selenium didn't complete your last command on time.\nFor help, please check https://wiki.saucelabs.com/display/DOCS/Common+Error+Messages",
          "os": "Linux",
          "browser": "Android 5.1",
          "details_url": "https://saucelabs.com/rest/v1.1/USERNAME/jobs/8f5nf6370061122bb6ah4ee10a2c966d"
        }
      ],
      "has_more": false
    },
    // more errors...
  ]
}


Builds And Tests Statistics

Aggregate all tests into builds and tests without build. Maximum number of returned builds is 25.

GET /rest/v1/analytics/trends/builds_tests
Parameters

os

optional

string, multiple occurrences allowed

Specifies values for the OS filter.

browser

optional

string, multiple occurrences allowed

Specifies values for the Browser filter.


Example of selecting user's builds and tests from March 1st, 2017 to March 2nd, 2017.

curl -u USERNAME:ACCESS_KEY "https://saucelabs.com/rest/v1/analytics/trends/errors?start=2017-03-01T12:00:00Z&end=2017-03-02T12:00:00Z&pretty"
Response:
 Click here to expand...
{
  "meta": {
    "status": 200
  },
  "builds": {
    "items": [
      {
        "name": "build-123",
        "tests_count": 34,
        "duration": 1916,
        "start_time": "2017-03-01T12:09:16Z",
        "end_time": "2017-03-01T12:41:25Z",
        "tests": [
          {
            "id": "a1a2b38812hy42e5affbd54p9757re5t",
            "owner": "USERNAME",
            "ancestor": "USERNAME",
            "name": "TestStatus",
            "creation_time": "2017-03-01T12:09:16Z",
            "end_time": "2017-03-01T12:10:44Z",
            "status": "failed",
            "error": "",
            "os": "Linux",
            "browser": "Android 5.1",
            "details_url": "https://saucelabs.com/rest/v1.1/a-team/jobs/a1a2b38812hy42e5affbd54p9757re5t"
          },
          // up to 10 items
        ],
        "has_more": true,
        "aggs": {
          "status": [
            {
              "name": "complete",
              "count": 23
            },
            {
              "name": "passed",
              "count": 9
            },
            {
              "name": "failed",
              "count": 2
            }
          ]
        }
      },
      // up to 25 builds
    ],
    "has_more": true
  },
  "tests_missing_build": {
    "items": [],
    "has_more": false
  }
}


Tests List

This endpoint is useful if one would like to retrieve more results from the above aggregations. 

GET /rest/v1/analytics/tests
Parameters

build

optional

string

Value of a test build field.

from

optional

non-negative integer

Item position from which data should be returned.

size

required

positive integer

Number of items to return.

missing_build

optional

any value

Returns only tests without a build.

query

optional 

string

Test name filtering the result.

desc

optional 

bool, default is false


If true, the result items will be sorted descending by creation time.

Example of getting next batch of 10 tests with build name equal to "build-123":

curl -u USERNAME:ACCESS_KEY "https://saucelabs.com/rest/v1/analytics/tests?start=2017-03-01T12:00:00Z&end=2017-03-02T12:00:00Z&size=10&from=10&build=build-123"
Response:
 Click here to expand...
{
  "meta": {
    "status": 200
  },
  "items": [
    {
      "id": "50fdd2369eer3031ad912kib57b12440",
      "owner": "USERNAME",
      "ancestor": "USERNAME",
      "name": "TestGet",
	  "build": "build-123",
      "creation_time": "2017-03-01T12:13:39Z",
      "end_time": "2017-03-01T12:16:22Z",
      "status": "complete",
      "error": "",
      "os": "OS X El Capitan (10.11)",
      "browser": "iPhone 10.0",
      "details_url": "https://saucelabs.com/rest/v1.1/a-team/jobs/50fdd2369eer3031ad912kib57b12440"
    },
    // 9 more tests
  ],
  "has_more": true
}

The license could not be verified: License Certificate has expired!

Test Metrics

Aggregate test runs metrics for a given test name.

GET /rest/v1/analytics/insights/test-metrics
Parameters

query

required 

string

Test name filtering the result.

os

optional

string, multiple occurrences allowed

Specifies values for the OS filter.

browser

optional

string, multiple occurrences allowed

Specifies values for the Browser filter.


Example of metrics collected for a test with a name "AnalyticsSeleniumTest on OS X 10.10".

curl -u USERNAME:ACCESS_KEY "https://saucelabs.com/rest/v1/analytics/insights/test-metrics?start=1515687172&end=1516291972&query=AnalyticsSeleniumTest%20on%20OS%20X%2010.10&pretty"
Response:

This result means that there were 1008 reruns of a test with such a name and the average duration is 33 seconds.

 Click here to expand...
{
  "meta": {
    "status": 200
  },
  "aggs": {
    "count": 1008,
    "fastestRun": {
      "id": "1cc127f6af024184a45fc45817672a341",
      "owner": "a-team",
      "ancestor": "a-team",
      "name": "AnalyticsSeleniumTest on OS X 10.10",
      "build": "",
      "creation_time": "2018-01-12T11:50:02Z",
      "start_time": "2018-01-12T11:50:02Z",
      "end_time": "2018-01-12T11:50:27Z",
      "duration": 25,
      "status": "passed",
      "error": "",
      "os": "OS X Yosemite (10.10)",
      "os_normalized": "",
      "browser": "Chrome 51.0",
      "browser_normalized": "",
      "details_url": "https://saucelabs.com/rest/v1.1/a-team/jobs/1cc127f6af024184a45fc45817672a341"
    },
    "slowestRun": {
      "id": "faf35305919245ebaceab93712d009b0",
      "owner": "a-team",
      "ancestor": "a-team",
      "name": "AnalyticsSeleniumTest on OS X 10.10",
      "build": "",
      "creation_time": "2018-01-15T19:10:01Z",
      "start_time": "2018-01-15T19:10:01Z",
      "end_time": "2018-01-15T19:40:59Z",
      "duration": 1858,
      "status": "errored",
      "error": "Test exceeded maximum duration after 1800 seconds",
      "os": "OS X Yosemite (10.10)",
      "os_normalized": "",
      "browser": "Chrome 51.0",
      "browser_normalized": "",
      "details_url": "https://saucelabs.com/rest/v1.1/a-team/jobs/faf35305919245ebaceab93712d009b0"
    },
    "statuses": {
      "errored": 7,
      "failed": 1,
      "passed": 1000
    },
    "totalQueueTime": 0.3843098311817279,
    "totalRunTime": 33.18867924528302
  }
}
  • No labels