<!-- format instructions http://pythonhosted.org/sphinxcontrib-httpdomain/# -->

# Resources

<a id="ngwdev-resource-classes"></a>

## Resource classes

The current list of resource classes:

* resource_group
* postgis_layer
* wmsserver_service
* baselayers
* postgis_connection
* webmap
* wfsserver_service
* vector_layer
* raster_layer
* mapserver_style
* qgis_vector_style
* raster_style
* file_bucket
* lookup_table
* wmsclient_layer
* wmsclient_connection
* formbuilder_form
* trackers_group
* tracker
* collector_project

## HTTP API

### Version

#### Versionadded
Добавлено в версии 3.0.

To get NextGIS Web API version execute the following request:

### GET /api/component/pyramid/pkg_version

**Example request**:

```http
GET /api/component/pyramid/pkg_version HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example JSON response**:

```json
{
   "nextgisweb": "2.0",
   "nextgisweb_mapserver": "0.0dev"
}
```

### Routes

#### Versionadded
Добавлено в версии 3.0.

Routes are the REST API URLs which are supported by current instance of NextGIS
Web. To get possible routes execute the following request:

### GET /api/component/pyramid/route

**Example request**:

```http
GET /api/component/pyramid/route HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example JSON response**:

```json
{
    "pyramid.settings": [
        "/api/component/pyramid/settings"
    ],
    "feature_layer.feature.update": [
        "/resource/{0}/feature/{1}/update",
        "id",
        "feature_id"
    ],
    ...
    "pyramid.statistics": [
        "/api/component/pyramid/statistics"
    ],
    "feature_layer.feature.item": [
        "/api/resource/{0}/feature/{1}",
        "id",
        "fid"
    ],
    "pyramid.pkg_version": [
        "/api/component/pyramid/pkg_version"
    ]
}
```

### Schema

Schema request returns list of supported NextGIS Web resources, each resource type
properties and metadata.

### GET /resource/schema

Schema request.

#### NOTE
REST API requests require accept field in header with following text: Accept: \*/\*

**Example request**:

