How to have diff URL starting from a commit ID?

Hi,
is there a way, starting from https://api.github.com/repos/user/repo/commits/d07c8960xxxxx79e839f8d8f to have the commit ID of the previous version, to be able to run something like

https://api.github.com/repos/repos/user/compare/d07c8960xxxxx79e839f8d8f...2b58c5fxxxxxx44f3b79a0371378da3db6

Thank you