Gitlab api

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.


1 Like

It depends on what you want to accomplish, though, trying may be a good start. It’s a ruby wrapper to access GitLab API - you can fetch data from any gitlab instances including 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)

Next, you’ll need to get authentication. The simplest way is to use private token.

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