Search code examples
gitlabgitlab-api

Gitlab API filter projects by topic (project tag)


I'm in trouble filtering projects by "tag" with the api (named topics in project settings).

I would get the same result as the following UI query https://gitlab.xxxxxx.com/explore/projects?tag=ruby

It returns all project that are tagged with the "ruby" topic.

Here is an example of result I have with the api when describing a single project:

curl --header "Authorization: Bearer $GITLAB_TOKEN" "https://gitlab.hostname.com/api/v4/projects/42?simple=true" | json_pp
...
"tag_list" : [
  "ruby"
],
...

According to the documentation (https://docs.gitlab.com/ce/api/projects.html#list-all-projects) I should be able to filter on project tag_list using topic parameter

curl --header "Authorization: Bearer $GITLAB_TOKEN" "https://gitlab.hostname.com/api/v4/projects?topic=ruby&simple=true" | json_pp

But this query returns all my projects, even those without any tag or the wrong ones

I tried using "tag" or "tag_list" instead of "topic" but nothing worked as I expected

Is someone have an idea on how to proceed ?

Note that I'm using gitlab CE 13.9


Solution

  • As you mentioned, you're using gitlab version 13.9 and the ability of filtering projects by tag_list or topic has come with version 14 and later.

    See: https://docs.gitlab.com/13.11/ee/api/projects.html#list-all-projects