Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nickpeihl/ags-walk

Walks an ArcGIS Server Rest API and returns all services
https://github.com/nickpeihl/ags-walk

arcgis arcgis-server gis node

Last synced: about 2 months ago
JSON representation

Walks an ArcGIS Server Rest API and returns all services

Awesome Lists containing this project

README

        

# ags-walk

Walk the folders of an ArcGIS Server Rest API and return all the services as an
array

## about

[ArcGIS Server](http://server.arcgis.com) is GIS software used by many federal, state, and municipal governments and organizations to publish web-enabled GIS data. ArcGIS Server uses the [GeoServices API](https://geoservices.github.io/). This module walks the services and folders of the root GeoServices API for a given URL and returns all services and service types in an array. This could be used to create a repository of dataset names from one or more ArcGIS Server REST URLs.

Links to each dataset URL can be made by concatenating the root GeoServices URL with the dataset item and dataset type. For example, if the root URL is `http://sampleserver6.arcgisonline.com/arcgis/rest/services` and one of the datasets in the array is `{ name: '911CallsHotspot', type: 'MapServer' }` the full URL to the service is `http://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/MapServer`.

## command line

With Node v8.2.0+ it is not necessary to install ags-walk. You can run:

`npx ags-walk [options]`

See example and available options by entering

`npx ags-walk -h`

## install

To use as a dependency in a Node.js library you can install ags-walk by running:

`npm i ags-walk`

then include

`var agsWalk = require('ags-walk')`

in your script file.

For the browser include the tag:
``
and `agsWalk()` is added as a global function.

## api

### agsWalk

Walk the folders of an ArcGIS Server Rest API
and return all the services as an array

**Parameters**

- `url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the base url of an ArcGIS Server Rest API
- `opts` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** options for the module
- `opts.limit` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the maximum number of folders to
index at the same time (optional, default `5`)
- `cb` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** the callback function to run after
results have been returned

**Examples**

```javascript
// returns [{ name: 'Elevation/earthquakedemoelevation, type: 'MapServer'}...]
agsWalk('http://sampleserver6.arcgisonline.com/arcgis/rest/services', function(err, services) {
if (err) throw err
return services
}
```

Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>**

## license

Copyright 2017 Nick Peihl

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.