I tried using commits rest apibut it's listing the entire commit instead of the expected ones.
Used API like this: https://dev.azure.com/xxx/xxxx/_apis/git/repositories/xxxxx/commits?api-version=7.0&searchCriteria.fromCommitId={fromcommit}&searchCriteria.toCommitId={tocommit}