Skip to content

NGSI-LD and FiLiP

NGSI-LD is an ETSI standard API to read, write and subscribe to data about real-world entities. Every entity has an id, a type and attributes, and a JSON-LD @context that gives the attributes their meaning, usually from Smart Data Models. In the MIMs the two go together: Smart Data Models with NGSI-LD is the main mechanism of MIM2.

The calls you need most

Call Does
GET /ngsi-ld/v1/entities?type=WasteContainer&limit=100 List entities of a type
GET /ngsi-ld/v1/entities?type=WasteContainer&q=fillingLevel>0.8 Filter by attribute
GET /ngsi-ld/v1/entities/{id} One entity
…&options=keyValues Only the values, without the NGSI-LD structure
POST /ngsi-ld/v1/entityOperations/upsert Create or update several entities
POST /ngsi-ld/v1/subscriptions Be notified of changes

Send Accept: application/ld+json to get the @context inside the body.

FiLiP

FiLiP (FIWARE Library for Python), by RWTH Aachen, is a Python client for FIWARE APIs, NGSI-LD included, with Pydantic models for the entities. CitCom uses it in the MIAIS.

pip install filip
from filip.clients.ngsi_ld.cb import ContextBrokerLDClient
from filip.models.base import FiwareLDHeader

cb = ContextBrokerLDClient(url="http://localhost:1026", fiware_header=FiwareLDHeader())
containers = cb.get_entity_list(entity_type="WasteContainer", limit=100)
from filip.clients.ngsi_ld.cb import ContextBrokerLDClient
from filip.models.base import FiwareLDHeader
from ds_consumer_auth import data_space_session

cb = ContextBrokerLDClient(
    url="https://apisix-townhall-vlc.citcom-vrain-dataspace.eu/lepus",
    session=data_space_session(),  # see ds-consumer-auth
    fiware_header=FiwareLDHeader(),
    create_tenant=False,
)
containers = cb.get_entity_list(entity_type="WasteContainer", limit=100)

The code is the same at both levels; only the session changes. See ds-consumer-auth.

Brokers

Broker Notes
Orion-LD FIWARE, MongoDB. Used in Valencia for the traffic state
Scorpio NEC, PostgreSQL. Comes with the FIWARE Data Space Connector
Lepus Not a broker: serves an NGSI-v2 broker as NGSI-LD

Learn more

Next step ds-consumer-authGet the access token of the data space from your code.