Learn how to use the portal service to list items in the portal.
An access token is not needed in this tutorial because you will be searching for public items from the portal. However, an access token from OAuth 2.0 credentials is needed to access private items. The use of API keys is not supported to perform private search.
Prerequisites
You need an ArcGIS Location Platform, ArcGIS Online, or ArcGIS Enterprise account to use your portal.
Steps
Set up environment
- In a different window, launch Postman and create a blank request.
- If you are using the CDN libraries, to get started.
- Install the ArcGIS API for Python.
- Start your Jupyter Notebook environment locally.
- To get started, .
Perform a search
request
- Set the request type to
GET
. - In the URL field, type in
https:
.//www.arcgis.com/sharing/rest/search - Set the
f
parameter topjson
in the parameter list. - Set the
q
parameter totype:
in the parameter list."Web Map" - Run the request.
GET https://www.arcgis.com/sharing/rest/search?q=type:"web map" HTTP/1.1
&f=pjson
-
Import the
request
method from thearcgis
global.Rest Use dark colors for code blocks <script> const { request } = globalThis.arcgisRest; </script>
-
Create a variable called
search
and set its value as the portal service URL, e.g.Endpoint https:
.//www.arcgis.com/sharing/rest/search Use dark colors for code blocks <script> const { request } = globalThis.arcgisRest; const searchEndpoint = 'https://www.arcgis.com/sharing/rest/search'; </script>
-
Create a variable
search
and set its value as your search criteria, e.g.Keyword type:
. To see other available query parameters, go to Search parameters."Web Map" Use dark colors for code blocks <script> const { request } = globalThis.arcgisRest; const searchEndpoint = 'https://www.arcgis.com/sharing/rest/search'; const searchKeyword = 'type="Web Map"'; </script>
-
Construct the search parameters with an object called
search
. Pass in your search keyword andParams f:
in the object to format the response into a JSON format.json Use dark colors for code blocks <script> const { request } = globalThis.arcgisRest; const searchEndpoint = 'https://www.arcgis.com/sharing/rest/search'; const searchKeyword = 'type="Web Map"'; const searchParams = { q: searchKeyword, f: 'json', }; </script>
-
Execute the call and print the
JSON
response.Use dark colors for code blocks <script> const { request } = globalThis.arcgisRest; const searchEndpoint = 'https://www.arcgis.com/sharing/rest/search'; const searchKeyword = 'type="Web Map"'; const searchParams = { q: searchKeyword, f: 'json', }; request(searchEndpoint, { params: searchParams }) .then(response => { console.log(response); }) .catch(error => { console.error(error); }); </script>
-
Add the following import statement to your code.
main.pyUse dark colors for code blocks from arcgis.gis import GIS
-
Establish a connection to the portal using the
GIS()
module.main.pyUse dark colors for code blocks from arcgis.gis import GIS gis = GIS() ## Default portal: "https://arcgis.com/"
-
Create a variable called
query
with a value oftype='web map'
to only list web maps in the search results.main.pyUse dark colors for code blocks from arcgis.gis import GIS gis = GIS() ## Default portal: "https://arcgis.com/" query = "type: 'web map'"
-
Pass in the query parameter to the
search
operation.main.pyUse dark colors for code blocks from arcgis.gis import GIS gis = GIS() ## Default portal: "https://arcgis.com/" query = "type: 'web map'" results = gis.content.search(query) print(results)
-
Add the following
require
statement to your code.Use dark colors for code blocks require(["esri/request"], (esriRequest) => { });
-
Create a variable called
url
and set its value as the portal service URL, e.g.https:
.//www.arcgis.com/sharing/rest/search Use dark colors for code blocks require(["esri/request"], (esriRequest) => { const url = "https://www.arcgis.com/sharing/rest/search"; });
-
Create an object called
options
and define your search parameters, e.g.type:
and"Web Map" f:
. To see other available query parameters, go to Search parameters.pjson Use dark colors for code blocks require(["esri/request"], (esriRequest) => { const url = "https://www.arcgis.com/sharing/rest/search"; const options = { query: { q: 'type:"Web Map"', f: "pjson" } }; });
-
Execute the call and print the
JSON
response.Use dark colors for code blocks require(["esri/request"], (esriRequest) => { const url = "https://www.arcgis.com/sharing/rest/search"; const options = { query: { q: 'type:"Web Map"', f: "pjson" } }; esriRequest(url, options).then((response) => { const data = response.data; console.log(data); }); });
View the results
The output of your search
operation should look something like this, but with content that meets your search criteria:
{
"total": 10000,
"start": 1,
"num": 10,
"nextStart": 11,
"results": [
{
"id": "86265e5a4bbb4187a59719cf134e0018",
"owner": "esri",
"created": 1364516917000,
"modified": 1716225900000,
"guid": null,
"name": null,
{
"total": 10000,
"start": 1,
"num": 10,
"nextStart": 11,
"results": [
{
"id": "86265e5a4bbb4187a59719cf134e0018",
"owner": "esri",
"created": 1364516917000,
"modified": 1716225900000,
"guid": null,
"name": null,
[<Item title:"Celebrating Lost Loved Ones" type:Web Mapping Application owner:jlindemann_rx>, <Item title:"Social Media flooding map" type:Web Mapping Application owner:EsriUKedteam>, <Item title:"Základní mapy České republiky (S-JTSK)" type:Web Map owner:Czech_user_community>, <Item title:"True Geography of the London Underground" type:Web Map owner:Esri_UK>, <Item title:"ArcGIS Viewer for Flex HeatMapWidget" type:Web Mapping Application owner:Heberlie>, <Item title:"Web application - Map tour" type:Web Mapping Application owner:bart_opleidingen>, <Item title:"Table of Contents (TOC)/Legend Widget for JavaScript API" type:Web Mapping Application owner:nliu>, <Item title:"Britten Wilder-Autobiography of Author Britten Wilder" type:Web Scene owner:brittenwilder>, <Item title:"Wander-Routen-Map - Landkreis Cham" type:Web Map owner:LandkreisCham>, <Item title:"ORADEA,AEROPORTURI,DISTANTA SI AGREMENT" type:Web Map owner:EmiEmanuel>]
{
"total": 10000,
"start": 1,
"num": 10,
"nextStart": 11,
"results": [
{
"id": "86265e5a4bbb4187a59719cf134e0018",
"owner": "esri",
"created": 1364516917000,
"modified": 1716225900000,
"guid": null,
"name": null,
What's next
![](/documentation/static/access-feature-layer-data-fe6f3f2d53d5ce5d3207e3b43c9c6c59.png)
Copy a hosted layer item
Use the portal service to copy a hosted layer item in your portal.
![](/documentation/static/access-feature-layer-data-fe6f3f2d53d5ce5d3207e3b43c9c6c59.png)
Set sharing level for an item
Use the portal service to set the sharing level for an item in your portal.
![](/documentation/static/access-feature-layer-data-fe6f3f2d53d5ce5d3207e3b43c9c6c59.png)
Create a new group and add members
Use the portal service to create a new group and add members in your portal.