API Usage

HIAS TassAI Facial Recognition Agent

 

Introduction

The following is the API Documentation for the HIASCDI API. This API is based on the specifications provided in the FIWARE-NGSI v2 Specification.

 

Secure HTTP Requests

API calls to the HIASCDI API are made using secure HTTP requests. The HIAS server protects the API endpoints with strong SSL encryption, a firewall and Basic AUTH authentication.

The following HTTP request methods are available:

HTTP Responses

HTTP Success Response

HTTP Success Codes

HTTP Error Response

The error payload is a JSON response including the following fields:

HTTP Error Codes

 

Authentication

Authentication is handled using the HIAS server security. Calls to HIASCDI must provide a HIAS user's key (YourKey below) in the Authorization header, authorization type Basic. A HIAS user's key is generated by joining the username and password with a : separating them, and then Base64 encoding the key.

headers = {
    "Content-Type": "application/json",
    "Authorization": "Basic YourKey"
}

 

API Entry Point

Retrieve API Resources

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.

GET https://YourHIAS/hiascdi/v1

Response

Attributes
entities_url
required
string
URL which points to the entities resource
/v1/entities
types_url
required
string
URL which points to the types resource
/v1/types
subscriptions_url
required
string
URL which points to the subscriptions resource
/v1/subscriptions
registrations_url
required
string
URL which points to the registrations resource
/v1/registrations

 

Entities

List Entities

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 of the FIWARE NGSI-V2 specification).

GET https://YourHIAS/hiascdi/v1/entities?id=00000000-0000-0000-0000-000000000000000&type=Robotics&idPattern=00000000-.*&typePattern=Room_.*&q=temperature%3E40&mq=temperature.accuracy%3C0.9&georel=near&geometry=point&coords=41.390205%2C2.154007%3B48.8566%2C2.3522&limit=20&offset=20&attrs=seatNumber&metadata=cpuUsage&orderBy=temperature%2C!speed&options=

Parameters Compliant Verified
id A comma-separated list of elements. Retrieve entities whose ID matches one of the elements in the list. Incompatible with idPattern.
Example: 00000000-0000-0000-0000-000000000000000.
String
type A comma-separated list of elements. Retrieve entities whose type matches one of the elements in the list. Incompatible with typePattern.
Example: Robotics.
String
idPattern A correctly formated regular expression. Retrieve entities whose ID matches the regular expression. Incompatible with id.
Example: 00000000-.*.
String
typePattern A correctly formated regular expression. Retrieve entities whose type matches the regular expression. Incompatible with type.
Example: Robot.*.
String
q A query expression, composed of a list of statements separated by ;, i.e., q=statement1;statement2;statement3. See Simple Query Language specification.
Example: batteryLevel.value==0.
String
mq 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.
Example: batteryLevel.accuracy<0.9.
String
georel Spatial relationship between matching entities and a reference shape. See Geographical Queries specification.
Example: near.
String
geometry Geografical area to which the query is restricted. See Geographical Queries specification.
Example: point.
String
coords List of latitude-longitude pairs of coordinates separated by ';'. See Geographical Queries specification.
Example: 41.390205,2.154007;48.8566,2.3522.
String
limit Limits the number of entities to be retrieved.
Example: 20.
Number
offset Establishes the offset from where entities are retrieved.
Example: 20.
Number
attrs 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.
Example: name.
String
metadata A list of metadata names to include in the response. See "Filtering out attributes and metadata" section of specifications for more detail.
Example: cpuUsage.
String
orderBy Criteria for ordering results. See "Ordering Results" section of specifications for details.
Example: temperature,!speed.
String
Options Options dictionary.
Possible values: count, keyValues , values , unique.
String

Response

 

Create Entity

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).

POST https://YourHIAS/hiascdi/v1/entities?options=

Parameters Compliant Verified
Options Options dictionary.
Possible values: keyValues, upsert.
String

Response:

 

Entity by ID

Retrieve Entity

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.

GET https://YourHIAS/hiascdi/v1/entityId?type=&attrs=network_location%2network_status&metadata=cpuUsage&options=

Parameters Compliant Verified
entityId Id of the entity to be retrieved. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
attrs 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.
Example: network_location,network_status
String
metadata A list of metadata names to include in the response. See "Filtering out attributes and metadata" section for more detail.
Example: cpuUsage
String
Options Options dictionary.
Possible values: keyValues, value, unique.
String

Response:

 

Retrieve Entity Attributes

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.

GET https://YourHIAS/hiascdi/v1/entityId/attrs?type=&attrs=network_location%2network_status&metadata=cpuUsage&options=

