curl --request GET \
--url https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"head": {
"reference": "refs/pull/123",
"commitSha": "4f0c2d1e9b8a7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
"coverageCommits": [
{
"tag": "unit",
"commitSha": "4f0c2d1e9b8a7c6d5e4f3a2b1c0d9e8f7a6b5c4d"
}
]
},
"base": {
"reference": "refs/heads/main",
"commitSha": "9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0b",
"coverageCommits": [
{
"tag": "unit",
"commitSha": "9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0b"
}
]
},
"comparisons": [
{
"metric": {
"key": "LCOV",
"name": "Line Coverage",
"description": "Percentage of lines covered by tests",
"category": "coverage",
"inverted": false,
"valueType": "percentage"
},
"base": 87.5,
"head": 87.8,
"change": 0.3,
"unavailableReason": null
}
],
"diffCoverage": {
"key": "DCOV",
"name": "Diff Coverage",
"description": "Line coverage of the lines this pull request added or modified",
"category": "coverage",
"inverted": false,
"valueType": "percentage",
"value": 84.21,
"coveredLines": 16,
"missedLines": 3,
"unavailableReason": null
}
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}Get pull request coverage
Retrieve a pull request’s coverage, as the pull request’s Coverage page shows it: total line coverage at the base and head, and the diff coverage of the lines the pull request adds or modifies. Coverage from every tag is combined, and the diff is the pull request’s current diff. Every section keeps its shape. When a section can’t be computed, its values are null and unavailableReason says why, while the other sections still return: no_coverage (no coverage has been processed for the pull request: none was uploaded, or it is still processing), selective_coverage (the head coverage is a selective upload, which has no total), diff_too_large (GitHub can’t return the diff because it is too large), or no_changed_files (GitHub reports no changed files, which can mean it hasn’t computed the diff yet). As on the pull request’s Coverage page, the pull request’s author needs a Qlty seat when the project is private; otherwise the response is a 403 that links to seat management. See https://docs.qlty.sh/cloud/billing/seats. Requires a user access token from someone who signs in to Qlty with GitHub, because the pull request and its diff are read from GitHub as that user. When the GitHub organization enforces SAML single sign-on and the user’s authorization has lapsed, the response is a 403 that links to https://docs.qlty.sh/cloud/troubleshooting#saml-re-authentication-required; re-authorize, then retry.
curl --request GET \
--url https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qlty.sh/gh/{ownerKeyOrId}/projects/{projectKeyOrId}/pulls/{number}/coverage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"head": {
"reference": "refs/pull/123",
"commitSha": "4f0c2d1e9b8a7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
"coverageCommits": [
{
"tag": "unit",
"commitSha": "4f0c2d1e9b8a7c6d5e4f3a2b1c0d9e8f7a6b5c4d"
}
]
},
"base": {
"reference": "refs/heads/main",
"commitSha": "9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0b",
"coverageCommits": [
{
"tag": "unit",
"commitSha": "9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0b"
}
]
},
"comparisons": [
{
"metric": {
"key": "LCOV",
"name": "Line Coverage",
"description": "Percentage of lines covered by tests",
"category": "coverage",
"inverted": false,
"valueType": "percentage"
},
"base": 87.5,
"head": 87.8,
"change": 0.3,
"unavailableReason": null
}
],
"diffCoverage": {
"key": "DCOV",
"name": "Diff Coverage",
"description": "Line coverage of the lines this pull request added or modified",
"category": "coverage",
"inverted": false,
"valueType": "percentage",
"value": 84.21,
"coveredLines": 16,
"missedLines": 3,
"unavailableReason": null
}
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}{
"errors": [
{
"status": "400",
"title": "Bad Request",
"detail": "The request was invalid."
}
]
}Authorizations
Generate an API token at https://qlty.sh/user/settings/tokens
Path Parameters
Repository owner name (login) or workspace ID
3"acme-corp"
Repository name or project ID
3"my-repo"
Pull request number
x > 0123