How to find Gitlab group ID using Gitlab API via python-gitlab
pip install python-gitlab
import gitlab
def get_gitlab_group_id(group_name, access_token):
# Initialize a GitLab instance with your private token
gl = gitlab.Gitlab('https://gitlab.com', private_token=access_token)
# Search for groups by name
groups = gl.groups.list(search=group_name)
for group in groups:
if group.name == group_name or group.path == group_name:
return group.id
raise ValueError("Group not found")
# Usage example
group_id = get_gitlab_group_id("Protectors of the Footprint Realm", 'glpat-yykIsrTg6RyKcFAvd2os')
group_id
will be an integer, for example 6604163