abas
abas

Reputation: 17

How to get GitLab project name/URL by using Project id in GitLab API

Is there a way to search for GitLab projects by Project ID?

Thank you.

Upvotes: 1

Views: 5273

Answers (1)

Igor Drozdov
Igor Drozdov

Reputation: 15045

It's possible to get single project by requesting /projects/:id endpoint: https://docs.gitlab.com/ee/api/projects.html#get-single-project

For example:

curl https://gitlab.com/api/v4/projects/278964

The response is going to contain name, ssh_url_to_repo, http_url_to_repo, web_url, etc:

{
  "id": 3,
  "description": null,
  "default_branch": "master",
  "visibility": "private",
  "ssh_url_to_repo": "[email protected]:diaspora/diaspora-project-site.git",
  "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
  "web_url": "http://example.com/diaspora/diaspora-project-site",
  "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md",
  "tag_list": [ //deprecated, use `topics` instead
    "example",
    "disapora project"
  ],
  "topics": [
    "example",
    "disapora project"
  ],
  "owner": {
    "id": 3,
    "name": "Diaspora",
    "created_at": "2013-09-30T13:46:02Z"
  },
  "name": "Diaspora Project Site",
  "name_with_namespace": "Diaspora / Diaspora Project Site",
  "path": "diaspora-project-site",
  "path_with_namespace": "diaspora/diaspora-project-site",
  "issues_enabled": true,
...

Upvotes: 3

Related Questions