How to use the GitLab REST API
The GitLab API allows you to perform many of the actions you typically do when using the user interface. Using the API allows us to automate the process and eliminate any user interaction.
The GitLab API comes in two flavors: the REST API and the GraphQL API. For people just getting started with APIs, the REST API is much easier to understand and use. So this is what I will be demoing in this tutorial.
How to use the GitLab REST API
The GitLab API specification defines various endpoints based on the action we want to perform.
Let’s do a simple request using Postman.
I am using gitlab.com, so the GitLab API base URL will be this:
If you are self-hosting GitLab, your base URL will look like this:
I will call the projects
endpoint to get a list of all public projects.
If you want to get details about a project, all you need is to append the project id to the URL.