Search items

You can use the portal service to search for items. Item search is the process of querying the portal service to find users, groups, or different types of content such as maps, scenes, layers, files, services, or apps from templates and builders.

You can use content search to:

  • Search for public or private items.
  • Find different types of items.
  • Sort search results.
  • Return pages of search results.

Search parameters

To search for items, you make an HTTPS request to the portal service and use the search operation. The search operation supports a query string with fields, and operators, such as AND, OR, and NOT. You can perform an open search for text using the default fields or you can search for text in specific fields such as the title, description, or tags. You can also specify a location to search near, or a bounding box to search in by defining the bbox parameter.

The general steps to search for items are:

  1. Define the URL to the portal service: https://www.arcgis.com/sharing/rest/search.
  2. Provide the text for your search. For example, "Streets", or "Elevation level".
  3. Define the item type for your search. For example, Web Map or Feature Service.
  4. Set the sort order for your return results.
  5. Any additional fields, such as tags, date created, or last modified.

URL request

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

Key parameters

NameDescriptionExamples
qThe text or formatted query with text.q="streets", q="streets AND highways", q=(title:"streets" OR description:"streets")
sortFieldThe primary sort field.sortField=numviews, sortField=created, sortField=modified
sortOrderReturn results in ascending or descending order.sortOrder=asc, sortOrder=desc

Additional parameters: To refine the search further, you can use parameters such as bbox, num, start, and categories.

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="streets"
  • To search specific fields, use a colon : after the field name.
  • Use double quotes "text" around all search text.
  • Capitalize all AND, OR, and NOT operators.
  • Use () to group operators.
  • Use the type: field to define the type of items to return. e.g. type: Web Map

For example:

Use dark colors for code blocksCopy
1
https://www.arcgis.com/sharing/rest/search?f=json&q=title:"London Tube" AND type:"Web Map" AND tags:Transportation

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

Code examples using key parameters

Search for text

Find any type of item with the keywords title or description.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS 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
27
28
29
30
31
32
33
34
35
36
37
38
    portal = new Portal(); // Default is "https://www.arcgis.com/sharing/rest"
    portal.load().then(()=>{
      const query = {
        query: ["title:\"Seven Natural Wonders of the World\" OR description:\"Seven Natural Wonders of the World\""]
      };
      portal.queryItems(query).then((response)=>{
        console.log(response);
      });
    });

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
curl https://www.arcgis.com/sharing/rest/search \
-d 'q=title:"Seven Natural Wonders of the World" OR description:"Seven Natural Wonders of the World"' \
-d 'f=pjson'

Search for tags and an owner

Find items by searching for tags and an owner name.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS 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
27
28
29
30
31
32
33
34
35
36
37
38
    portal = new Portal(); // Default is "https://www.arcgis.com/sharing/rest"
    portal.load().then(()=>{
      const query = {
        query: "tags:\"USA Demographics\" AND owner:\"esri\""
      };
      portal.queryItems(query).then((response)=>{
        console.log(response);
      });
    });

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
curl https://www.arcgis.com/sharing/rest/search \
-d 'q=tags:"USA Demographics" AND owner:"esri"' \
-d 'f=pjson'

Search for a type of item

Find items by searching for a type of item. Learn more about the types of items in items.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS 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
27
28
29
30
31
32
33
34
35
36
37
38
        portal = new Portal(); // Default is "https://www.arcgis.com/sharing/rest"
        portal.load().then(()=>{
          const query = {
            query: ["title:\"London Map\" AND type:\"Web Map\""]
          };
          portal.queryItems(query).then((response)=>{
            console.log(response);
          });
        });

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
curl https://www.arcgis.com/sharing/rest/search \
-d 'q=title:"London Map" AND type:"Web Map"' \
-d 'f=pjson'

Search by date

Find items by searching using a range of dates.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS API for PythonArcGIS REST JS
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
            // Date range for the search
            var startDate = "2022-01-01";
            var endDate = "2022-12-31";

            // Construct the query URL
            var queryURL = "https://www.arcgis.com/sharing/rest/search";
            var queryParams = {
                f: "json",
                q: `modified:[${startDate} TO ${endDate}]`,
                num: 10 // Specify the number of results
            };

            // Perform the query
            esriRequest(queryURL, {
                query: queryParams,
                responseType: "json"
            }).then(function (response) {
                // Handle the response
                var results = response.data.results;
                console.log(results);

                // You can process the results and add them to the map as needed
                // For example, add a MapImageLayer with the search results
                var searchLayer = new MapImageLayer({
                    url: results[0].url // Use the URL of the first result
                });

Search for a group

Find groups by searching for a text in the title.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS 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
27
28
29
30
31
32
33
34
35
36
37
38
        portal = new Portal(); // Default is "https://www.arcgis.com/sharing/rest"
        portal.load().then(()=>{
        const query = {
          query: "title: Hikers"
        };
        portal.queryGroups(query).then((response)=>{
          console.log(response);
        });
      });

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
curl https://www.arcgis.com/sharing/rest/community/groups \
-d 'q=title:"hikers"' \
-d 'f=pjson'

Search by extent

Find items near point or a bounding box (extent).

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
      portal = new Portal(); // Default is "https://www.arcgis.com/sharing/rest"
      portal.load().then(()=>{
        const query = {
          query: "snippet: food cart, type: Web Map",
          extent: {
              xmax: "-122.6750",
              xmin: "-122.6750",
              ymax: "45.5051",
              ymin: "45.5051"
            }

        };
      portal.queryItems(query).then((response)=>{
        console.log(response);
      });
    });

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
1
2
3
4
curl  https://www.arcgis.com/sharing/rest/search \
-d 'bbox=-122.6750,45.5051, -122.6750,45.5051' \
-d 'q="food cart" AND type:"web map"' \
-d 'f=pjson'

Code examples using SQL operators

Search for web maps created after a specific date

Find web maps created after January 1st, 2024.

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
specific_date = "2024-01-01"

# Perform a search for web apps created after the specified date
search_query = f"created > '{date}' AND type:'Web Mapping Application'"
results = gis.content.search(query=search_query, item_type="Web Mapping Application")

# Print the search results
print("Search Results:")
for item in results:
    print(f"Web App Title: {item.title}, Item ID: {item.id}, Created Date: {item.created}")

Search for feature layers owned by a user

Find feature layers that are owned by a specifid user

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
owner_username = "owner_username"

# Perform a search for feature layers owned by the specified user
results = gis.content.search(query=f'type:Feature Service AND owner:{username}')

# Print the search results
print("Search Results:")
for item in results:
    print(f"Item Name: {item.title}, Item ID: {item.id}, Owner: {item.owner}")

Search for web apps using tags

Find web applications based on specific tags.

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
tags_to_search = "Enter tags here"  # Example: "visualization, analysis"

# Construct the SQL query to search for web apps with specific tags
sql_query = f"tags LIKE '%{tags}%' AND type:'Web Mapping Application'"

# Perform the search
results = gis.content.search(query=sql_query, item_type='Web Mapping Application', max_items=10)  # Adjust max_items as needed

# Print the search results
print("Search Results:")
for item in results:
    print(f"Web App Title: {item.title}, Web App ID: {item.id}, Tags: {item.tags}")

Search for groups with a certain access type

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
access_type = "public"

# Construct the SQL query to search for groups with the specified access type
sql_query = f"SELECT id, title FROM groups WHERE access='{access_type}'"

# Execute the query
results = gis.groups.search(sql_query)

# Print the search results
print("Search Results:")
for group in results:
    print(f"Group Name: {group.title}, Group ID: {group.id}")

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.