Table of contents:


API Overview

This describes the resources that make up the official SpacialDB API v1. If you have any problems please contact support. SpacialDB has a RESTful query API that let you perform Create, Read, Update and Delete operations on you core Geospatial Layers. These layers need to conform to SpacialDB's standard schema. More details on standard schema can be found at standard schema page.

URL

You can reach version 1.0 of the API via http

  http://api.spacialdb.com/1/

or via https

  https://api.spacialdb.com/1/


Layer resource

The Layer resource maps to a SpacialDB table. It can store geospatial features and key-value attributes.


Publish a feature for a given layer

Creates a new feature.

Url:

POST /users/:user/layers/:layername?key=<accessKey>

Input:

  • geometry

    • Optional GeoJSON Geometry Object
  • properties

    • Optional JSON Object
  • key

    • Required String, access key for your account/layer

Requires at least one of the above geometry or properties attribute.

{
    "geometry": <GeoJSON Geometry Object>
    "properties": {
        <key1>: <value1>,
        <key2>: <value2>
    }
}

Response:

Code/Header

200 - OK

Body:

{
    id: 42
}

Back to Table of Contents


Update a feature of a layer with given id

Url:

PUT /users/:user/layers/:layername/:id?key=<accesKey>

Input:

  • geometry
    • Optional GeoJSON Geometry Object
  • properties
    • Optional JSON OBject
  • key
    • Required String, access key for your account/layer

Requires at least one of the above.

{
    "geometry": <GeoJSON Geometry Object>
    "properties": {
        <key1>: <value1>,
        <key2>: <value2>
    }
}

Response:

Code:

204 - NO CONTENT

Back to Table of Contents


Delete a feature from a layer given the feature id

Url:

DELETE /users/:user/layers/:layername/:id?key=<accessKey>

Input:

  • key
    • Required String, access key for your account/layer

Response:

Code:

204 - NO CONTENT

Back to Table of Contents


Get the all features in a layer

Url:

GET /users/:user/layers/:layername?key=<accessKey>

Input:

  • key
    • Required String, access key for your account/layer

Response:

Code:

200 - OK

Body:

{
    "type": "FeatureCollection",
    "features": [
        {
            "id": 42
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [-0.925268, 51.552603]
            }
            "properties": {
                "office": "Awesome Company",
                "nice": "true"
            }

        }
    ]
}

Back to Table of Contents


Get a feature of a layer by id

Url:

GET /users/:user/layers/:layername/:id?key=<accessKey>

Input:

  • key
    • Required String, access key for your account/layer

Supports all extended request options.

Response:

Code:

200 - OK

Body:

{
    "id": 42
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [-0.925268, 51.552603]
    }
    "properties": {
        "office": "Awesome Company",
        "nice": "true"
    }
}

Back to Table of Contents


Get a single feature with only the requested attributes e.g. the id, properties

Url:

GET /users/:user/layers/:layername/:id?key=<accessKey>&attr=id,properties

Input:

  • key
    • Required String, access key for your account/layer
  • attr
    • Required

Response:

Code:

200 - OK

Body:

{
    "id": 42
    "properties": {
        key: "value",
        key2: "value2"
    }
}

Back to Table of Contents


Get a collection of features with only the requested attributes e.g. id, properties

Url:

GET /users/:user/layers/:layername?key=<accessKey>&attr=id,properties

Return:

Code:

200 - OK

Body:

 {
    "type": "FeatureCollection",
    "features": [
        {
            "id": 42
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [-0.925268, 51.552603]
            }
            "properties": {
                "office": "Awesome Company",
                "nice": "true"
            }

        }
    ]
}

Back to Table of Contents


Get all features intersecting a given geometry

Url:

GET /users/:user/layers/:layername/functions/intersects?key=<accessKey>&input=<geometry>

Input:

  • key
    • Required String, access key for your account/layer
  • input
    • Required JSON containing a GeoJSON Geometry in the body, as follows:
{
  "geometry": <GeoJSON Geometry Object>
}

Response:

Code:

200 - OK

Body:

{
    "type": "FeatureCollection",
    "features": [
        {
            "id": 42
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [-0.925268, 51.552603]
            }
            "properties": {
                "office": "Awesome Company",
                "nice": "true"
            }
        }
    ]
}

Back to Table of Contents


Get all features within (inclusion) given geometry

Url:

GET /users/:user/layers/:layername/functions/within?key=<accessKey>&input=<geometry>

Input:

  • key
    • Required String, access key for your account/layer
  • input
    • Required JSON containing a GeoJSON Geometry in the body, as follows:
{
    "geometry": <GeoJSON Geometry Object>
}

Response:

Code:

200 - OK

Body:

{
    "type": "FeatureCollection",
    "features": [
        {
            "id": 42
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [-0.925268, 51.552603]
            }
            "properties": {
                "office": "Awesome Company",
                "nice": "true"
            }
        }
    ]
}

Back to Table of Contents


Get all features with the given properties

Url:

GET /users/:user/layers/:layername?key=<accessKey>&input=<url-encoded-JSON>

Input:

  • key

    • Required String, access key for your account/layer
  • input This parameter is a URL encoded JSON object with the following attributes:

    • operator
    • Required Key-Value-Pair which defines the operator to combine the properties. Valid values are be or or and.
    • properties
    • Requried Object properties with Key-Value-Pairs which will be part of the WHERE condition
{
    "operator": "or",
    "properties": {
        "office": "Awesome Company",
        "nice": "true"
    }
}

Response:

Code:

200 - OK

Body:

{
    "type": "FeatureCollection",
    "features": [
        {
            "id": 42
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [-0.925268, 51.552603]
            }
            "properties": {
                "office": "Awesome Company",
                "nice": "true"
            }
        }
    ]
}

Back to Table of Contents


Get all features sorted by a property key

  • key
    • Required String, access key for your account/layer
  • sort
    • Required String which enables sorting
  • order
    • Required String which defines the order of the sorting. Could be asc or desc.
  • sorton
    • Required String which defines the property key we sort on.

Url:

GET /users/:user/layers/:layername?key=<accessKey>&sort

Body:

{
   "order": "asc",
   "sorton": "name"
}

Response:

Code:

200 - OK

Body:

{
    "type": "FeatureCollection",
    "features": [
        {
            "id": 1,
            "type": "Feature",
            "geometry": {
                "type": "Point"
                "coordinates": [42.0 23.0]
            }
            "properties": {
                name: "bar"
            }
        },
        {
            "id": 2,
            "type": "Feature",
            "geometry": {
                "type": "Point"
                "coordinates": [23.0 42.0]
            }
            "properties": {
                name: "foo"
            }
        }
    ]
}

Back to Table of Contents


Count the features in a collection/layer

Url:

GET /users/:user/layer/:layername?key=<accessKey>&count

Input:

  • key
    • Required String, access key for your account/layer
  • count
    • Required, enables counting.

Response:

Code:

200 - OK

Body:

{
    count: 42
}

Back to Table of Contents


Extended request options

Extended request options let you do more fine tuned requests by supporting parameters for:

Sorting

Requested only specific attributes

Counting

Back to Table of Contents