Search users

You can use the portal service to search for users. This operation allows authenticated users to search for other members in the portal.

The portal search index is updated whenever users are created, updated, or deleted. The results from a search are limited to searching members that are visible to the portal. This is based on permissions, which members can manage by adjusting their access settings.

You can search for users based on:

  • Keywords like names, usernames, and email addresses.
  • Filtering specific criteria such as role, department, or location in a member profile.
  • Wildcard characters (* or %) search to narrow results based on patterns.
  • Attributes such as creation date, last login time or permissions.

Search parameters

The general steps to search for users are:

  1. Define the URL to the portal service: https://www.arcgis.com/sharing/rest/community/users.
  2. Provide the text for your search. For example, username or fullName.
  3. Set the sort order for your return results.
  4. Any additional fields, such as description, tags, created or modified.

URL request

Use dark colors for code blocksCopy
1
https://www.arcgis.com/sharing/rest/community/users?<parameters>

Default fields

When searching for text in items or groups, if you do not provide fields, the following default fields are searched.

ItemsGroups
titletitle
tagstags
descriptiondescription
snippetsnippet
tagKeywordsowner

Key parameters

NameDescriptionExamples
qThe text or formatted query with text.q="streets"
q="john+smith"
q=(firstName:"john" OR lastName:"smith")
filterApply structured filtering using field name.filter=firstName:"john"
filter=lastName:"john"
sortFieldThe primary sort field.sortField=username
sortField=created
sortField=modified
sortField=fullname
sortOrderReturn results in ascending or descending order.sortOrder=asc
sortOrder=desc

Query structure

Here are a some of the general rules for formatting queries:

  • For an open search, specify the text at the beginning. e.g. q="john+smith"
  • To search specific fields, use a colon : after the field name.
  • Use double quotes "text" around all user search text.
  • Capitalize all AND, OR, and NOT operators.
  • Use () to group operators.

For example:

Use dark colors for code blocksCopy
1
https://www.arcgis.com/sharing/rest/community/users?f=json&q="john"

Code examples

Search for a user by username

Find users with the keyword username.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
search_username = "desired_username"

# Search for users by username
user_results = gis.users.search(search_username)

# Print the results
for user in user_results:
    print("Username:", user.username)
    print("Full Name:", user.fullName)
    print("Email:", user.email)
    print("Account Type:", user.userType)
    print("Role:", user.role)

Search for users by email

Find users with the keyword user's email.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
email = "example@email.com"

# Search for users by email
user_search = gis.users.search(email=email)

# Iterate through search results
for user in user_search:
    print("Username:", user.username)
    print("Full Name:", user.fullName)
    print("Email:", user.email)
    print("Role:", user.role)
    print("User Type:", user.userType)
    print("Account Level:", user.level)

Search for users by full name

Find users by full name using the keyword user's name.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
full_name = "John Doe"

# Perform the search
search_results = gis.users.search(full_name)

# Print search results
for user in search_results:
    print("Username:", user.username)
    print("Full Name:", user.fullName)
    print("Email:", user.email)
    print("Role:", user.role)

Search for users by user type

Find users based on specific user types.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
user_type = "creator"  # Replace with the desired user type

# Search for users by user type
search_results = gis.users.search(query="userType:" + user_type)

# Print the search results
for user in search_results:
    print("Username:", user.username)
    print("Full Name:", user.fullName)
    print("Email:", user.email)
    print("User Type:", user.userType)

Search for users by specific group

Find users based on specific group names.

ArcGIS API for PythonArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Define the list of group names to search for
group_names = ['Group1', 'Group2', 'Group3']

# Empty list to store matching users
matching_users = []

# Loop through each group name
for group_name in group_names:
    # Retrieve the group object by name
    # Assuming there is only one group with the specified name
    group = gis.groups.search(group_name)[0]

    # Retrieve the users who are members of the group
    group_users = group.get_members()

    # Add users to the matching_users list
    matching_users.extend(group_users)
Expand

Tools

Use tools to access the portal and create and manage content for applications.

Services

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.