Gitlab API for downloading plain diff for a merge request

How can I download plain diff for a gitlab merge request? There is an option in the UI. Is there a way to do this using API/python SDK?

Hi did you check the Gitlab API docs? Merge requests API | GitLab seems to mention stuff about pulling diffs for merge requests.

1 Like

Yes. I checked it. There is an API which gives the diffs in JSON format. However, if the changes are too many, it does not give all the diffs. On UI, I can get the plain diffs using<namespace>/<project>/-/merge_requests/<mr_iid>.diff but this output is not available through API.

Yes, it’s subject to limits - at the end of that particular API it says:

which when clicking that link, also allows us to read:

don’t see any real way to obtain results, other than perhaps combining the results from the first command, and obtaining more details using another API: Merge requests API | GitLab and looping through.

1 Like

Looping over the response of the Diff versions API does not solve the purpose. I can see over 1000 diffs in the plain diff downloaded from UI but can’t find a way to get the same through API. I would appreciate any help provided to conquer this scenario.

If none of the aforementioned diff API options in the link provided don’t help, then it would seem it’s not possible. In which case, you could open an issue here: Issues · / GitLab · GitLab and ask if someone could develop/code for a future version of Gitlab such a possibility to do it via API.

1 Like