Parameters Compliant Verified
entityId Id of the entity to be retrieved. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
attrs 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.
Example: network_location,network_status
String
metadata A list of metadata names to include in the response. See "Filtering out attributes and metadata" section for more detail.
Example: cpuUsage
String
Options Options dictionary.
Possible values: keyValues, value, unique.
String

Response:

 

Update or Append Entity Attributes

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.

POST https://YourHIAS/hiascdi/v1/entityId/attrs?type=&options=

Parameters Compliant Verified
entityId Id of the entity to be updated. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
Options Options dictionary.
Possible values: keyValues, append.
String

Response:

 

Update Existing Entity Attributes

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.

PATCH https://YourHIAS/hiascdi/v1/entityId/attrs?type=&options=

Parameters Compliant Verified
entityId Id of the entity to be updated. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
Options Options dictionary.
Possible values: keyValues.
String

Response:

 

Replace All Entity Attributes

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.

PUT https://YourHIAS/hiascdi/v1/entityId/attrs?type=&options=

Parameters Compliant Verified
entityId Id of the entity to be updated. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
Options Options dictionary.
Possible values: keyValues.
String

Response:

 

Remove Entity

Delete the entity.

DELETE https://YourHIAS/hiascdi/v1/entityId?type=

Parameters Compliant Verified
entityId Id of the entity to be updated. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String

Response:

 

Attributes

Attribute by Entity ID

Get Attribute Data

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).

GET https://YourHIAS/hiascdi/v1/entityId/attrs/attrName?type=&metadata=cpuUsage

Parameters Compliant Verified
entityId Id of the entity. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
attrName Name of the attribute to be retrieved. (REQUIRED) String
metadata A list of metadata names to include in the response. See "Filtering out attributes and metadata" section for more detail.
Example: cpuUsage
String

Response:

 

Update Attribute Data

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).

PUT https://YourHIAS/hiascdi/v1/entityId/attrs/attrName?type=

Parameters Compliant Verified
entityId Id of the entity. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
attrName Name of the attribute to be retrieved. (REQUIRED) String

Response:

 

Remove A Single Attribute

Removes an entity attribute.

DELETE https://YourHIAS/hiascdi/v1/entityId/attrs/attrName?type=

Parameters Compliant Verified
entityId Id of the entity. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
attrName Name of the attribute to be retrieved. (REQUIRED) String

Response:

 

Attribute Value

By Entity ID

Get Attribute Value

This operation returns the value property with the value of the attribute.

GET https://YourHIAS/hiascdi/v1/entityId/attrs/attrName/value?type=

Parameters Compliant Verified
entityId Id of the entity. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
attrName Name of the attribute to be retrieved. (REQUIRED) String

Response:

 

Update Attribute Value

The request payload is the new attribute value.

The payload MIME type in the request is specified in the Content-Type HTTP header.

PUT https://YourHIAS/hiascdi/v1/entityId/attrs/attrName/value?type=

Parameters Compliant Verified
entityId Id of the entity. (REQUIRED) String
type Entity type, to avoid ambiguity in case there are several entities with the same entity id. String
attrName Name of the attribute to be retrieved. (REQUIRED) String

Response:

 

Types

Entity types

List Entity Types

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:

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.

GET https://YourHIAS/hiascdi/v1/types/?limit=10&offset=20&options=

Parameters Compliant Verified
limit Limit the number of types to be retrieved.
Example: 10
Number
offset Skip a number of records.
Example: 20
Number
Options Options dictionary.
Possible values: count, values.
String

Response code:

 

Create Entity Types (CUSTOM)

The request payload is a JSON object with the type type with information about the entity type:

POST https://YourHIAS/hiascdi/v1/types/

Response code:

 

Update Entity Types (CUSTOM)

The request payload is a JSON object with the type type with information about the entity type:

PATCH https://YourHIAS/hiascdi/v1/types/

Response code:

 

Entity Type

Retrieve Entity Type

This operation returns a JSON object with information about the type:

GET https://YourHIAS/hiascdi/v1/types/entityType

Parameters Compliant Verified
entityType Entity Type.
Example: Robotics
String

Response code:

 

Subscriptions

A subscription is represented by a JSON object with the following fields:

A subject contains the following subfields:

A notification object contains the following subfields:

An http object contains the following subfields:

An httpCustom object contains the following subfields.

If httpCustom is used, then the considerations described in "Custom Notifications" section apply.

Notification rules are as follow:

 

Subscription List

List Subscriptions

Returns a list of all the subscriptions present in the system.