```http
GET /resource/schema HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example JSON response**:

```json
{
    "scopes": {
        "resource": {
            "label": "Ресурс",
            "identity": "resource",
            "permissions": {
                "manage_children": {
                    "label": "Manage child resources"
                },
                "change_permissions": {
                    "label": "Change permissions"
                },
                "read": {
                    "label": "Read"
                },
                "create": {
                    "label": "Create"
                },
                "update": {
                    "label": "Modify"
                },
                "delete": {
                    "label": "Delete"
                }
            }
        },
        "service": {
            "label": "Сервис",
            "identity": "service",
            "permissions": {
                "connect": {
                    "label": "Connection"
                },
                "configure": {
                    "label": "Configure"
                }
            }
        },
        "datastruct": {
            "label": "Data structure",
            "identity": "datastruct",
            "permissions": {
                "write": {
                    "label": "White"
                },
                "read": {
                    "label": "Read"
                }
            }
        },
        "connection": {
            "label": "Connection",
            "identity": "connection",
            "permissions": {
                "write": {
                    "label": "Write"
                },
                "read": {
                    "label": "Read"
                },
                "connect": {
                    "label": "Connect"
                }
            }
        },
        "webmap": {
            "label": "Web-map",
            "identity": "webmap",
            "permissions": {
                "display": {
                    "label": "Open"
                }
            }
        },
        "data": {
            "label": "Data",
            "identity": "data",
            "permissions": {
                "write": {
                    "label": "Write"
                },
                "read": {
                    "label": "Read"
                }
            }
        },
        "metadata": {
            "label": "Metadata",
            "identity": "metadata",
            "permissions": {
                "write": {
                    "label": "Write"
                },
                "read": {
                    "label": "Read"
                }
            }
        }
    },
    "resources": {
        "raster_style": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "raster_style",
            "label": "Raster style"
        },
        "resource": {
            "scopes": [
                "resource",
                "metadata"
            ],
            "identity": "resource",
            "label": "Resource"
        },
        "postgis_connection": {
            "scopes": [
                "connection",
                "resource",
                "metadata"
            ],
            "identity": "postgis_connection",
            "label": "PostGIS connection"
        },
        "resource_group": {
            "scopes": [
                "resource",
                "metadata"
            ],
            "identity": "resource_group",
            "label": "Resource group"
        },
        "wmsclient_connection": {
            "scopes": [
                "connection",
                "resource",
                "metadata"
            ],
            "identity": "wmsclient_connection",
            "label": "WMS connection"
        },
        "mapserver_style": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "mapserver_style",
            "label": "MapServer style"
        },
        "vector_layer": {
            "scopes": [
                "resource",
                "datastruct",
                "data",
                "metadata"
            ],
            "identity": "vector_layer",
            "label": "Vector layer"
        },
        "qgis_vector_style": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "qgis_vector_style",
            "label": "QGIS style"
        },
        "wmsclient_layer": {
            "scopes": [
                "resource",
                "datastruct",
                "data",
                "metadata"
            ],
            "identity": "wmsclient_layer",
            "label": "WMS layer"
        },
        "basemap_layer": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "basemap_layer",
            "label": "Basemap"
        },
        "wfsserver_service": {
            "scopes": [
                "resource",
                "service",
                "metadata"
            ],
            "identity": "wfsserver_service",
            "label": "WFS service"
        },
        "lookup_table": {
            "scopes": [
                "resource",
                "data",
                "metadata"
            ],
            "identity": "lookup_table",
            "label": "Reference"
        },
        "postgis_layer": {
            "scopes": [
                "resource",
                "datastruct",
                "data",
                "metadata"
            ],
            "identity": "postgis_layer",
            "label": "PostGIS layer"
        },
        "webmap": {
            "scopes": [
                "resource",
                "webmap",
                "metadata"
            ],
            "identity": "webmap",
            "label": "Web map"
        },
        "wmsserver_service": {
            "scopes": [
                "resource",
                "service",
                "metadata"
            ],
            "identity": "wmsserver_service",
            "label": "WMS service"
        },
        "raster_layer": {
            "scopes": [
                "resource",
                "datastruct",
                "data",
                "metadata"
            ],
            "identity": "raster_layer",
            "label": "Raster layer"
        }
    }
}
```

### Basic requests

### GET /api/resource/(*int:* id)

Get JSON resource representation. Need resource read permission.

### PUT /api/resource/(*int:* id)

Change resource by JSON payload data. Need read and write permissions.

### DELETE /api/resource/(*int:* id)

Delete resource.

### GET /api/resource/

Get resource description in JSON.

* **Parameters:**
  * **parent** (*integer*) – Parent resource identifier.

### POST /api/resource/

Create resource by JSON data payload.

* **Parameters:**
  * **parent** (*integer*) – Parent resource identifier, may be in JSON payload.
  * **cls** (*string*) – Resource class (type). For a list of supported resource classes see [Resource classes](#ngwdev-resource-classes).

### Search resources

To search resources execute the following request:

### GET /api/resource/search/?(*string:* key1)=(*string:* value1)&(*string:* key2)=(*string:* value2)...

Search resources.

* **Request Headers:**
  * [Accept](https://www.rfc-editor.org/info/rfc7231#section-5.3.2) – must be `*/*`
  * [Authorization](https://www.rfc-editor.org/info/rfc7235#section-4.2) – optional Basic auth string to authenticate
* **Parameters:**
  * **key2...** (*key1,*) – resource properties (for example, cls, creation_date, keyname). If resource property has children they are divided by double underscore (`__`). The `serialization=full` parameter make return list of resources with full description, otherwise only `resource` key will be returned.
  * **value1,value2...** – key value to search. All `key=value` pairs form the following search string `key1=value1 AND key2=value2 AND ...`.
* **Status Codes:**
  * [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/200) – no error
* **Request JSON Array of Objects:**
  * **resource** – Array of resource json representation.

#### WARNING
Now supported only `owner_user__id` key with child.

#### NOTE
Without parameters request returns all resources available to current user.

**Example request**:

Search by keyname

```http
GET /api/resource/search/?keyname=satellite HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example response**:

```json
[
    {
        "resource": {
            "id": 856,
            "cls": "resource_group",
            "creation_date": "1970-01-01T00:00:00",
            "parent": {
                "id": 0,
                "parent": {
                    "id": null
                }
            },
            "owner_user": {
                "id": 4
            },
            "permissions": [],
            "keyname": "satellite",
            "display_name": "111222",
            "children": false,
            "interfaces": [],
            "scopes": [
                "resource",
                "metadata"
            ]
        },
        "resmeta": {}
    }
]
```

Found only one resource because keyname is unique in the whole NextGIS Web instance.

**Example request**:

Search by name

```http
GET /api/resource/search/?display_name=photos HTTP/1.1
Host: ngw_url
Accept: */*
```

Search for raster layers

```http
GET /api/resource/search/?cls=raster_layer HTTP/1.1
Host: ngw_url
Accept: */*
```

Search for QGIS vector styles with metadata

```http
GET /api/resource/search/?cls=qgis_vector_style&serialization=full HTTP/1.1
Host: ngw_url
Accept: */*
```

### Child resource

To get child resources of parent resource with identifier `id` execute the
following request:

### GET /api/resource/?parent=(*int:* id)

**Example JSON response**:

```json
[ {
    "resource": {
       "id": 730,
       "cls": "webmap",
       "parent": {
          "id": 640,
          "parent": {
             "id": 639
          }
       },
       "owner_user": {
          "id": 4
       },
       "permissions": [],
       "keyname": null,
       "display_name": "OpenDroneMap sample",
       "description": null,
       "children": false,
       "interfaces": [],
       "scopes": [
          "resource",
          "webmap",
          "metadata"
       ]
    },
    "webmap": {
       "extent_left": -83.31,
       "extent_right": -83.3,
       "extent_bottom": 41.042,
       "extent_top": 41.034,
       "bookmark_resource": null,
       "root_item": {
          "item_type": "root",
          "children": [
             {
                "layer_adapter": "image",
                "layer_enabled": true,
                "layer_max_scale_denom": null,
                "item_type": "layer",
                "layer_min_scale_denom": null,
                "display_name": "Seneca country",
                "layer_style_id": 642,
                "layer_transparency": null
             }
          ]
       }
    },
    "basemap_webmap": {
       "basemaps": [
          {
             "opacity": null,
             "enabled": true,
             "position": 0,
             "display_name": "HikeBikeMap",
             "resource_id": 1039
          },
          {
             "opacity": null,
             "enabled": true,
             "position": 1,
             "display_name": "Спутник",
             "resource_id": 1038
          }
       ]
    },
    "resmeta": {
       "items": {}
    }
 },
 {
    "resource": {
       "id": 641,
       "cls": "raster_layer",
       "parent": {
          "id": 640,
          "parent": {
             "id": 639
          }
       },
       "owner_user": {
          "id": 4
       },
       "permissions": [],
       "keyname": null,
       "display_name": "odm_orthophoto_low",
       "description": null,
       "children": true,
       "interfaces": [
          "IBboxLayer"
       ],
       "scopes": [
          "resource",
          "datastruct",
          "data",
          "metadata"
       ]
    },
    "resmeta": {
       "items": {}
    },
    "raster_layer": {
       "srs": {
          "id": 3857
       },
       "xsize": 16996,
       "ysize": 17054,
       "band_count": 4
    }
 },
 {
    "resource": {
       "id": 1041,
       "cls": "wfsserver_service",
       "parent": {
          "id": 640,
          "parent": {
             "id": 639
          }
       },
       "owner_user": {
          "id": 4
       },
       "permissions": [],
       "keyname": null,
       "display_name": "WFS service for demo",
       "description": null,
       "children": false,
       "interfaces": [],
       "scopes": [
          "resource",
          "service",
          "metadata"
       ]
    },
    "resmeta": {
       "items": {}
    },
    "wfsserver_service": {
       "layers": [
          {
             "maxfeatures": 2222,
             "keyname": "lines",
             "display_name": "Просеки",
             "resource_id": 534
          }
       ]
    }
 },
 {
    "resource": {
       "id": 1036,
       "cls": "resource_group",
       "parent": {
          "id": 640,
          "parent": {
             "id": 639
          }
       },
       "owner_user": {
          "id": 4
       },
       "permissions": [],
       "keyname": null,
       "display_name": "Sample folder",
       "description": null,
       "children": true,
       "interfaces": [],
       "scopes": [
          "resource",
          "metadata"
       ]
    },
    "resmeta": {
       "items": {}
    }
 },
 {
    "resource": {
       "id": 1037,
       "cls": "wmsserver_service",
       "parent": {
          "id": 640,
          "parent": {
             "id": 639
          }
       },
       "owner_user": {
          "id": 4
       },
       "permissions": [],
       "keyname": null,
       "display_name": "OpenDroneMap at NextGIS.com",
       "description": null,
       "children": false,
       "interfaces": [],
       "scopes": [
          "resource",
          "service",
          "metadata"
       ]
    },
    "resmeta": {
       "items": {}
    },
    "wmsserver_service": {
       "layers": [
          {
             "min_scale_denom": null,
             "keyname": "seneca_country",
             "display_name": "Seneca country",
             "max_scale_denom": null,
             "resource_id": 642
          }
       ]
    }
 } ]
