Understanding v5 REST API Response

I am trying to read the data returned by the new version of the api but I am a bit confused. The old api v4.6 had a documentation around the totals and the diff attributes. The documentation of v5 seem to be lacking a bit of information.

I ran the commit report api on one of my repos and I got the following response:
(For sake of Interest, view the GET api call HERE

{
    "totals": {
        "files": 2,
        "lines": 55,
        "hits": 54,
        "misses": 1,
        "partials": 0,
        "coverage": 98.18,
        "branches": 0,
        "methods": 0,
        "messages": 0,
        "sessions": 1,
        "complexity": 0.0,
        "complexity_total": 0.0,
        "complexity_ratio": 0,
        "diff": [
            1,
            1,
            1,
            0,
            0,
            "100",
            0,
            0,
            0,
            0,
            0,
            0,
            0
        ]
    },
    "files": [
        {
            "name": "calculator.py",
            "totals": {
                "files": 0,
                "lines": 24,
                "hits": 24,
                "misses": 0,
                "partials": 0,
                "coverage": 100.0,
                "branches": 0,
                "methods": 0,
                "messages": 0,
                "sessions": 0,
                "complexity": 0.0,
                "complexity_total": 0.0,
                "complexity_ratio": 0,
                "diff": 0
            },
            "line_coverage": [
                [
                    3,
                    0
                ],
                [
                    4,
                    0
                ],
                [
                    5,
                    0
                ],
                [
                    6,
                    0
                ],
            ]
        },
],
...,
"commit_file_url": "https://app.codecov.io/gh/ErnestFistozz/codecov-python/commit/604c71bae5b931d98636d6a26f968041469124c3/tree/"
}

I believe the totals and diff within the new api version is the same with what is explained by v4.6 Totals and Diff .

Can you please direct me to the documentation where

            "line_coverage": [
                [
                    3,
                    0
                ]
            ]

is explained. i.e I wish to understand what do the 3 and the 0 mean exactly. Finally, is there any api that returns the change percentage as shown in the screenshot

NB: I am currently subtracting the old coverage from the new coverage to get the change, just asking if there’s an easier approach

@ErnestFistozz I’m not sure but I can try to take a look. Could you send the the link to the last screenshot you sent?

@tom the project can be found HERE

@ErnestFistozz, I see that we don’t do a good job of explaining the parts of our API response. I’ll see if we can make those changes. But to answer your question, I’m going to do a little guesswork.

line_coverage is an array containing arrays of the format [line number, covered] where covered is 0 if the line has coverage and 1 if the line is not covered.

@tom Thanks. I actually thought that it was something along those lines as well, except I though the 0 or 1 was somehow related to how many times the lines is being called or executed , but thanks, much appreciated.

1 Like

So it turns out our guessing may not be necessarily accurate, I ran an api call to another publicc repo and it returned line_coverage [ [ xxx, 4] ] . so the covered value seems to be something else as it can be greater than 1.

@ErnestFistozz oh bizarre! Would you mind pointing me to where you found that? I’ll dig into our codebase tomorrow and see what I can come up with as well.