Get a user

Fetch details for a single user in the organization.

GET https://chat.fhir.org/api/v1/users/{user_id}

You can also fetch details on all users in the organization.

This endpoint is new in Zulip Server 3.0 (feature level 1).

Usage examples

#!/usr/bin/env python3

import zulip

# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")

# Fetch details on a user given a user ID
user_id = 8
result = client.get_user_by_id(user_id)
# If you'd like data on custom profile fields, you can request them as follows:
result = client.get_user_by_id(user_id, include_custom_profile_fields=True)
print(result)

curl -sSX GET -G https://chat.fhir.org/api/v1/users/12 \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY

You may pass the client_gravatar or include_custom_profile_fields query parameter as follows:

curl -sSX GET -G https://chat.fhir.org/api/v1/users/12 \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY \
    -d 'client_gravatar=true' \
    -d 'include_custom_profile_fields=true'

Parameters

Note: The following parameters are all URL query parameters.

user_id required in path

Example: 12

The target user's ID.


client_gravatar optional

Example: True

Whether the client supports computing gravatars URLs. If enabled, avatar_url will be included in the response only if there is a Zulip avatar, and will be null for users who are using gravatar as their avatar. This option significantly reduces the compressed size of user data, since gravatar URLs are long, random strings and thus do not compress well. The client_gravatar field is set to true if clients can compute their own gravatars.

Defaults to false.


include_custom_profile_fields optional

Example: True

Whether the client wants custom profile field data to be included in the response.

Changes: New in Zulip 2.1.0. Previous versions do no offer these data via the API.

Defaults to false.


Response

Return values

  • user: A dictionary containing basic data on a given Zulip user.

    • email: The Zulip API email address of the user or bot.

      If you do not have permission to view the email address of the target user, this will be a fake email address that is usable for the Zulip API but nothing else.

    • is_bot: A boolean specifying whether the user is a bot or full account.

    • avatar_url: URL for the the user's avatar. Will be null if the client_gravatar query parameter was set to True and the user's avatar is hosted by the Gravatar provider (i.e. the user has never uploaded an avatar).

    • avatar_version: Version for the the user's avatar. Used for cache-busting requests for the user's avatar. Clients generally shouldn't need to use this; most avatar URLs sent by Zulip will already end with ?v={avatar_version}.

    • full_name: Full name of the user or bot, used for all display purposes.

    • is_admin: A boolean specifying whether the user is an organization administrator.

    • is_owner: A boolean specifying whether the user is an organization owner. If true, is_admin will also be true.

      Changes: New in Zulip 3.0 (feature level 8).

    • bot_type: An integer describing the type of bot:

      • null if the user isn't a bot.
      • 1 for a Generic bot.
      • 2 for an Incoming webhook bot.
      • 3 for an Outgoing webhook bot.
      • 4 for an Embedded bot.
    • user_id: The unique ID of the user.

    • bot_owner_id: If the user is a bot (i.e. is_bot is True), bot_owner is the user ID of the bot's owner (usually, whoever created the bot).

      Will be null for legacy bots that do not have an owner.

      Changes: New in Zulip 3.0 (feature level 1). In previous versions, there was a bot_owner field containing the email address of the bot's owner.

    • is_active: A boolean specifying whether the user account has been deactivated.

    • is_guest: A boolean specifying whether the user is a guest user.

    • timezone: The time zone of the user.

    • date_joined: The time the user account was created.

    • delivery_email: The user's real email address. This field is present only if email address visibility is limited and you are an administrator with access to real email addresses under the configured policy.

    • profile_data: A dictionary containing custom profile field data for the user. Each entry maps the integer ID of a custom profile field in the organization to a dictionary containing the user's data for that field. Generally the data includes just a single value key; for those custom profile fields supporting markdown, a rendered_value key will also be present.

      • '{id}': Object with data about what value user filled in the custom profile field with id id.

        • value: User's personal value for this custom profile field.

        • rendered_value: The value rendered in HTML. Will only be present for custom profile field types that support markdown rendering.

          This user-generated HTML content should be rendered using the same CSS and client-side security protections as are used for message content.

Example response

A typical successful JSON response may look like:

{
    "msg": "",
    "result": "success",
    "user": {
        "avatar_url": "https://secure.gravatar.com/avatar/6d8cad0fd00256e7b40691d27ddfd466?d=identicon&version=1",
        "bot_type": null,
        "date_joined": "2019-10-20T07:50:53.729659+00:00",
        "email": "hamlet@zulip.com",
        "full_name": "King Hamlet",
        "is_active": true,
        "is_admin": false,
        "is_bot": false,
        "is_guest": false,
        "is_owner": false,
        "profile_data": {
            "1": {
                "rendered_value": "<p>+0-11-23-456-7890</p>",
                "value": "+0-11-23-456-7890"
            },
            "2": {
                "rendered_value": "<p>I am:</p>\n<ul>\n<li>The prince of Denmark</li>\n<li>Nephew to the usurping Claudius</li>\n</ul>",
                "value": "I am:\n* The prince of Denmark\n* Nephew to the usurping Claudius"
            },
            "3": {
                "rendered_value": "<p>Dark chocolate</p>",
                "value": "Dark chocolate"
            },
            "4": {
                "value": "vim"
            },
            "5": {
                "value": "1900-1-1"
            },
            "6": {
                "value": "https://blog.zulig.org"
            },
            "7": {
                "value": "[11]"
            },
            "8": {
                "value": "zulipbot"
            }
        },
        "timezone": "",
        "user_id": 10
    }
}