swagger: '2.0'
info:
version: '1.0'
title: FIWARE-NGSI v2 Specification
description: 'TODO: Add a description'
host: orion.lab.fiware.org
basePath: /
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/v2:
get:
description: "This resource does not have any attributes. Instead it offers\
\ the initial\nAPI affordances in the form of the links in the JSON body.\n\
It is recommended to follow the \u201Curl\u201D link values,\n[Link](https://tools.ietf.org/html/rfc5988)\
\ or Location headers where\napplicable to retrieve resources. Instead of\
\ constructing your own URLs,\nto keep your client decoupled from implementation\
\ details."
summary: Retrieve API Resources
tags:
- API Entry Point
operationId: Retrieve API Resources
produces:
- application/json
parameters: []
responses:
'200':
description: ''
schema:
$ref: '#/definitions/RetrieveApiResourcesResponse'
examples:
application/json:
entities_url: /v2/entities
types_url: /v2/types
subscriptions_url: /v2/subscriptions
registrations_url: /v2/registrations
x-unitTests:
- request:
method: GET
uri: /v2
expectedResponse:
x-allowExtraHeaders: true
x-bodyMatchMode: RAW
x-arrayOrderedMatching: false
x-arrayCheckCount: false
x-matchResponseSchema: true
headers:
Content-Type: application/json
body: '{ "entities_url": "/v2/entities", "types_url": "/v2/types", "subscriptions_url":
"/v2/subscriptions", "registrations_url": "/v2/registrations"}'
x-testShouldPass: true
x-testEnabled: true
x-testName: Retrieve API Resources1
x-testDescription: "This resource does not have any attributes. Instead it\
\ offers the initial\nAPI affordances in the form of the links in the JSON\
\ body.\nIt is recommended to follow the \u201Curl\u201D link values,\n\
[Link](https://tools.ietf.org/html/rfc5988) or Location headers where\n\
applicable to retrieve resources. Instead of constructing your own URLs,\n\
to keep your client decoupled from implementation details."
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
/v2/entities:
get:
description: "Retrieves a list of entities that match different criteria by\
\ id, type, pattern matching (either id or type)\nand/or those which match\
\ a query or geographical query (see [Simple Query Language](#simple_query_language)\
\ and \n[Geographical Queries](#geographical_queries)). A given entity has\
\ to match all the criteria to be retrieved\n(i.e., the criteria is combined\
\ in a logical AND way). Note that pattern matching query parameters are incompatible\n\
(i.e. mutually exclusive) with their corresponding exact matching parameters,\
\ i.e. `idPattern` with `id` and\n`typePattern` with `type`.\nThe response\
\ payload is an array containing one object per matching entity. Each entity\
\ follows\nthe JSON entity representation format (described in \"JSON Entity\
\ Representation\" section).\nResponse code:\n* Successful operation uses\
\ 200 OK\n* Errors use a non-2xx and (optionally) an error payload. See subsection\
\ on \"Error Responses\" for\n more details."
summary: List Entities
tags:
- Entities
operationId: List Entities
produces:
- application/json
parameters:
- name: id
in: query
required: false
type: string
description: 'A comma-separated list of elements.
Retrieve entities whose ID matches one of the elements in the list.
Incompatible with `idPattern`.'
- name: type
in: query
required: false
type: string
description: 'comma-separated list of elements.
Retrieve entities whose type matches one of the elements in the list.
Incompatible with `typePattern`.'
- name: idPattern
in: query
required: false
type: string
description: 'A correctly formated regular expression.
Retrieve entities whose ID matches the regular expression. Incompatible
with `id`.'
- name: typePattern
in: query
required: false
type: string
description: 'A correctly formated regular expression.
Retrieve entities whose type matches the regular expression. Incompatible
with `type`.'
- name: q
in: query
required: false
type: string
description: 'A query expression, composed of a list of statements
separated by `;`, i.e., q=statement1;statement2;statement3.
See [Simple Query Language specification](#simple_query_language).'
- name: mq
in: query
required: false
type: string
description: 'A query expression for attribute metadata,
composed of a list of statements separated by `;`, i.e., mq=statement1;statement2;statement3.
See [Simple Query Language specification](#simple_query_language).'
- name: georel
in: query
required: false
type: string
description: 'Spatial relationship between matching entities and a
reference shape. See [Geographical Queries](#geographical_queries).'
- name: geometry
in: query
required: false
type: string
description: 'Geografical area to which the query is restricted.
See [Geographical Queries](#geographical_queries).'
- name: coords
in: query
required: false
type: string
description: 'List of latitude-longitude
pairs of coordinates separated by '';''. See [Geographical Queries](#geographical_queries).'
- name: limit
in: query
required: false
type: number
format: double
exclusiveMaximum: false
exclusiveMinimum: false
description: Limits the number of entities to be retrieved
- name: offset
in: query
required: false
type: number
format: double
exclusiveMaximum: false
exclusiveMinimum: false
description: Establishes the offset from where entities are retrieved
- name: attrs
in: query
required: false
type: string
description: '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.'
- name: metadata
in: query
required: false
type: string
description: 'A list of metadata names to include in the response.
See "Filtering out attributes and metadata" section for more detail.'
- name: orderBy
in: query
required: false
type: string
description: 'Criteria for ordering results.
See "Ordering Results" section for details.'
- name: options
in: query
required: false
enum:
- count
- keyValues
- values
- unique
x-enum-elements:
- name: count
description: ''
- name: keyValues
description: ''
- name: values
description: ''
- name: unique
description: ''
type: string
description: Options dictionary
responses:
'200':
description: ''
schema:
type: array
items:
$ref: '#/definitions/ListEntitiesResponse'
examples:
application/json:
- 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
x-unitTests:
- request:
method: GET
uri: /v2/entities?id=Boe_Idearium&type=Room&idPattern=Bode_.*&typePattern=Room_.*&q=temperature>40&mq=temperature.accuracy<0.9&georel=near&geometry=point&coords=41.390205,2.154007;48.8566,2.3522&limit=20&offset=20&attrs=seatNumber&metadata=accuracy&orderBy=temperature,!speed
expectedResponse:
x-allowExtraHeaders: true
x-bodyMatchMode: RAW
x-arrayOrderedMatching: false
x-arrayCheckCount: false
x-matchResponseSchema: true
headers:
Content-Type: application/json
body: '[ { "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" } } }
}]'
x-testShouldPass: true
x-testEnabled: true
x-testName: List Entities1
x-testDescription: "Retrieves a list of entities that match different criteria\
\ by id, type, pattern matching (either id or type)\nand/or those which\
\ match a query or geographical query (see [Simple Query Language](#simple_query_language)\
\ and \n[Geographical Queries](#geographical_queries)). A given entity has\
\ to match all the criteria to be retrieved\n(i.e., the criteria is combined\
\ in a logical AND way). Note that pattern matching query parameters are\
\ incompatible\n(i.e. mutually exclusive) with their corresponding exact\
\ matching parameters, i.e. `idPattern` with `id` and\n`typePattern` with\
\ `type`.\nThe response payload is an array containing one object per matching\
\ entity. Each entity follows\nthe JSON entity representation format (described\
\ in \"JSON Entity Representation\" section).\nResponse code:\n* Successful\
\ operation uses 200 OK\n* Errors use a non-2xx and (optionally) an error\
\ payload. See subsection on \"Error Responses\" for\n more details."
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
post:
description: "The payload is an object representing the entity to be created.\
\ The object follows\nthe JSON entity representation format (described in\
\ a \"JSON Entity Representation\" section).\nResponse:\n* Successful operation\
\ uses 201 Created (if upsert option is not used) or 204 No Content (if\n\
\ upsert option is used). Response includes a `Location` header with the\
\ URL of the\n created entity.\n* Errors use a non-2xx and (optionally) an\
\ error payload. See subsection on \"Error Responses\" for\n more details."
summary: Create Entity
tags:
- Entities
operationId: Create Entity
produces:
- application/json
parameters:
- name: Content-Type
in: header
required: true
type: string
description: ''
- name: body
in: body
required: true
description: ''
schema:
$ref: '#/definitions/CreateEntityRequest'
- name: options
in: query
required: false
enum:
- keyValues
- upsert
x-enum-elements:
- name: keyValues
description: ''
- name: upsert
description: ''
type: string
description: Options dictionary
responses:
'204':
description: ''
x-unitTests:
- request:
method: POST
uri: /v2/entities
headers:
Content-Type: application/json
body: '{ "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" } } }}'
expectedResponse:
x-allowExtraHeaders: true
x-bodyMatchMode: NONE
x-arrayOrderedMatching: false
x-arrayCheckCount: false
x-matchResponseSchema: true
headers:
Location: /v2/entities/Bcn-Welt?type=Room
x-testShouldPass: true
x-testEnabled: true
x-testName: Create Entity1
x-testDescription: "The payload is an object representing the entity to be\
\ created. The object follows\nthe JSON entity representation format (described\
\ in a \"JSON Entity Representation\" section).\nResponse:\n* Successful\
\ operation uses 201 Created (if upsert option is not used) or 204 No Content\
\ (if\n upsert option is used). Response includes a `Location` header with\
\ the URL of the\n created entity.\n* Errors use a non-2xx and (optionally)\
\ an error payload. See subsection on \"Error Responses\" for\n more details."
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
/v2/entities/{entityId}:
get:
description: '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:
* Successful operation uses 200 OK
* Errors use a non-2xx and (optionally) an error payload. See subsection on
"Error Responses" for more details.'
summary: Retrieve Entity
tags:
- Entities
operationId: Retrieve Entity
produces:
- application/json
parameters:
- name: entityId
in: path
required: true
type: string
description: Id of the entity to be retrieved
- name: type
in: query
required: false
type: string
description: 'Entity type, to avoid ambiguity in case there are several
entities with the same entity id.'
- name: attrs
in: query
required: false
type: string
description: '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.'
- name: metadata
in: query
required: false
type: string
description: 'A list of metadata names to include in the response.
See "Filtering out attributes and metadata" section for more detail.'
- name: options
in: query
required: false
enum:
- keyValues
- values
- unique
x-enum-elements:
- name: keyValues
description: ''
- name: values
description: ''
- name: unique
description: ''
type: string
description: Options dictionary
responses:
'200':
description: ''
schema:
$ref: '#/definitions/RetrieveEntityResponse'
examples:
application/json:
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
x-unitTests: []
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
delete:
description: "Delete the entity.\nResponse:\n* Successful operation uses 204\
\ No Content\n* Errors use a non-2xx and (optionally) an error payload. See\
\ subsection on \"Error Responses\" for\n more details."
summary: Remove Entity
tags:
- Entities
operationId: Remove Entity
produces:
- application/json
parameters:
- name: entityId
in: path
required: true
type: string
description: Id of the entity to be deleted
- name: type
in: query
required: false
type: string
description: 'Entity type, to avoid ambiguity in case there are several
entities with the same entity id.'
responses:
'204':
description: ''
x-unitTests: []
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
/v2/entities/{entityId}/attrs:
get:
description: "This request is similar to retreiving the whole entity, however\
\ this one omits the `id` and `type`\nfields.\nJust like the general request\
\ of getting an entire entity, this operation must return only one\nentity\
\ element. If more than one entity with the same ID is found (e.g. entities\
\ with\nsame ID but different type), an error message is returned, with the\
\ HTTP status code set to\n409 Conflict.\nResponse:\n* Successful operation\
\ uses 200 OK\n* Errors use a non-2xx and (optionally) an error payload. See\
\ subsection on \"Error Responses\" for\n more details."
summary: Retrieve Entity Attributes
tags:
- Entities
operationId: Retrieve Entity Attributes
produces:
- application/json
parameters:
- name: entityId
in: path
required: true
type: string
description: Id of the entity to be retrieved
- name: type
in: query
required: false
type: string
description: 'Entity type, to avoid ambiguity in case there are several
entities with the same entity id.'
- name: attrs
in: query
required: false
type: string
description: '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.'
- name: metadata
in: query
required: false
type: string
description: 'A list of metadata names to include in the response.
See "Filtering out attributes and metadata" section for more detail.'
- name: options
in: query
required: false
enum:
- keyValues
- values
- unique
x-enum-elements:
- name: keyValues
description: ''
- name: values
description: ''
- name: unique
description: ''
type: string
description: Options dictionary
responses:
'200':
description: ''
schema:
$ref: '#/definitions/RetrieveEntityAttributesResponse'
examples:
application/json:
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
x-unitTests: []
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
put:
description: "The request payload is an object representing the new entity attributes.\
\ The object follows\nthe JSON entity representation format (described in\
\ a \"JSON Entity Representation\" above), except\nthat `id` and `type` are\
\ not allowed.\nThe attributes previously existing in the entity are removed\
\ and replaced by the ones in the\nrequest.\nResponse:\n* Successful operation\
\ uses 204 No Content\n* Errors use a non-2xx and (optionally) an error payload.\
\ See subsection on \"Error Responses\" for\n more details."
summary: Replace all entity attributes
tags:
- Entities
operationId: Replace all entity attributes
produces:
- application/json
parameters:
- name: entityId
in: path
required: true
type: string
description: Id of the entity in question.
- name: Content-Type
in: header
required: true
type: string
description: ''
- name: body
in: body
required: true
description: ''
schema:
$ref: '#/definitions/ReplaceAllEntityAttributesRequest'
- name: type
in: query
required: false
type: string
description: 'Entity type, to avoid ambiguity in case there are several
entities with the same entity id.'
- name: options
in: query
required: false
enum:
- keyValues
x-enum-elements:
- name: keyValues
description: ''
type: string
description: Operations options
responses:
'204':
description: ''
x-unitTests: []
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
post:
description: "The request payload is an object representing the attributes to\
\ append or update. The object follows\nthe JSON entity representation format\
\ (described in \"JSON Entity Representation\" section), except\nthat `id`\
\ and `type` are not allowed.\nThe entity attributes are updated with the\
\ ones in the payload, depending on\nwhether the `append` operation option\
\ is used or not.\n* If `append` is not used: the entity attributes are updated\
\ (if they previously exist) or appended\n (if they don't previously exist)\
\ with the ones in the payload.\n* If `append` is used (i.e. strict append\
\ semantics): all the attributes in the payload not\n previously existing\
\ in the entity are appended. In addition to that, in case some of the\n \
\ attributes in the payload already exist in the entity, an error is returned.\n\
Response:\n* Successful operation uses 204 No Content\n* Errors use a non-2xx\
\ and (optionally) an error payload. See subsection on \"Error Responses\"\
\ for\n more details."
summary: Update or Append Entity Attributes
tags:
- Entities
operationId: Update or Append Entity Attributes
produces:
- application/json
parameters:
- name: entityId
in: path
required: true
type: string
description: Entity id to be updated
- name: Content-Type
in: header
required: true
type: string
description: ''
- name: body
in: body
required: true
description: ''
schema:
$ref: '#/definitions/UpdateOrAppendEntityAttributesRequest'
- name: type
in: query
required: false
type: string
description: 'Entity type, to avoid ambiguity in case there are several
entities with the same entity id.'
- name: options
in: query
required: false
enum:
- append
- keyValues
x-enum-elements:
- name: append
description: ''
- name: keyValues
description: ''
type: string
description: Operations options
responses:
'204':
description: ''
x-unitTests: []
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
patch:
description: "The request payload is an object representing the attributes to\
\ update. The object follows\nthe JSON entity representation format (described\
\ in \"JSON Entity Representation\" section), except\nthat `id` and `type`\
\ are not allowed.\nThe entity attributes are updated with the ones in the\
\ payload. In addition to that, if one or more\nattributes in the payload\
\ doesn't exist in the entity, an error is returned.\nResponse:\n* Successful\
\ operation uses 204 No Content\n* Errors use a non-2xx and (optionally) an\
\ error payload. See subsection on \"Error Responses\" for\n more details."
summary: Update Existing Entity Attributes
tags:
- Entities
operationId: Update Existing Entity Attributes
produces:
- application/json
parameters:
- name: entityId
in: path
required: true
type: string
description: Id of the entity to be updated
- name: Content-Type
in: header
required: true
type: string
description: ''
- name: body
in: body
required: true
description: ''
schema:
$ref: '#/definitions/UpdateExistingEntityAttributesRequest'
- name: type
in: query
required: false
type: string
description: 'Entity type, to avoid ambiguity in case there are several
entities with the same entity id.'
- name: options
in: query
required: false
enum:
- keyValues
x-enum-elements:
- name: keyValues
description: ''
type: string
description: Operations options
responses:
'204':
description: ''
x-unitTests: []
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
/v2/entities/{entityId}/attrs/{attrName}:
get:
description: "Returns a JSON object with the attribute data of the attribute.\
\ The object follows the JSON\nrepresentation for attributes (described in\
\ \"JSON Attribute Representation\" section).\nResponse:\n* Successful operation\
\ uses 200 OK.\n* Errors use a non-2xx and (optionally) an error payload.\
\ See subsection on \"Error Responses\" for\n more details."
summary: Get attribute data
tags:
- Attributes
operationId: Get attribute data
produces:
- application/json
parameters:
- name: entityId
in: path
required: true
type: string
description: Id of the entity
- name: attrName
in: path
required: true
type: string
description: Name of the attribute to be retrieved.
- name: type
in: query
required: false
type: string
description: 'Entity type, to avoid ambiguity in case there are several
entities with the same entity id.'
- name: metadata
in: query
required: false
type: string
description: 'A list of metadata names to include in the response.
See "Filtering out attributes and metadata" section for more detail.'
responses:
'200':
description: ''
schema:
$ref: '#/definitions/GetAttributeDataResponse'
examples:
application/json:
value: 21.7
type: Number
metadata: {}
x-unitTests:
- request:
method: GET
uri: /v2/entities/Bcn_Welt/attrs/temperature?metadata=accuracy
expectedResponse:
x-allowExtraHeaders: true
x-bodyMatchMode: RAW
x-arrayOrderedMatching: false
x-arrayCheckCount: false
x-matchResponseSchema: true
headers:
Content-Type: application/json
body: '{ "value": 21.7, "type": "Number", "metadata": {}}'
x-testShouldPass: true
x-testEnabled: true
x-testName: Get attribute data1
x-testDescription: "Returns a JSON object with the attribute data of the attribute.\
\ The object follows the JSON\nrepresentation for attributes (described\
\ in \"JSON Attribute Representation\" section).\nResponse:\n* Successful\
\ operation uses 200 OK.\n* Errors use a non-2xx and (optionally) an error\
\ payload. See subsection on \"Error Responses\" for\n more details."
x-operation-settings:
CollectParameters: false
AllowDynamicQueryParameters: false
AllowDynamicFormParameters: false
IsMultiContentStreaming: false
put:
description: "The request payload is an object representing the new attribute\
\ data. Previous attribute data\nis replaced by the one in the request. The\
\ object follows the JSON representation for attributes\n(described in \"\
JSON Attribute Representation\" section).\nResponse:\n* Successful operation\
\ uses 204 No Content\n* Errors use a non-2xx and (optionally) an error payload.\
\ See subsection on \"Error Responses\" for\n more details."
summary: Update Attribute Data
tags:
- Attributes
operationId: Update Attribute Data
produces:
- application/json
parameters:
- name: entityId
in: path
required: true
type: string
description: Id of the entity to update
- name: attrName
in: path
required: true
type: string
description: Attribute name
- name: Content-Type
in: header
required: true
type: string
description: ''
- name: body
in: body
required: true
description: ''
schema:
$ref: '#/definitions/UpdateAttributeDataRequest'
- name: type
in: query
required: false
type: string
description: 'Entity type, to avoid ambiguity in case there are several
entities with the same entity id.'
responses:
'200':
# --- truncated at 32 KB (112 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/fiware/refs/heads/main/openapi/fiware-ngsiv2-openapi.yml