REST API endpoint's domain for GitLab SaaS account

REST API endpoint’s domain for GitLab SaaS account

Hi there!
I am trying to integrate GitLab with our web application using GitLab API.

What I’d like to do is getting users’ information via this endpoint.
Our account is GitLab SaaS (not self-managed one).

Is it possible to get our users information even if the account is hosted by GitLab?
If so, I’d be happy if I anyone tell me which domain I need to send a HTTP request?


I could get an access token through auth code flow, and then with the token, tried to get users information by sending GET request to the following endpoint(https://gitlab.com/api/v4/users).

What I got is the following response.
It seems like gitlab.com’s users list, not ours.

[
    {
        "id": 10890744,
        "username": "diken1",
        "name": "Diken Ulak",
        "state": "active",
        "avatar_url": "https://secure.gravatar.com/avatar/7efde246838215734cd420c8ec3cbb41?s=80&d=identicon",
        "web_url": "https://gitlab.com/diken1"
    },
    {
        "id": 10890743,
        "username": "VladislavB33",
        "name": "Vladislav Bystrushkin",
        "state": "active",
        "avatar_url": "https://secure.gravatar.com/avatar/092475501cfa23dffece3c669ad7922a?s=80&d=identicon",
        "web_url": "https://gitlab.com/VladislavB33"
    },
    {
        "id": 10890742,
        "username": "drahan88",
        "name": "Andriy Drahanchuk",
        "state": "active",
        "avatar_url": "https://secure.gravatar.com/avatar/38022d3579050925916f7356cd432f3a?s=80&d=identicon",
        "web_url": "https://gitlab.com/drahan88"
    },
    {
        "id": 10890741,
        "username": "AlexanderYarokhovich",
        "name": "AlexanderYarokhovich",
        "state": "active",
        "avatar_url": "https://secure.gravatar.com/avatar/2d2d22ca9ab640f3c68442f8044845c2?s=80&d=identicon",
        "web_url": "https://gitlab.com/AlexanderYarokhovich"
    },

Thanks for taking the time to be thorough in your request, it really helps! :blush:

Hi @taro.sato, welcome to the GitLab Community Forum! :tada:

By default the https://gitlab.com/api/v4/users endpoint will return data on a list GitLab.com users with public profiles. To get information on your users, you’ll likely want to use the Group and Project Members API Group and project members API | GitLab

Alternatively, you can look up individual user information by querying username (GET /users?username=<username>) or user id (GET /users/:id.

2 Likes

@gitlab-greg
Hi Greg!

Thanks for your reply, it helps a lot!
Another question related to Group and Project Members API came up after trying to get users info.

Even though I set my email to public by user settings as the attached screenshot shows, I was not able to get users information with email attribute.

We need to get email attribute in our project, so if you have any idea to solve this issue please give me some advice.

Thanks,