4

For example I want to receive only project names: https://gitlab.com/api/v4/groups/:id/projects?fields=name

Is that possible?

graceman9
  • 608
  • 2
  • 8
  • 20

3 Answers3

3

That's not possible in the REST API. But, GitLab is working on GraphQL support, and you'd be able to express that in GraphQL.

https://docs.gitlab.com/ee/api/graphql/

King Chung Huang
  • 5,026
  • 28
  • 24
3

To iterate on Vonc & King Chung Huang 's answers, using the following GraphQL query, you can get only the name field of the projects inside your group :

{
  group(fullPath: "your_group_name") {
    projects {
      nodes {
        name
      }
    }
  }
}

You can go to the following URL : https://$gitlab_url/-/graphql-explorer and past the above query

Using & :

gitlab_url=<your gitlab host>
access_token=<your access token>
group_name=<your group name>

curl -s -H "Authorization: Bearer $access_token" \
     -H "Content-Type:application/json" \
     -d '{ 
          "query": "{ group(fullPath: \"'$group_name'\") { projects { nodes { name }}}}"
      }' "https://$gitlab_url/api/graphql" | jq '.'
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
2

GitLab 1.11 (May 2019) has now introduced a "basic support for group GraphQL queries "

GraphQL APIs allows users to request exactly the data they need, making it possible to get all required data in a limited number of requests.

In this release, GitLab is now supporting basic group information support in the GraphQL API.

See Issue 60786 and documentation: "Available queries"

A first iteration of a GraphQL API includes the following queries

  • project : Within a project it is also possible to fetch a mergeRequest by IID.
  • group : Only basic group information is currently supported.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250