Gitlab API for all projects under group
You can also use the recently released Gitlab GraphQL API to query groups by name :
{
group(fullPath: "your_group_here") {
projects {
nodes {
name
description
httpUrlToRepo
nameWithNamespace
starCount
}
}
}
}
You can go to the following URL : https://[your_gitlab_host]/-/graphql-explorer and past the above query
The Graphql endpoint is a POST on "https://$gitlab_url/api/graphql"
An example using curl
and jq
:
gitlab_url=<your gitlab host>
access_token=<your access token>
group_name=<your group>
curl -s -H "Authorization: Bearer $access_token" \
-H "Content-Type:application/json" \
-d '{
"query": "{ group(fullPath: \"'$group_name'\") { projects {nodes { name description httpUrlToRepo nameWithNamespace starCount}}}}"
}' "https://$gitlab_url/api/graphql" | jq '.'
This is fairly handy if you use curl
:
curl --header "PRIVATE-TOKEN: xxxxxxxxxxxxxxx" http://gitlab.your_namespace.com/api/v4/groups/your_group/projects
Adding to @Dante's answer,
This gives first 20 projects in the group.
curl --header "PRIVATE-TOKEN: xxxxxxxxxxxxxxx" https://gitlab.your_namespace.com/api/v4/groups/your_group_id/projects
To get more projects we should add 'page' and 'per_page' parameter.
The below request will fetch you up to 100 projects under requested group.
curl --header "PRIVATE-TOKEN: xxxxxxxxxxxxxxx" https://gitlab.your_namespace.com/api/v4/groups/your_group_id/projects?&per_page=100" .
If you now want all projects, you have to loop through the pages. Change the page parameter.
Add json_pp to your request to get a nicely formatted output.
curl --header "PRIVATE-TOKEN: xxxxxxxxxxxxxxx" https://gitlab.your_namespace.com/api/v4/groups/your_group_id/projects | json_pp