New in 2.4: Test runs you can trust See what's new →

Get salary statistics overall and per department

GEThttps://api.testingapis.com/api/Employees/stats

Responses

200
Totals, active count, average salary, and count/average/min/max salary per department.

Example

Request
curl -X GET "https://api.testingapis.com/api/Employees/stats"
Run in Studio
Response200 OK
{
  "totalEmployees": 28,
  "activeEmployees": 26,
  "averageSalary": 175571.43,
  "departments": [
    {
      "department": "Design",
      "count": 2,
      "averageSalary": 110000,
      "minSalary": 86000,
      "maxSalary": 134000
    },
    {
      "department": "Engineering",
… (8 more lines)

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/Employees/stats");
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "GET",
    "https://api.testingapis.com/api/Employees/stats",
    allow_redirects=False,
)
print(response.status_code, response.text)
Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newBuilder()
            .followRedirects(HttpClient.Redirect.NEVER)
            .build();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.testingapis.com/api/Employees/stats"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}