I just found out an even easier way to get the project id: just see the HTML content of the gitlab page hosting your project. There is an input with a field called project_id, e.g:

<input type="hidden" name="project_id" id="project_id" value="335" />
Answer from codependent on Stack Overflow
🌐
GitLab
forum.gitlab.com › how to use gitlab
Gitlab projects API "Search by project name" - How to Use GitLab - GitLab Forum
April 1, 2024 - Unfortunately they did not put ... the tags from the resource which includes the project name, then I’m using the gitlab projects api Search by Project Name to get the ID of the project so that my ......
🌐
Python GitLab
python-gitlab.readthedocs.io › en › stable › gl_objects › projects.html
Projects - python-gitlab v8.5.0 - Read the Docs
To list the starred projects of another user, see the Users API docs. ... Fetching a list of projects, doesn’t include all attributes of all projects. To retrieve all attributes, you’ll need to fetch a single project ... # Get a project by ID project_id = 851 project = gl.projects.get(project_id) # Get a project by name with namespace project_name_with_namespace = "namespace/project_name" project = gl.projects.get(project_name_with_namespace)
Discussions

Where do I find the project ID for the GitLab API? - Stack Overflow
And the one based on jq: curl -s ... http:///api/v3/projects// | jq '.id 2021-07-14T20:23:48.063Z+00:00 ... Save this answer. ... Show activity on this post. ... Save this answer. ... Show activity on this post. If you know your project name, you can get the project id by using the ... More on stackoverflow.com
🌐 stackoverflow.com
How to get the project details using Gitlab API
Currently i have the below url for my gitlab and i would like to fetch all the projects details of MRs which are open. I know if we provide the project id in the url i could fetch. But it involves lot of manual task to go through all 45 projects and provide the id and retrive the details using ... More on forum.gitlab.com
🌐 forum.gitlab.com
1
0
February 15, 2024
How to get a list of all your Gitlab personal projects via API?
My favourite would probably be https://gitlab.com/api/v4/projects?search=$your_username&search_namespaces=true However, that returns a 500 error for me :/ Alternatively you could do https://gitlab.com/api/v4/projects?owned=true , then iterate through the results and only keep those were the namespace.id matches your personal namespace. More on reddit.com
🌐 r/gitlab
3
3
June 17, 2022
How to get GitLab project name by using Project id in GitLab API - Stack Overflow
I have a script which prints project id with other attributes like allowed to push , allowed to merge I need to replace project name with project id. How is this possible? PROJECT=$(cat /var/opt/gi... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitLab
forum.gitlab.com › how to use gitlab
How to get GitLab project name by using Project id in GitLab API - How to Use GitLab - GitLab Forum
July 19, 2022 - I have a script which prints project id with other attributes like allowed to push , allowed to merge I need to replace project name with project id. How is this possible? PROJECT=$(cat /var/opt/gitlab/.project) TOKEN=$(cat /var/opt/gitlab/.token) URL=$(cat /etc/gitlab/gitlab.rb | grep external_url | grep -vE ‘pages|registry’ | grep -v ^# | cut -f 2 -d “'”) projectId=( $(curl -sS --header “PRIVATE-TOKEN: $TOKEN” “$URL/api/v4/projects?&per_page=100&sort=asc&page=[1-50]”| jq -r ..id) ) for i ...
🌐
GitLab
docs.gitlab.com › gitlab docs › extend › rest api › resources › projects
Projects API | GitLab Docs
REST API to create, retrieve, update, delete, and manage projects and project features.
🌐
GitLab
forum.gitlab.com › how to use gitlab
How to get the project details using Gitlab API - How to Use GitLab - GitLab Forum
February 15, 2024 - Currently i have the below url for my gitlab and i would like to fetch all the projects details of MRs which are open. I know if we provide the project id in the url i could fetch. But it involves lot of manual task to go through all 45 projects and provide the id and retrive the details using ...
🌐
GitLab
docs.gitlab.com › 12.10 › ee › api › projects.html
Sign in · GitLab
By signing in you accept the Terms of Use and acknowledge the Privacy Statement and Cookie Policy.
Find elsewhere
🌐
GitLab
gitlab.com › gitlab.org › gitlab foss › #47909
Add API to search for a project using `path_with_namespace` (#47909) · Issues · GitLab.org / GitLab FOSS · GitLab
June 14, 2018 - "GET /projects?path_with_namespace=:namespace" ### What does success look like, and how can we measure that? This feature will be a success if we could get details only of required project, nothing else, output should contain one result or none. ### Links / references /label ~api ... GitLab AI Context Project: gitlab-org/gitlab-foss Instance: https://gitlab.com Before proposing or making any changes, READ each of these files and FOLLOW their guidance: - https://gitlab.com/gitlab-org/gitlab-foss/-/raw/master/CONTRIBUTING.md — contribution guidelines - https://gitlab.com/gitlab-org/gitlab-foss
🌐
GitLab
forum.gitlab.com › how to use gitlab
Which endpoint should be used to programmatically determine the project ID? - How to Use GitLab - GitLab Forum
June 11, 2024 - Problem to solve Hello, I am currently partially automating the development process in my company. An essential component is a Python script that creates a merge request in Gitlab when certain conditions are met. To do this via the Rest API, you need the project ID.
🌐
University of Toronto
microfluidics.utoronto.ca › help › help
Projects · Api · Help · GitLab
Get a list of all visible projects across GitLab for the authenticated user. When accessed without authentication, only public projects with simple fields are returned. ... This endpoint supports keyset pagination for selected order_by options. When simple=true or the user is unauthenticated this returns something like: ... [ { "id": 4, "description": null, "name": "Diaspora Client", "name_with_namespace": "Diaspora / Diaspora Client", "path": "diaspora-client", "path_with_namespace": "diaspora/diaspora-client", "created_at": "2013-09-30T13:46:02Z", "default_branch": "main", "tag_list": [ "exa
Top answer
1 of 9
98

If only your private token is available, you can only use the API:

PROJECTS

Use the following command to request projects:

curl "https://<host>/api/v4/projects?private_token=<your private token>"

This will return you the first 20 entries. To get more you can add the paramater per_page

curl "https://<host>/api/v4/projects?private_token=<your private token>&per_page=100"

with this parameter you can request between 20and 100 entries (see REST API Pagination documentation).

If you now want all projects, you have to loop through the pages. To get to another page add the parameter page.

curl "https://<host>/api/v4/projects?private_token=<your private token>&per_page=100&page=<page_number>"

Now you may want to know how many pages there are. For that, add the curl parameter --head. This will not return the payload, but the header.

The result should look like this:

HTTP/1.1 200 OK
Server: nginx
Date: Thu, 13 Jul 2017 17:43:24 GMT
Content-Type: application/json
Content-Length: 29428
Cache-Control: no-cache
Link: <request link>
Vary: Origin
X-Frame-Options: SAMEORIGIN
X-Next-Page: 2
X-Page: 1
X-Per-Page: 20
X-Prev-Page:
X-Request-Id: 80ecc167-4f3f-4c99-b09d-261e240e7fe9
X-Runtime: 4.117558
X-Total: 312257
X-Total-Pages: 15613
Strict-Transport-Security: max-age=31536000

The two interesting parts here are X-Totaland X-Total-Pages. The first is the count of available entries and the second the count of total pages.

I suggest to use python or some other kind of script to handle the requests and concat the results at the end.

If you want to refine the search, consult this wiki page: https://docs.gitlab.com/api/projects.html#projects-api

GROUPS

For groups simply replace projects with groups in the curls. https://docs.gitlab.com/api/groups.html#list-groups


UPDATE:

Here is the official list of Gitlab API clients/wrappers: https://docs.gitlab.com/api/rest/third_party_clients/

I highly recommend using one of these.

2 of 9
10

In bash for Gitlab API V4:

#!/bin/bash
GL_DOMAIN=""
GL_TOKEN=""
echo "" > gitlab_projects_urls.txt
for ((i=1; ; i+=1)); do
    contents=$(curl "$GL_DOMAIN/api/v4/projects?private_token=$GL_TOKEN&per_page=100&page=$i")
    if jq -e '. | length == 0' >/dev/null; then 
       break
    fi <<< "$contents"
    echo "$contents" | jq -r '.[].ssh_url_to_repo' >> gitlab_projects_urls.txt
done
🌐
GitLab
forum.gitlab.com › devsecops
How to get all project name associated to a user in gitlab - DevSecOps - GitLab Forum
November 15, 2022 - Can any one help me with the api or way to get project list from gitlab for particular user.
🌐
GitHub
github.com › python-gitlab › python-gitlab › issues › 28
Please implement getting project by namespace/name · Issue #28 · python-gitlab/python-gitlab
August 9, 2014 - Currently gitlab cli supports 'project get' by project id only, while Gitlab API supports getting specific project also by namespace/project_name "Get a specific project, identified by project ID or NAMESPACE/PROJECT_NAME, which is owned...
Author: python-gitlab
🌐
Medium
medium.com › devops-with-valentine › how-to-use-the-gitlab-rest-api-ba4e4ca1fcae
How to use the GitLab REST API. The GitLab API allows you to perform… | by Valentin Despa | DevOps with Valentine | Medium
September 24, 2021 - 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. 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: ... I will call the projects endpoint to get a list of all public projects.
🌐
GitLab
docs.gitlab.com › gitlab docs › extend › rest api › resources › search
Search API | GitLab Docs
To use a filter, include it in your query (for example, a query filename:some_name*). You can use wildcards (*) for glob matching. curl --request GET \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/search?scope=wiki_blobs&search=bye" ... [ { "basename": "home", "data": "hello\n\nand bye\n\nend", "path": "home.md", "filename": "home.md", "id": null, "ref": "main", "startline": 5, "project_id": 6, "group_id": null } ]