How to get the latest commit date of the file along with content details from GitHub API call

I have used the below GitHub api and i’am able to get the files details of the path.

[https://github.***.com/api/v3/repos/exampleowner-Management/examplerepo/contents/Compile/Teradata/Tables?access_token=*****](https://github. .com/api/v3/repos/exampleowner-Management/examplerepo/contents/Compile/Teradata/Tables?access_token=** )

The result of this API call is :

    "name": ".DS_Store",
    "path": "Compile/Tables/test.ddl",
    "sha": "1cef8efa8694678e3b7ab230a6a891afa1a1996d",
    "size": 8196,
    "url": "***",
    "html_url": "***",
    "git_url": "***",
    "download_url": "***",
    "type": "file",
    "_links": {
        "self": "***",
        "git": "***",
        "html": "***"

I have checked in github and the commitid for this file is not showing the same one which was given in the 'sha ’ key value.

is this API returning some other value in sha?

What i actually need is the download url for the file,commit id and commited date informations.

I have tried using another API ,which is :

[https://github.***.com/api/v3/repos/exampleowner-Management/examplerepo/commits/1cef8efa8694678e3b7ab230a6a891afa1a1996d?access_token=*****](https://github. .com/api/v3/repos/exampleowner-Management/examplerepo/commits/1cef8efa8694678e3b7ab230a6a891afa1a1996d?access_token=** )

but the response of this API for this sha is:

"message": "Not Found",
"documentation_url": ""}

does anyone have a solution for this issue.i have tested for other files also and the ‘sha’ value is different from the commit id showing in github.

finally got the expected result by using is the complete code

def run_query(query): # A simple function to use to make the API call. Note the json= section.
        request ='https://api.github.***.com/graphql', json={'query': query}, headers=headers)
        return request.json()
    except e:
        returnVal = '404'

            query = """
                          repository(owner: \""""+ownerVal+"""\", name: \""""+repoVal+"""\") {
                            object(expression: \""""+branchVal+"""\") {
                              ... on Commit {
                                blame(path: \""""+folderVal+"/"+data['name']+"""\") {
                                  ranges {
                                    commit {

result = run_query(query)

commit_date = result["data"]["repository"]["object"]["blame"]["ranges"][0]["commit"]["committedDate"]
1 Like