```

Obtain layers id and display_name in bash

<!-- _ngwdev_resource_properties -->

### Resource properties

To get resource properties execute the following request:

### GET /api/resource/(*int:* id)

Resource properties.

**Example request**:

```http
GET /api/resource/1 HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example JSON response**:

```json
{
 "resource": {
     "id": 2,
     "cls": "resource_group",
     "parent": {
         "id": 0,
         "parent": {
             "id": null
         }
     },
     "owner_user": {
         "id": 4
     },
     "permissions": [],
     "keyname": null,
     "display_name": "test",
     "description": "",
     "children": true,
     "interfaces": [],
     "scopes": [
         "resource",
         "metadata"
     ]
 },
 "resmeta": {
     "items": {}
 }
}
```

Where:

* **resource** - resource description
  > * id - resource identifier
  > * cls - resource type (see. [Resource classes](#ngwdev-resource-classes))
  > * parent - parent resource
  > * owner_user - resource owner identifier
  > * permissions - resource permissions array
  > * keyname - unique identifier (allowed only ASCII characters). Must be unique in whole NextGIS Web instance
  > * display_name - name showing in web user interface
  > * description - resource description showing in web user interface
  > * children - boolean value. True if resource has children resources
  > * interfaces - API interfaces supported by resource
  > * scope - which scope the resource is belongs
* **resmeta** - resource metadata

The map resource properties has the following json description:

```json
{
 "resource": {
     "id": 1,
     "cls": "webmap",
     "parent": {
         "id": 2,
         "parent": {
             "id": 0
         }
     },
     "owner_user": {
         "id": 4
     },
     "permissions": [],
     "keyname": null,
     "display_name": "Main web map",
     "description": null,
     "children": false,
     "interfaces": [],
     "scopes": [
         "resource",
         "webmap",
         "metadata"
     ]
 },
 "webmap": {
     "extent_left": -180,
     "extent_right": 180,
     "extent_bottom": -90,
     "extent_top": 90,
     "draw_order_enabled": null,
     "bookmark_resource": null,
     "root_item": {
         "item_type": "root",
         "children": [
             {
                 "layer_adapter": "image",
                 "layer_enabled": true,
                 "draw_order_position": null,
                 "layer_max_scale_denom": null,
                 "item_type": "layer",
                 "layer_min_scale_denom": null,
                 "display_name": "Cities",
                 "layer_style_id": 91,
                 "layer_transparency": null
             },
             {
                 "group_expanded": false,
                 "display_name": "Points of interest",
                 "children": [
                  ],
                 "item_type": "group"
             }
         ]
     }
 },
 "basemap_webmap": {
     "basemaps": [
        {
             "opacity": null,
             "enabled": true,
             "position": 0,
             "display_name": "OpenStreetMap Standard",
             "resource_id": 665
         },
     ]
 },
 "resmeta": {
     "items": {}
 }
}
```

Where:

* **resource** - resource description (see upper for details)
* **webmap** - web map description
  > * extent_left, extent_right, extent_bottom, extent_top -
  > * draw_order_enabled - use specific draw order or same as layers order
  > * bookmark_resource - vector layer resource identifier
  > * root_item - layers description group
  >   > * item_type - always root
  >   > * children - map layers and groups
  >   >   > * layer_adapter - `image` or `tile` (also see [Создание веб-карты](../../../docs_ngweb/source/webmaps_admin.html.md#ngw-map-create))
  >   >   > * layer_enabled - is layer checked be default
  >   >   > * draw_order_position - if drawing order is enabled this is position in order. May be `null`.
  >   >   > * layer_max_scale_denom, layer_min_scale_denom - a scale range in format `1 : 10 000`
  >   >   > * item_type - may be `group` or `layer`
  >   >   > * display_name - layer or group name
  >   >   > * layer_style_id - vector or raster layer style resource identifier
  >   >   > * layer_transparency - transparency
  >   >   > * group_expanded - is group checked by default or not
* **basemap_webmap** - array of web map basemaps
  > * opacity - basemap opacity
  > * enabled - is basemap should be present in web map basemaps combobox
  > * position - position in web map basemaps combobox
  > * display_name - name showing in web map basemaps combobox
  > * resource_id - basemap resource identifier
* **resmeta** - resource metadata

### Changing resource permissions

To change resource permissions you need to do `PUT` request to resource JSON
endpoint. In general g permissions doesn’t different from g
resource keyname or any other property.

```http
PUT /api/resource/10

{
  "resource": {
    "permissions": [
      {
        "action": "allow",
        "principal": { "id": 10 },
        "identity": "",
        "scope": "",
        "permission": "",
        "propagate": true
      },
      {
        "action": "allow",
        "principal": { "id": 20 },
        "identity": "",
        "scope": "resource",
        "permission": "read",
        "propagate": true
      }
    ]
  }
}
```

Where:

> * `action` - `allow` or `deny`, priority of `deny` is higher then
>   `allow`.
> * `principal` - user or group for which this rule applies. Users and groups
>   are principals, so they share same `id` space.
> * `identity` - resource class for which this rule applies. Empty string
>   means that this rule applies to all resource classes.
> * `scope` - see resource schema, empty string means «All resources».
> * `permission` - see resource schem, empty string means «All permissions».
> * `propagate` - should this rule apply to child resources or not.

### Feature count

To get feature count in vector layer execute the following request:

### GET /api/resource/(*int:* id)/feature_count

Get feature count

* **Request Headers:**
  * [Accept](https://www.rfc-editor.org/info/rfc7231#section-5.3.2) – must be `*/*`
  * [Authorization](https://www.rfc-editor.org/info/rfc7235#section-4.2) – optional Basic auth string to authenticate
* **Status Codes:**
  * [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/200) – no error

**Example request**:

```http
GET /api/resoure/10/feature_count HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example response**:

```json
{ "total_count": 0 }
```

### Get layer extent

To get layer extent execute following request. You can request extent for vector and raster layers.
Returned coordinates are in WGS84 (EPSG:4326) spatial reference.

### GET /api/resource/(*int:* id)/extent

Get layer extent

* **Request Headers:**
  * [Accept](https://www.rfc-editor.org/info/rfc7231#section-5.3.2) – must be `*/*`
  * [Authorization](https://www.rfc-editor.org/info/rfc7235#section-4.2) – optional Basic auth string to authenticate
* **Request JSON Object:**
  * **extent** (*jsonobj*) – extent json object
* **Status Codes:**
  * [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/200) – no error

**Example request**:

```http
GET /api/resoure/10/extent HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example response**:

```json
{
  "extent":
  {
    "minLat": 54.760400119987466,
    "maxLon": 35.08562149737197,
    "minLon": 35.06675807847286,
    "maxLat": 54.768358305249386
  }
}
```

### Features and single feature

To get a single feature of vector layer execute the following request:

### GET /api/resource/(*int:* id)/feature/(*int:* feature_id)/?srs=(*int:* srs)

To get all vector layer features execute the following request:

### GET /api/resource/(*int:* id)/feature/?srs=(*int:* srs)

Get features

* **Query Parameters:**
  * **srs** – EPSG code for input SRS (will be automatically reprojected to destination SRS)
* **Request Headers:**
  * [Accept](https://www.rfc-editor.org/info/rfc7231#section-5.3.2) – must be `*/*`
  * [Authorization](https://www.rfc-editor.org/info/rfc7235#section-4.2) – optional Basic auth string to authenticate
* **Request JSON Array of Objects:**
  * **features** – features array
* **Status Codes:**
  * [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/200) – no error

To get features using filters execute the following request:

#### Versionadded
Добавлено в версии 3.1.

### GET /api/resource/(*int:* id)/feature/?limit=(*int:* limit)&offset=(*int:* offset)&intersects=(*string:* wkt_string)&fields=(string:field_name_1,string:field_name_2,...)&fld_{field_name_1}=(*string:* value)&fld_{field_name_2}=(*string:* value)&fld_{field_name_3}_\_ilike=(*string:* value)&fld_{field_name_4}_\_like=(*string:* value)&extensions=(*string:* extensions)

Get features with parameters

* **Request Headers:**
  * [Accept](https://www.rfc-editor.org/info/rfc7231#section-5.3.2) – must be `*/*`
  * [Authorization](https://www.rfc-editor.org/info/rfc7235#section-4.2) – optional Basic auth string to authenticate
* **Parameters:**
  * **limit** – limit feature count adding to return array
  * **offset** – skip some features before create features array
  * **order_by** – order results by fields. Add minus char to descending.
  * **intersects** – geometry as WKT string in EPSG:3857. Features intersect with this geometry will added to array
  * **fields** – comma separated list of fields in return feature
  * **fld_{field_name_1}...fld_{field_name_N}** – field name and value to filter return features. Parameter name forms as `fld_` + real field name (keyname). All pairs of field name = value form final `AND` SQL query.
  * **fld_{field_name_1}_\_{operation}...fld_{field_name_N}_\_{operation}** – field name and value to filter return features using operation statement. Supported operations are: `gt`, `lt`, `ge`, `le`, `eq`, `ne`, `like`, `ilike`. All pairs of field name - operation - value form final `AND` SQL query.
  * **geom_format** – `geojson` - output geometry in geojson format instead of WKT
  * **srs** – EPSG code - reproject geometry to EPSG
  * **geom** – yes - return geometry, no - don’t return geometry (defaults yes)
  * **dt_format** – iso - return date, time, timestamp in ISO format, obj - return date, time, timestamp as JSON object (default obj)
  * **extensions** – comma separated list of extensions. Available `description` and `attachments`. Defaults to `description,attachments`
* **>jsonarray features:**
  features array
* **Status Codes:**
  * [200 OK](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/200) – no error

Filter operations:

* gt - greater (>)
* lt - lower (<)
* ge - greater or equal (>=)
* le - lower or equal (<=)
* eq - equal (=)
* ne - not equal (!=)
* like - LIKE SQL statement (for strings compare)
* ilike - ILIKE SQL statement (for strings compare)

To filter part of field use percent sign. May be at the start of a string, at the
end or both. Works only for `like` and `ilike` operations.

**Example request**:

```http
GET api/resource/1878/feature/8 HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example JSON response**:

```json
{
  "id": 8,
  "geom": "MULTIPOLYGON (((4071007.5456240694038570 7385427.4912760490551591,
                           4071010.5846461649052799 7385440.8649944914504886,
                           4071018.6441773008555174 7385439.0351102603599429,
                           4071019.4902054299600422 7385442.7727465946227312,
                           4071057.3388322992250323 7385434.1683989763259888,
                           4071056.4928041673265398 7385430.4307667789980769,
                           4071065.5208148718811572 7385428.1726148622110486,
                           4071062.6153761623427272 7385414.7794514624401927,
                           4071058.2961799190379679 7385415.5581231201067567,
                           4071055.1347063803113997 7385401.6588457319885492,
                           4071007.8795825401321054 7385412.3850365970283747,
                           4071011.1301116724498570 7385426.6931363716721535,
                           4071007.5456240694038570 7385427.4912760490551591)))",
  "fields": {
      "OSM_ID": 128383475,
      "BUILDING": "apartments",
      "A_STRT": "проспект Ленина",
      "A_SBRB": "",
      "A_HSNMBR": "209",
      "B_LEVELS": "14",
      "NAME": ""
  }
}
```

**Example response with photo and description**:

```json
{
     "id": 1,
     "geom": "MULTIPOINT (14690369.3387846201658249 5325725.3689366327598691)",
     "fields": {
         "name_official": "Краевое государственное автономное учреждение...",
         "name_short": "МФЦ Приморского края",
         "square": "702",
         "windows": "16",
         "start_date": "2013/12/30",
         "addr": "690080, Приморский край. г. Владивосток, ул. Борисенко д. 102",
         "phone_consult": "(423) 201-01-56",
         "opening_hours": "пн: 09:00-18:00 (по предварительной записи)вт: 09:00-20:00ср: 11:00-20:00чт: 09:00-20:00пт: 09:00-20:00 сб: 09:00-13:00 вс: выходной",
         "director": "Александров Сергей Валерьевич",
         "desc": "Центр создан в целях ...",
         "services_info": "Ознакомиться с перечнем можно ...",
         "issue_info": "ответственность должностных лиц ...",
         "website": "http://mfc-25.ru"
       },
     "extensions": {
         "description": " Описание объекта в ...",
         "attachment": [
             {
                 "id": 1,
                 "name": "fyADeqvXtXo.jpg",
                 "size": 107458,
                 "mime_type": "image/jpeg",
                 "description": null,
                 "is_image": true
             },
             {
                 "id": 2,
                 "name": "0_12cb49_b02b5fb0_orig.jpg",
                 "size": 65121,
                 "mime_type": "image/jpeg",
                 "description": "Текст подписи к фото",
                 "is_image": true
             }
         ]
     }
 }
```

**Example request with parameters**:

```http
GET api/resource/442/feature/?fld_ondatr_set=3.0 HTTP/1.1
Host: ngw_url
Accept: */*
```

```http
GET api/resource/442/feature/?intersects=POLYGON((4692730.0186502402648329%206500222.2378559196367859,4692731.0186502402648330%206500222.2378559196367859,4692730.0186502402648331%206500222.2378559196367861,4692730.0186502402648329%206500222.2378559196367861,4692730.0186502402648329%206500222.2378559196367859)) HTTP/1.1
Host: ngw_url
Accept: */*
```

```http
GET api/resource/442/feature/?fld_dataunreal=2018-04-15&fields=Desman_ID,Year_1 HTTP/1.1
Host: ngw_url
Accept: */*
```

```http
GET /api/resource/197/feature/?geom_format=geojson&srs=4326 HTTP/1.1
Host: ngw_url
Accept: */*
```

```http
GET /api/resource/197/feature/?order_by=NAME,-LEISURE HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example response with photo and description**:

```json
[
  {
      "id": 1,
      "geom": {
          "type": "LineString",
          "coordinates": [
              [
                  43.530026045806544,
                  56.54254685020393
              ],
              [
                  43.53069976860634,
                  56.5418515124425
              ],
              [
                  43.53178999904635,
                  56.54087804170086
              ],
              [
                  43.53378038747746,
                  56.53965877275228
              ],
              [
                  43.534406424553474,
                  56.53930211850715
              ]
          ]
      },
      "fields": {
          "ogc_fid": 5794,
          "CLCODE": 61220000,
          "CLNAME": " ",
          "ANGLE": null,
          "TEXT": null
      },
      "extensions": {
          "description": null,
          "attachment": null
      }
  }
]
```

**Example request to get features without geometry**:

```http
GET api/resource/442/feature/?geom=no HTTP/1.1
Host: ngw_url
Accept: */*
```

**Example request to get features without extensions**:

```http
GET api/resource/442/feature/?extensions= HTTP/1.1
Host: ngw_url
Accept: */*
```

For large geometries use GET body to send such geometry.

**Example request to get features with large geometry**:

```bash
curl --request GET "http://sandbox.nextgis.com/api/resource/1234/feature/" --header "Content-Type: application/json" --data-raw "{\"intersects\": \"MULTIPOLYGON (((3821804.05999104725196958 5744803.73564852681010962, 3756055.8574127024039626 5562813.06612514425069094, 3927526.96338468883186579 5635924.2469089291989803, 3821804.05999104725196958 5744803.73564852681010962)))\"}"
```

### Attachment

Attachment URL forms from feature URL adding `attachment/` and attachment
identifier. For example:

### GET /api/resource/(*int:* id)/feature/(*int:* feature_id)/attachment/(*int:* attachment_id)/download

Attachment support loading any file types. For image files a preview generates
during upload.

### GET /api/resource/(*int:* id)/feature/(*int:* feature_id)/attachment/(*int:* attachment_id)/image?size=200x150

### Map web interface

#### Versionadded
Добавлено в версии 3.0.

To get map web interface (not a map json representation) execute one of the
following request:

### GET resource/{0}/display

Web map user interface.

**Example request**:

```http
GET resource/42/display HTTP/1.1
Host: ngw_url
Accept: */*
```

To get web interface without layer control and toolbars execute the following
request:

### GET resource/{0}/display/tiny

Web map `light` user interface.
