This resource does not have any attributes. Instead it offers the initial API affordances in the form of the links in the JSON body. It is recommended to follow the “url” link values, Link or Location headers where applicable to retrieve resources. Instead of constructing your own URLs, to keep your client decoupled from implementation details.
{- "entities_url": "/v2/entities",
- "types_url": "/v2/types",
- "subscriptions_url": "/v2/subscriptions",
- "registrations_url": "/v2/registrations"
}
Retrieves a list of entities that match different criteria by id, type, pattern matching (either id or type)
and/or those which match a query or geographical query (see Simple Query Language and
Geographical Queries). A given entity has to match all the criteria to be retrieved
(i.e., the criteria is combined in a logical AND way). Note that pattern matching query parameters are incompatible
(i.e. mutually exclusive) with their corresponding exact matching parameters, i.e. idPattern
with id
and
typePattern
with type
.
The response payload is an array containing one object per matching entity. Each entity follows
the JSON entity representation format (described in "JSON Entity Representation" section).
Response code:
id | string A comma-separated list of elements.
Retrieve entities whose ID matches one of the elements in the list.
Incompatible with |
type | string comma-separated list of elements.
Retrieve entities whose type matches one of the elements in the list.
Incompatible with |
idPattern | string A correctly formated regular expression.
Retrieve entities whose ID matches the regular expression. Incompatible with |
typePattern | string A correctly formated regular expression.
Retrieve entities whose type matches the regular expression. Incompatible with |
q | string A query expression, composed of a list of statements
separated by |
mq | string A query expression for attribute metadata,
composed of a list of statements separated by |
georel | string Spatial relationship between matching entities and a reference shape. See Geographical Queries. |
geometry | string Geografical area to which the query is restricted. See Geographical Queries. |
coords | string List of latitude-longitude pairs of coordinates separated by ';'. See Geographical Queries. |
limit | number <double> Limits the number of entities to be retrieved |
offset | number <double> Establishes the offset from where entities are retrieved |
attrs | string Comma-separated list of attribute names whose data are to be included in the response. The attributes are retrieved in the order specified by this parameter. If this parameter is not included, the attributes are retrieved in arbitrary order. See "Filtering out attributes and metadata" section for more detail. |
metadata | string A list of metadata names to include in the response. See "Filtering out attributes and metadata" section for more detail. |
orderBy | string Criteria for ordering results. See "Ordering Results" section for details. |
options | string Enum: "count" "keyValues" "values" "unique" Options dictionary |
[- {
- "type": "Room",
- "id": "DC_S1-D41",
- "temperature": {
- "value": 35.6,
- "type": "Number",
- "metadata": { }
}
}, - {
- "type": "Room",
- "id": "Boe-Idearium",
- "temperature": {
- "value": 22.5,
- "type": "Number",
- "metadata": { }
}
}, - {
- "type": "Car",
- "id": "P-9873-K",
- "speed": {
- "value": 100,
- "type": "number",
- "metadata": {
- "accuracy": {
- "value": 2,
- "type": "Number"
}, - "timestamp": {
- "value": "2015-06-04T07:20:27.378Z",
- "type": "DateTime"
}
}
}
}
]
The payload is an object representing the entity to be created. The object follows the JSON entity representation format (described in a "JSON Entity Representation" section). Response:
Location
header with the URL of the
created entity.options | string Enum: "keyValues" "upsert" Options dictionary |
Content-Type required | string |
type required | string |
id required | string |
temperature required | object |
humidity required | object |
location required | object |
{- "type": "Room",
- "id": "Bcn-Welt",
- "temperature": {
- "value": 21.7
}, - "humidity": {
- "value": 60
}, - "location": {
- "value": "41.3763726, 2.1864475",
- "type": "geo:point",
- "metadata": {
- "crs": {
- "value": "WGS84"
}
}
}
}
The response is an object representing the entity identified by the ID. The object follows the JSON entity representation format (described in "JSON Entity Representation" section). This operation must return one entity element only, but there may be more than one entity with the same ID (e.g. entities with same ID but different types). In such case, an error message is returned, with the HTTP status code set to 409 Conflict. Response:
entityId required | string Id of the entity to be retrieved |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
attrs | string Comma-separated list of attribute names whose data must be included in the response. The attributes are retrieved in the order specified by this parameter. See "Filtering out attributes and metadata" section for more detail. If this parameter is not included, the attributes are retrieved in arbitrary order, and all the attributes of the entity are included in the response. |
metadata | string A list of metadata names to include in the response. See "Filtering out attributes and metadata" section for more detail. |
options | string Enum: "keyValues" "values" "unique" Options dictionary |
{- "type": "Room",
- "id": "Bcn_Welt",
- "temperature": {
- "value": 21.7,
- "type": "Number"
}, - "humidity": {
- "value": 60,
- "type": "Number"
}, - "location": {
- "value": "41.3763726, 2.1864475",
- "type": "geo:point",
- "metadata": {
- "crs": {
- "value": "WGS84",
- "type": "Text"
}
}
}
}
Delete the entity. Response:
entityId required | string Id of the entity to be deleted |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
This request is similar to retreiving the whole entity, however this one omits the id
and type
fields.
Just like the general request of getting an entire entity, this operation must return only one
entity element. If more than one entity with the same ID is found (e.g. entities with
same ID but different type), an error message is returned, with the HTTP status code set to
409 Conflict.
Response:
entityId required | string Id of the entity to be retrieved |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
attrs | string Comma-separated list of attribute names whose data are to be included in the response. The attributes are retrieved in the order specified by this parameter. If this parameter is not included, the attributes are retrieved in arbitrary order, and all the attributes of the entity are included in the response. See "Filtering out attributes and metadata" section for more detail. |
metadata | string A list of metadata names to include in the response. See "Filtering out attributes and metadata" section for more detail. |
options | string Enum: "keyValues" "values" "unique" Options dictionary |
{- "temperature": {
- "value": 21.7,
- "type": "Number"
}, - "humidity": {
- "value": 60,
- "type": "Number"
}, - "location": {
- "value": "41.3763726, 2.1864475",
- "type": "geo:point",
- "metadata": {
- "crs": {
- "value": "WGS84",
- "type": "Text"
}
}
}
}
The request payload is an object representing the new entity attributes. The object follows
the JSON entity representation format (described in a "JSON Entity Representation" above), except
that id
and type
are not allowed.
The attributes previously existing in the entity are removed and replaced by the ones in the
request.
Response:
entityId required | string Id of the entity in question. |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
options | string Value: "keyValues" Operations options |
Content-Type required | string |
temperature required | object |
seatNumber required | object |
{- "temperature": {
- "value": 25.5
}, - "seatNumber": {
- "value": 6
}
}
The request payload is an object representing the attributes to append or update. The object follows
the JSON entity representation format (described in "JSON Entity Representation" section), except
that id
and type
are not allowed.
The entity attributes are updated with the ones in the payload, depending on
whether the append
operation option is used or not.
append
is not used: the entity attributes are updated (if they previously exist) or appended
(if they don't previously exist) with the ones in the payload.append
is used (i.e. strict append semantics): all the attributes in the payload not
previously existing in the entity are appended. In addition to that, in case some of the
attributes in the payload already exist in the entity, an error is returned.
Response:entityId required | string Entity id to be updated |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
options | string Enum: "append" "keyValues" Operations options |
Content-Type required | string |
ambientNoise required | object |
{- "ambientNoise": {
- "value": 31.5
}
}
The request payload is an object representing the attributes to update. The object follows
the JSON entity representation format (described in "JSON Entity Representation" section), except
that id
and type
are not allowed.
The entity attributes are updated with the ones in the payload. In addition to that, if one or more
attributes in the payload doesn't exist in the entity, an error is returned.
Response:
entityId required | string Id of the entity to be updated |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
options | string Value: "keyValues" Operations options |
Content-Type required | string |
temperature required | object |
seatNumber required | object |
{- "temperature": {
- "value": 25.5
}, - "seatNumber": {
- "value": 6
}
}
Returns a JSON object with the attribute data of the attribute. The object follows the JSON representation for attributes (described in "JSON Attribute Representation" section). Response:
entityId required | string Id of the entity |
attrName required | string Name of the attribute to be retrieved. |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
metadata | string A list of metadata names to include in the response. See "Filtering out attributes and metadata" section for more detail. |
{- "value": 21.7,
- "type": "Number",
- "metadata": { }
}
The request payload is an object representing the new attribute data. Previous attribute data is replaced by the one in the request. The object follows the JSON representation for attributes (described in "JSON Attribute Representation" section). Response:
entityId required | string Id of the entity to update |
attrName required | string Attribute name |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
Content-Type required | string |
value required | number <double> |
metadata required | object |
{- "value": 25,
- "metadata": {
- "unitCode": {
- "value": "CEL"
}
}
}
Removes an entity attribute. Response:
entityId required | string Id of the entity. |
attrName required | string Attribute name. |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
This operation returns the value
property with the value of the attribute.
Accept
header can be expanded to application/json
or text/plain
return the value as a JSON with a
response type of application/json or text/plain (whichever is the first in Accept
header or
application/json
in case of Accept: */*
).Accept
header can be expanded to text/plain return the value as text. In case of a string, citation
marks are used at the begining and end.entityId required | string Id of the entity in question |
attrName required | string Name of the attribute to be retrieved. |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
{- "address": "Ronda de la Comunicacion s/n",
- "zipCode": 28050,
- "city": "Madrid",
- "country": "Spain"
}
The request payload is the new attribute value.
application/json
, then the value of the attribute is set to
the JSON object or array coded in the payload (if the payload is not a valid JSON document,
then an error is returned).text/plain
, then the following algorithm is applied to the
payload:"
), the value is taken as a string
(the citation marks themselves are not considered part of the string)true
or false
, the value is taken as a boolean.null
, the value is taken as null.Content-Type
HTTP header.
Response:entityId required | string Id of the entity to be updated. |
attrName required | string Attribute name. |
type | string Entity type, to avoid ambiguity in case there are several entities with the same entity id. |
Content-Type required | string |
address required | string |
zipCode required | integer <int32> |
city required | string |
country required | string |
{- "address": "Ronda de la Comunicacion s/n",
- "zipCode": 28050,
- "city": "Madrid",
- "country": "Spain"
}
If the values
option is not in use, this operation returns a JSON array with the entity types.
Each element is a JSON object with information about the type:
type
: the entity type name.attrs
: the set of attribute names along with all the entities of such type, represented in
a JSON object whose keys are the attribute names and whose values contain information of such
attributes (in particular a list of the types used by attributes with that name along with all the
entities).count
: the number of entities belonging to that type.
If the values
option is used, the operation returns a JSON array with a list of entity type
names as strings.
Results are ordered by entity type
in alphabetical order.
Response code:limit | number <double> Limit the number of types to be retrieved. |
offset | number <double> Skip a number of records. |
options | string Enum: "count" "values" Options dictionary. |
[- {
- "type": "Car",
- "attrs": {
- "speed": {
- "types": [
- "Number"
]
}, - "fuel": {
- "types": [
- "gasoline",
- "diesel"
]
}, - "temperature": {
- "types": [
- "urn:phenomenum:temperature"
]
}
}, - "count": 12
}, - {
- "type": "Room",
- "attrs": {
- "pressure": {
- "types": [
- "Number"
]
}, - "humidity": {
- "types": [
- "percentage"
]
}, - "temperature": {
- "types": [
- "urn:phenomenum:temperature"
]
}
}, - "count": 7
}
]
This operation returns a JSON object with information about the type:
attrs
: the set of attribute names along with all the entities of such type, represented in
a JSON object whose keys are the attribute names and whose values contain information of such
attributes (in particular a list of the types used by attributes with that name along with all the
entities).count
: the number of entities belonging to that type.
Response code:entityType required | string Entity Type |
{- "attrs": {
- "pressure": {
- "types": [
- "Number"
]
}, - "humidity": {
- "types": [
- "percentage"
]
}, - "temperature": {
- "types": [
- "urn:phenomenum:temperature"
]
}
}, - "count": 7
}
Returns a list of all the subscriptions present in the system. Response:
limit | number <double> Limit the number of subscriptions to be retrieved |
offset | number <double> Skip a number of subscriptions |
options | string Value: "count" Options dictionary |
[- {
- "id": "abcdefg",
- "description": "One subscription to rule them all",
- "subject": {
- "entities": [
- {
- "id": "Bcn_Welt",
- "type": "Room"
}
], - "condition": {
- "attrs": [
- "temperature "
], - "expression": {
- "q": "temperature>40"
}
}
}, - "notification": {
- "httpCustom": {
- "headers": {
- "X-MyHeader": "foo"
}, - "qs": {
- "authToken": "bar"
}
}, - "attrsFormat": "keyValues",
- "attrs": [
- "temperature",
- "humidity"
], - "timesSent": 12,
- "lastNotification": "2015-10-05T16:00:00Z",
- "lastFailure": "2015-10-06T16:00:00Z"
}, - "expires": "2016-04-05T14:00:00Z",
- "status": "failed",
- "throttling": 5
}
]
Creates a new subscription. The subscription is represented by a JSON object as described at the beginning of this section. Response:
Content-Type required | string |
description | string |
subject required | object |
notification required | object |
expires | string |
throttling | integer <int32> |
{- "description": "One subscription to rule them all",
- "subject": {
- "entities": [
- {
- "idPattern": ".*",
- "type": "Room"
}
], - "condition": {
- "attrs": [
- "temperature"
], - "expression": {
- "q": "temperature>40"
}
}
}, - "expires": "2016-04-05T14:00:00Z",
- "throttling": 5
}
The response is the subscription represented by a JSON object as described at the beginning of this section. Response:
subscriptionId required | string subscription Id. |
{ }
Only the fields included in the request are updated in the subscription. Response:
subscriptionId required | string subscription Id. |
Content-Type required | string |
expires required | string |
{- "expires": "2016-04-05T14:00:00Z"
}
Lists all the context provider registrations present in the system.
limit | number <double> Limit the number of registrations to be retrieved |
offset | number <double> Skip a number of registrations |
options | string Value: "count" Options dictionary |
[- {
- "id": "abcdefg",
- "description": "Example Context Source",
- "dataProvided": {
- "entities": [
- {
- "id": "Bcn_Welt",
- "type": "Room"
}
], - "attrs": [
- "temperature"
]
}, - "expires": "2017-10-31T12:00:00",
- "status": "active",
- "forwardingInformation": {
- "timesSent": 12,
- "lastForwarding": "2017-10-06T16:00:00Z",
- "lastSuccess": "2017-10-06T16:00:00Z",
- "lastFailure": "2017-10-05T16:00:00Z"
}
}
]
Creates a new context provider registration. This is typically used for binding context sources as providers of certain data. The registration is represented by a JSON object as described at the beginning of this section. Response:
Content-Type required | string |
description required | string |
dataProvided required | object |
provider required | object |
{- "description": "Relative Humidity Context Source",
- "dataProvided": {
- "entities": [
- {
- "id": "room2",
- "type": "Room"
}
], - "attrs": [
- "relativeHumidity"
]
},
}
The response is the registration represented by a JSON object as described at the beginning of this section. Response:
registrationId required | string registration Id. |
{- "id": "abcdefg",
- "description": "Example Context Source",
- "dataProvided": {
- "entities": [
- {
- "id": "Bcn_Welt",
- "type": "Room"
}
], - "attrs": [
- "temperature"
]
}, - "expires": "2017-10-31T12:00:00",
- "status": "failed",
- "forwardingInformation": {
- "timesSent": 12,
- "lastForwarding": "2017-10-06T16:00:00Z",
- "lastFailure": "2017-10-06T16:00:00Z",
- "lastSuccess": "2017-10-05T18:25:00Z"
}
}
Only the fields included in the request are updated in the registration. Response:
registrationId required | string registration Id. |
Content-Type required | string |
expires required | string |
{- "expires": "2017-10-04T00:00:00"
}
This operation allows to create, update and/or delete several entities in a single batch operation. The payload is an object with two properties:
actionType
, to specify the kind of update action to do: either append
, appendStrict
, update
,
delete
, or replace
.entities
, an array of entities, each entity specified using the JSON entity representation format
(described in the section "JSON Entity Representation").
This operation is split in as many individual operations as entities in the entities
vector, so
the actionType
is executed for each one of them. Depending on the actionType
, a mapping with
regular non-batch operations can be done:append
: maps to POST /v2/entities
(if the entity does not already exist) or POST /v2/entities/<id>/attrs
(if the entity already exists).appendStrict
: maps to POST /v2/entities
(if the entity does not already exist) or
POST /v2/entities/<id>/attrs?options=append
(if the entity already exists).update
: maps to PATCH /v2/entities/<id>/attrs
.delete
: maps to DELETE /v2/entities/<id>/attrs/<attrName>
on every attribute included in the entity or
to DELETE /v2/entities/<id>
if no attribute were included in the entity.replace
: maps to PUT /v2/entities/<id>/attrs
.
Response:options | string Value: "keyValues" Options dictionary |
Content-Type required | string |
actionType required | string |
entities required | Array of objects |
{- "actionType": "append",
- "entities": [
- {
- "type": "Room",
- "id": "Bcn-Welt",
- "temperature": {
- "value": 21.7
}, - "humidity": {
- "value": 60
}
}, - {
- "type": "Room",
- "id": "Mad_Aud",
- "temperature": {
- "value": 22.9
}, - "humidity": {
- "value": 85
}
}
]
}
The response payload is an Array containing one object per matching entity, or an empty array []
if
no entities are found. The entities follow the JSON entity representation format
(described in the section "JSON Entity Representation").
The payload may contain the following elements (all of them optional):
entities
: a list of entites to search for. Each element is represented by a JSON object with the
following elements:id
or idPattern
: Id or pattern of the affected entities. Both cannot be used at the same
time, but one of them must be present.type
or typePattern
: Type or type pattern of the entities to search for. Both cannot be used at
the same time. If omitted, it means "any entity type".attrs
: List of attributes to be provided (if not specified, all attributes).expression
: an expression composed of q
, mq
, georel
, geometry
and coords
(see "List
entities" operation above about this field).metadata
: a list of metadata names to include in the response.
See "Filtering out attributes and metadata" section for more detail.
Response code:limit | number <double> Limit the number of entities to be retrieved. |
offset | number <double> Skip a number of records. |
orderBy | string Criteria for ordering results. See "Ordering Results" section for details. |
options | string Enum: "count" "keyValues" "values" "unique" Options dictionary |
Content-Type required | string |
entities required | Array of objects |
attrs required | Array of strings |
expression required | object |
metadata required | Array of strings |
{- "entities": [
- {
- "idPattern": ".*",
- "type": "Room"
}, - {
- "id": "Car",
- "type": "P-9873-K"
}
], - "attrs": [
- "temperature",
- "humidity"
], - "expression": {
- "q": "temperature>20"
}, - "metadata": [
- "accuracy",
- "timestamp"
]
}
[- {
- "type": "Room",
- "id": "DC_S1-D41",
- "temperature": {
- "value": 35.6,
- "type": "Number"
}
}, - {
- "type": "Room",
- "id": "Boe-Idearium",
- "temperature": {
- "value": 22.5,
- "type": "Number"
}
}, - {
- "type": "Car",
- "id": "P-9873-K",
- "temperature": {
- "value": 40,
- "type": "Number",
- "accuracy": 2,
- "timestamp": {
- "value": "2015-06-04T07:20:27.378Z",
- "type": "DateTime"
}
}
}
]
This operation is intended to consume a notification payload so that all the entity data included by such notification is persisted, overwriting if necessary.
This operation is useful when one NGSIv2 endpoint is subscribed to another NGSIv2 endpoint (federation scenarios).
The request payload must be an NGSIv2 notification payload.
The behaviour must be exactly the same as POST /v2/op/update
with actionType
equal to append
.
Response code:
options | string Value: "keyValues" Options dictionary |
Content-Type required | string |
subscriptionId required | string |
data required | Array of objects |
{- "subscriptionId": "5aeb0ee97d4ef10a12a0262f",
- "data": [
- {
- "type": "Room",
- "id": "DC_S1-D41",
- "temperature": {
- "value": 35.6,
- "type": "Number"
}
}, - {
- "type": "Room",
- "id": "Boe-Idearium",
- "temperature": {
- "value": 22.5,
- "type": "Number"
}
}
]
}