GET https://YourHIAS/hiascdi/v1/subscriptions?limit=10&offset=20&options=

Parameters Compliant Verified
limit Limit the number of subscriptions to be retrieved.
Example: 10
Number
offset Skip a number of records.
Example: 20
Number
Options Options dictionary.
Possible values: count, values.
String

Response:

 

Create Subscription

Creates a new subscription. The subscription is represented by a JSON object as described at the beginning of this section.

POST https://YourHIAS/hiascdi/v1/subscriptions

Parameters Compliant Verified
NA

Response:

 

Subscription By ID

Retrieve Subscription

The response is the subscription represented by a JSON object as described at the beginning of this section.

GET https://YourHIAS/hiascdi/v1/subscriptions/subscriptionId

Parameters Compliant Verified
subscriptionId Subscription Id.
Example: abcdef
String

Response:

 

Update Subscription

Only the fields included in the request are updated in the subscription.

PATCH https://YourHIAS/hiascdi/v1/subscriptions/subscriptionId

Parameters Compliant Verified
subscriptionId Subscription Id.
Example: abcdef
String

Response:

 

Delete Subscription

Cancels subscription.

DELETE https://YourHIAS/hiascdi/v1/subscriptions/subscriptionId

Parameters Compliant Verified
NA

Response:

 

Registrations

A Context Registration allows to bind external context information sources so that they can play the role of providers of certain subsets (entities, attributes) of the context information space, including those located at specific geographical areas.

A NGSIv2 server implementation may implement query and/or update forwarding to context information sources. In particular, some of the following forwarding mechanisms could be implemented (not exahustive list):

Please check the corresponding specification in order to get the details.

A context registration is represented by a JSON object with the following fields:

The provider field contains the following subfields:

 

Registration list

List Registrations

Lists all the context provider registrations present in the system.

GET https://YourHIAS/hiascdi/v1/registrations?limit=10&offset=20&options=

Parameters Compliant Verified
limit Limit the number of registrations to be retrieved.
Example: 10
Number
offset Skip a number of records.
Example: 20
Number
Options Options dictionary.
Possible values: count.
String

Response:

 

Create Registration

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.

POST https://YourHIAS/hiascdi/v1/registrations

Response:

 

Registration By ID

Retrieve Registration

The response is the registration represented by a JSON object as described at the beginning of this section.

GET https://YourHIAS/hiascdi/v1/registrations/registrationId

Parameters Compliant Verified
registrationId Registration Id.
Example: abcdef
String

Response:

 

Update Registration

Only the fields included in the request are updated in the registration.

PATCH https://YourHIAS/hiascdi/v1/registrations/registrationId

Parameters Compliant Verified
registrationId Registration Id.
Example: abcdef
String

Response:

 

Delete Registration

Cancels a context provider registration.

DELETE https://YourHIAS/hiascdi/v1/registrations/registrationId

Parameters Compliant Verified
registrationId Registration Id.
Example: abcdef
String

Response:

 

Batch Operations

Update

This operation allows to create, update and/or delete several entities in a single batch operation. The payload is an object with two properties:

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:

POST https://YourHIAS/hiascdi/v1/op/update

Parameters Compliant Verified
options Options dictionary.
Possible values: keyValues.
String

Response:

 

Query

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):

POST https://YourHIAS/hiascdi/v1/op/query?limit=10&offset=20&options=

Parameters Compliant Verified
limit Limit the number of entities to be retrieved.
Example: 10
Number
offset Skip a number of records.
Example: 20
Number
offset Criteria for ordering results. See "Ordering Results" section for details.
Example: temperature,!speed
String
Options Options dictionary.
Possible values: count, values, keyValues, unique.
String

Response code:

 

Notify

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 /hiascdi/v1/op/update with actionType equal to append.

POST https://YourHIAS/hiascdi/v1/op/notify?options=

Parameters Compliant Verified
Options Options dictionary.
Possible values: keyValues.
String

Response code:

 

Contributing

Asociación de Investigacion en Inteligencia Artificial Para la Leucemia Peter Moss encourages and welcomes code contributions, bug fixes and enhancements from the Github community.

Ways to contribute

The following are ways that you can contribute to this project:

Please read the CONTRIBUTING document for a contribution guide.

You can also join in with, or create, a discussion in our Github Discussions area.

Contributors

All contributors to this project are listed below.

 

Versioning

We use SemVer for versioning.

 

License

This project is licensed under the MIT License - see the LICENSE file for details.

 

Bugs/Issues

You use the repo issues to track bugs and general requests related to using this project. See CONTRIBUTING for more info on how to submit bugs, feature requests and proposals.