Generating a link to the compare diff result of a single file

I understand that there is a compare API where you can provide a commits or branches for comparison.

gitLabApi.repositoryApi.compare

This returns the diffs fine but what I’d like to generate next is a link to a GitLab compare page to a given file. Say I have a commit change that’s modified 3 files, I want to provide a URL link to the diff of the last file say.

I see on the Compare web page that there is a dropdown like ‘Showing 2 changed files’ which provides links to the differing files. I’d like to reference these links too but I can’t see where the last hash in the URL’s are coming from to derive it in my code.

e.g.

https://…-/compare/master…caa803cae0b8dc2f7e8307d1248b7c72fe6463db#829fe3af42f5d5ec5d31291014745ed756b4a7ba

I thought that the sha after the # would be just be the blob Id but it doesn’t seem to be. Any suggestions?