NGSI-v2 Step-by-Step

Documentation NGSI v2 Support badge

This is a collection of NGSI-v2 tutorials for the FIWARE system. Each tutorial consists of a series of exercises to demonstrate the correct use of individual FIWARE components and shows the flow of context data within a simple Smart Solution either by connecting to a series of dummy IoT devices or manipulating the context directly or programmatically.

Should I use NGSI-v2 or NGSI-LD?

FIWARE offers two flavours of the NGSI interfaces:

  • NGSI-v2 offers JSON based interoperability used in individual Smart Systems
  • NGSI-LD offers JSON-LD based interoperability used for Federations and Data Spaces

NGSI-v2 is ideal for creating individual applications offering interoperable interfaces for web services or IoT devices. It is easier to understand than NGSI-LD and does not require a JSON-LD @context.

However, NGSI-LD and Linked Data is necessary when creating a data space or introducing a system of systems aproach, and in situations requiring interoperability across apps and organisations.

More information about NGSI-LD can be found here

How to Use

Each tutorial is a self-contained learning exercise designed to teach the developer about a single aspect of FIWARE. A summary of the goal of the tutorial can be found in the description at the head of each page. Every tutorial is associated with a GitHub repository holding the configuration files needed to run the examples. Most of the tutorials build upon concepts or enablers described in previous exercises the to create a complex smart solution which is "powered by FIWARE".

The tutorials are split according to the chapters defined within the FIWARE catalog and are numbered in order of difficulty within each chapter hence an introduction to a given enabler will occur before the full capabilities of that element are explored in more depth.

It is recommended to start with reading the full Core Context Management: The NGSI-v2 Interface Chapter before moving on to other subjects, as this will give you a fuller understanding of the role of context data in general. However, it is not necessary to follow all the subsequent tutorials sequentially - as FIWARE is a modular system, you can choose which enablers are of interest to you.

Prerequisites

The NGSI-v2 tutorials are designed to run under any Unix environment, the tested configuration and GitPod environment is currently based on Ubuntu 22.04.2 LTS. However, there may be some minor issues when running the tutorials directly on Windows machines or Apple M1 Silicon amd64 systems, and the following Virtual Box set-up or WSL set-up can be used when facing issues.

Docker and Docker Compose

To keep things simple all components will be run using Docker. Docker is a container technology which allows to different components isolated into their respective environments.

  • To install Docker on Windows follow the instructions here.
  • To install Docker on Mac/OS follow the instructions here.
  • To install Docker on Unix follow the instructions here.

Postman

The tutorials which use HTTP requests supply a collection for use with the Postman utility. Postman is a testing framework for REST APIs. The tool can be downloaded from www.getpostman.com. All the FIWARE Postman collections can be downloaded directly from the Postman API network.

GitPod

Gitpod is an open-source Kubernetes application for ready-to-code cloud development environments that spins up an automated dev environment for each task, in the cloud. It enables you to run the tutorials in a cloud development environment directly from your browser or your Desktop IDE. The default environment is based on Ubuntu and includes Java 11.0.16 and Maven 3.8.6.

Apache Maven

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Maven can be used to define and download our dependencies and to build and package Java or Scala code into a JAR file. Apache Maven 3.8.6 or higher is recommended.

JQ

jq is a lightweight and flexible command-line JSON processor which can be used to format the JSON responses received from the context broker and other FIWARE components. More information about how to use jq can be found here. jq-1.6 is recommended.

Data models

The following NGSI-v2 and NGSI-LD Data models are used within the tutorials:

List of Tutorials

Core Context Management: The NGSI-v2 Interface

These first tutorials are an introduction to the FIWARE Context Broker, and are an essential first step when learning to use FIWARE.

  101. Getting Started
  102. Entity Relationships
  103. CRUD Operations
  104. Context Providers
  105. Altering the Context Programmatically
  106. Subscribing to Changes in Context

Internet of Things, Robots and third-party systems

In order to make a context-based system aware of the state of the real world, it will need to access information from Robots, IoT Sensors or other suppliers of context data such as social media. It is also possible to generate commands from the context broker to alter the state of real-world objects themselves.

  201. Introduction to IoT Sensors
  202. Provisioning an IoT Agent
  203. IoT over MQTT
  204. Using an alternative IoT Agent
  205. Creating a Custom IoT Agent
  206. IoT over IOTA Tangle

Core Context Management: History Management

These tutorials show how to manipulate and store context data therefore it can be used for further processing.

  301. Persisting Context Data using Apache Flume (MongoDB, MySQL, PostgreSQL)
  302. Persisting Context Data using Apache NIFI (MongoDB, MySQL, PostgreSQL)
  303. Querying Time Series Data (MongoDB)
  304. Querying Time Series Data (Crate-DB)
  305. Big Data Analysis (Flink)
  306. Big Data Analysis (Spark)

Security: Identity Management

These tutorials show how to create and administer users within an application, and how to restrict access to assets, by assigning roles and permissions.

  401. Administrating Users and Organizations
  402. Managing Roles and Permissions
  403. Securing Application Access
  404. Securing Microservices with a PEP Proxy
  405. XACML Rules-based Permissions
  406. Administrating XACML via a PAP
  407. Authenticating Identities (OpenID)

Processing, Analysis and Visualization

These tutorials show how to create, process, analyze or visualize context information.

  501. Creating Application Mashups
  503. Introduction to Media Streams
  507. Cloud-Edge Computing

NGSI-LD for NGSI-v2 Developers

These tutorials show how to use NGSI-LD which combines context data management with linked data concepts.

  601. Introduction to Linked Data
  602. Linked Data Relationships and Data Models
  603. Traversing Linked Data
  604. Linked Data Subscriptions and Registrations