As I explore the ArcGIS API for Python, I'm trying to find a way to extract specific details from all my web services at once. Despite my efforts, I haven't found a straightforward solution. This may sound a little bit silly on my end, but my primary objective is to retrieve the 'last modified' dates of each service under my purview. While I've been able to access this data through the admin REST endpoint, I'm unsure how to extract this using Python. Any insights or guidance on how to accomplish this in Python would be greatly appreicated.
Thanks in advance
Sam
Python learner
Hi Sam,
you could do something like this in the Python API (untested and written from memory, check the docs)
Alternatively you can call the REST interface using the requests module in Python. I usually do a mix of both, but using RESTmore and more!
Regards
Carsten
Do you mean "last modified" for the ArcGIS Item or for the associated data? I have some code that tries to find the last time the data was changed. It only works for hosted feature layers. It does not work on feature layers proxied to an ArcGIS server REST service. For those I resort to detecting when the record count changes - not perfect but good enough. Of course if edit tracking is turned on then that makes it easy but I don't own the feature layers so I can't do that.
datetime.datetime.fromtimestamp(int(arcgis.features.FeatureLayer(<feature_layer_url>).properties['editingInfo']['dataLastEditDate'])/1000)
I apologize for leaving this discussion open for a while. To give you more context, I am attempting to go through all of the services to extract a bulk attribute called 'lastModified'. This attribute will provide me with information on when each service was last published. I was initially trying to accomplish this task through the ArcGIS API, but I'm still struggling to figure it out.
It looks like the "modified" property on each service item aligns with when it was last updated. You'll get some false positives for items that were edited after the service was overwritten but this should be good enough for most purposes. Take another look at Carsten's code for tips on getting the date out in a readable format.