Gitlab API to get total number of files in a directory

We have a directory in a project where it has more than 100 files,
We need to get all files from the repository with the api call.
Currently using the api
/api/v4/projects/{projectid}/repository/tree?ref=###& pagination=keyset&per_page=1000.
But it only returns first 100 record.
Please advise how to retrieve all the record or to get no of files present.

Hi :facepunch:
You can approach this issue by using / writing a small python script
Use chatgpt to generate one, should be pretty straight forward

Pagination limit is 100, so you would have to write a script as @doctor3182 said for you to iterate over the number of pages until you finally get the full list.

1 Like

is there any api to get number of files(count) present in the directory…, so that we would iterate that may times to get full list?

All the API endpoints are documented here: REST API resources | GitLab did you check through all of those? If you did, and didn’t find one, then you would need to do as explained and script it to iterate through each page listing of files until you get to the end. Whether you set a page limit of 10 or 100 at this point doesn’t matter too much, it’ll probably take the same amount of time anyway depending on how quick the API responses are for listings of 10 or 100 per page.