4

Is there any way I can get a list of REST services being consumed in ArcGIS Online?

I am an admin on our account and just trying to see where our REST Services are being used.

Rather then open each map or application in ArcGIS Online. I thought there may be someway of ArcGIS Online doing it for me. Or some other tool that could do it.

  • There is a tab in agol which will give you that statistics. My organization somewhere – FelixIP May 24 '16 at 1:21
1

For this kind of administration/maintenance I have been using ArcREST for some good time and I really like it.

You would need to download the ArcREST from GitHub and install it, see instructions on the website.

Here is a snippet of code for listing out which webmaps contain an operational layer you specify (in the form of service REST URL).

from arcrest.manageorg import Administration
from arcrest import AGOLTokenSecurityHandler

from libs configuration

agol_securityHandler = AGOLTokenSecurityHandler(configuration.agol_admin_username,
                                                configuration.agol_admin_password,
                                                configuration.agol_org_url)

agol_org_obj = Administration(securityHandler=agol_securityHandler,initialize=True)

#----------------------------------------------------------------------
def webmap_to_json(webmap_id):
    """Return json object with web map properties"""
    item_obj = agol_org_obj.content.getItem(webmap_id)
    #print item_obj.type, item_obj.item
    return item_obj.itemData(f='json')

#----------------------------------------------------------------------
def get_user_webmaps(username):
    """Return a list of webmap objects found in user's My Content"""
    user_obj = agol_org_obj.content.users.user(username)
    return [item for item in user_obj.items if item.type == 'Web Map']

#----------------------------------------------------------------------
def find_usepoints(service_url):
    """Return a list of tuples (webmap id,webmap title) where a service is used"""
    webmaps = get_user_webmaps('ownerusername')
    founded = []
    for webmap in webmaps:
        webmap_json = webmap_to_json(webmap.id)
        oper_lyrs_dict = webmap_json['operationalLayers']
        if any(service_url in url for url in [d['url'] for d in oper_lyrs_dict]):
            founded.append((webmap.id,webmap.title))
    return founded

search_url = 'http://localhost:6080/arcgis/rest/services/SampleWorldCities/MapServer'

print find_usepoints(search_url)

The URL to search for can be any URL that can be used within a web map (an ArcGIS Server service or Hosted Feature Service). You don't to specify the path to the particular layer within the service as substrings will be found within the list (in other words, it is sufficient to provide http://localhost:6080/arcgis/rest/services/SampleWorldCities as all URLs that have this string in them will be found (such as http://localhost:6080/arcgis/rest/services/SampleWorldCities/MapServer/0).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.