Gitlab api

Hi
Is there a good resource with examples on how to use the gitlab api?
I have read the docs but they dont really start at he beginning.

Cheers

1 Like

It depends on what you want to accomplish, though, trying https://github.com/NARKOZ/gitlab may be a good start. Itā€™s a ruby wrapper to access GitLab API - you can fetch data from any gitlab instances including gitlab.com and on-premises.

GitLab APIs are just REST apiā€™s. Try googling ā€œREST API tutorialā€.
If you have any specific question, post a new question in this forum again. Be sure to specify which language and environment you are using.

FYI, REST apiā€™s can be called from bash script using command such as curl, from language such as Java and Python.

Try entering the uri from your web browser to test the uri.
e.g. (get list of private repo)
https:///api/v3/projects/?simple=yes&private=true&per_page=2&page=1"

Next, youā€™ll need to get authentication. The simplest way is to use private token.
https://docs.gitlab.com/ee/api/#personal-access-tokens

If you are on Linux, you can just use curl command.
curl --header "PRIVATE-TOKEN: " --insecure ā€œhttps:///api/v3/projects/?simple=yes&private=true&per_page=2&page=1ā€

You can similarly just call other apis listed in gitlab api documentation.
e.g. (to add a new user)
curl -H ā€œPRIVATE-TOKEN: " -H ā€˜Content-Type:application/jsonā€™ -H ā€˜Accept:application/jsonā€™ -X POST -d '{ā€œemailā€:ā€",ā€œpasswordā€:"",ā€œusernameā€:"",ā€œnameā€:""}ā€™ https:///api/v4/users

1 Like

Many thanks

@hozawa

GitLab API for Sub-group owners

is there any way to get a list of sub-groups and their corresponding owners through GitLab API.

Note that the list shouldnā€™t include ā€œProjectsā€. It should list out ā€œsub-groupsā€ only.