ArcGIS Open Data API

2145
4
12-23-2018 12:48 PM
AndreiwidCorrea
New Contributor

Dear

I'm looking for a simple way to get the total number of datasets of an instance under *.opendata.arcgis.com.

The only way I found till now is to call data.json and then iterate through all its results/pages, e.g. https://alcaldiadeguarne-guarne.opendata.arcgis.com/data.json where there are 40 datasets.

I was wondering if could call e.g. api/v2/datasets and provide a filter with a parameter URL like this

https://alcaldiadeguarne-guarne.opendata.arcgis.com/api/v2/datasets?filter[url]=any(alcaldiadeguarne-guarne) 

Can you help me on this?

Thanks.

Tags (1)
0 Kudos
4 Replies
by Anonymous User
Not applicable

Hi Andreiwid,

You can return total datasets by a given source by filtering on the source field and looking at the aggregation values at the bottom of the json document. For example, if you call https://opendata.arcgis.com/api/v2/datasets?filter[source]=Municipio%20de%20Guarne and collapse the data field, you should see something like this:

The docCount aggregation field is what I think you're after, but let me know if I'm on the wrong track.

Best,

Patrick

0 Kudos
AndreiwidCorrea
New Contributor

Hi Patrick!

Thank you for you attention and answer.

Let me expand a lit bit more my needs just to see if you can supply me an extra help.

What I'm doing is automatically get the total number of datasets of many ArcGIS Open Data instances/installations. I only know beforehand the customer's domain (what comes before *.opendata.arcgis.com). So I can't go manually to each customer's instance/installation to check 'owner' attribute. So it came to my mind to rely on the customer ID (I think what comes before *.opendata.arcgis.com) to be a filter choice. I realized that the example I gave before (filter[url]) was not a good choice, as URL attribute doesn't see to be consistent across different instances/installations according to customer ID.

In sum, is there a way to return all datasets of an instance/installation given only the customer ID (what comes before *.opendata.arcgis.com)?

Thank you,

0 Kudos
AndreiwidCorrea
New Contributor

Hi!

After testing a lot of possibilities, I ended up making a sequence of 3 APIs in order to get the number of datasets of a given installation:

  1. ‘data.json’ – returns a list of the first 1,000 datasets of an installation. This API is necessary to extract at least one dataset ID to be use in next request.
  2. ‘/api/v2/datasets/{:id}’ – returns further details about a dataset where it is possible to access the standardized field ‘Owner’ necessary to make next request.
  3. ‘/api/v2/datasets’ – returns all the datasets to a given ‘Owner’ of an installation as well as the nested attribute ‘meta.stats.totalCount’ in the resulting JSON dictionary which finally specifies the number of existing datasets.

My experiments reported the API sequence 1 returns an empty dataset array for some installations. If you are curious about that, see https://data-brookhavenga.opendata.arcgis.com/data.json and https://data-eastlongmeadow.opendata.arcgis.com/data.json.

0 Kudos
hoogw
by
New Contributor III
  1. ‘/api/v2/datasets’ – returns all the datasets to a given ‘Owner’ of an installation as well as the nested attribute ‘meta.stats.totalCount’ in the resulting JSON dictionary which finally specifies the number of existing datasets.

Did you miss type /api/v2/datasets, missing something 

is it /api/v2/datasets/owner/{owner-id}?????

0 Kudos