I am new to GitLab and using API calls and am confused on how to make a call to get the repository/project files and metadata. My current API call is as follows:
https://gitlab.com/api/v3/projects?private_token=privateToken
privateToken at the end of the line above is replaced with my private token which I have taken out for obvious security reasons.
This will return to me the json that describes all of the projects I have, but I want to drill down deeper and see the specific information about the files that are stored within each project/repository. On the GitLab API documentation website, it lists this:
GET /projects/:id/repository/files/:file_path
However, since I am new to GitLab and API calls in general I am confused as to how to edit my first link to retrieve this information.
Ideally, I would like to be able to drill down to the project/repository files and metadata within python and not have to edit the first link above, but I am not sure if that is possible. How does GitLab return the json? As a hash table of hash tables, if so, how do I navigate through it?
Any clarification on how to parse through the json and drilling deeper within it would be greatly appreciated!
I am using Python 3.6.1.
Thanks!
Python solution Very useful information about gitlab api.
import gitlab
# private token or personal token authentication
gl = gitlab.Gitlab('https://gitlab.company.be', private_token='dklsfjksldjfkdsjf', api_version=4)
gl.auth()
project = gl.projects.get('path/to/project')
items = project.repository_tree()
print(items)