{"info":{"_postman_id":"37a6dc59-bcbb-4813-b1b3-5b088f4e3bdd","name":"NGSI-LD Working with @context","description":"<html><head></head><body><p>This tutorial examines the interaction between <strong>NGSI-LD</strong> and <strong>JSON-LD</strong> <code>@context</code> files. The <code>@context</code> files generated in the <a href=\"https://github.com/FIWARE/tutorials.Understanding-At-Context\">previous tutorial</a> are used as the underlying data model for inputing context data and context information is queries and read back in different formats.</p>\n<p>The <code>docker-compose</code> file for this tutorial can be found on GitHub: </p>\n<p><img src=\"https://fiware.github.io/tutorials.Getting-Started/icon/GitHub-Mark-32px.png\" alt=\"GitHub\"> <a href=\"https://github.com/FIWARE/tutorials.Getting-Started/tree/NGSI-LD\">FIWARE-LD 102: Working with <code>@context</code> </a></p>\n<h1 id=\"working-with-context-files\">Working with <code>@context</code> files</h1>\n<blockquote>\n<p>“Some quotations are greatly improved by lack of context.”</p>\n<p>― John Wyndham, The Midwich Cuckoos</p>\n</blockquote>\n<p>From the <a href=\"https://github.com/FIWARE/tutorials.Understanding-At-Context\">previous tutorial</a> we have generated two <code>@context</code> files defining the context data entities which will be offered in our simple Smart Farm Management System. This means that we have defined an agreed set of unique IDs (URNs or URLs) for all the\ndata entities and every single attribute within those entities so that other external applications will be able to programmatically understand the data held within our broker.</p>\n<p>For example the attribute <code>address</code> is within our smart application is defined as follows:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-jsonld\">\"@context\": {\n    \"schema\": \"https://schema.org/\",\n    \"address\": \"schema:address\"\n}\n</code></pre>\n<p>Which means that every <code>address</code> attribute follows the definition as defined by <code>schema.org</code>:</p>\n<p><code>https://schema.org/address</code> :</p>\n<p><img src=\"https://fiware.github.io/tutorials.Working-with-At-Context/img/architecture-ld.png\" alt=\"\"></p>\n<p>A program written by a third party would therefore be able to extract information such the fact an <code>address</code> attribute holds a JSON object with a sub-attribute containing the <code>streetAddress</code>  by referring to the full <a href=\"https://schema.org/version/latest/schemaorg-current-http.jsonld\">schema.org <strong>JSON-LD</strong> schema</a></p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-jsonld\">{\n  \"@id\": \"http://schema.org/streetAddress\",\n  \"@type\": \"rdf:Property\",\n  \"http://schema.org/domainIncludes\": {\n    \"@id\": \"http://schema.org/PostalAddress\"\n  },\n  \"http://schema.org/rangeIncludes\": {\n    \"@id\": \"http://schema.org/Text\"\n  },\n  \"rdfs:comment\": \"The street address. For example, 1600 Amphitheatre Pkwy.\",\n  \"rdfs:label\": \"streetAddress\"\n}\n</code></pre>\n<p>This is the <strong>JSON-LD</strong> programmatic syntax allowing computers to extract meaningful data <em>The attribute <code>address.streetAddress</code> is a street</em> directly without the need for human intervention.</p>\n<p>Imagine the case where a company is contracting agricultural labourers. The farmer will need to be billed for the work done. If such a system is built on JSON-LD, it does not matter if the farmer's Farm Management Information System assigns different names to the attributes of the billing address provided that the farmer and contractor can agree on the well-defined URNS for each attribute as <strong>JSON-LD</strong> can easily translate between the two formats using common expansion and compaction algorithms.</p>\n<h2 id=\"ngsi-ld-rules\">NGSI-LD Rules</h2>\n<p><strong>NGSI-LD</strong> is a formally structured <em>extended subset</em> of <strong>JSON-LD</strong>. Therefore <strong>NGSI-LD</strong> offers all the interoperability and flexibility of <strong>JSON-LD</strong> itself. It also defines its own core <code>@context</code> which cannot be overridden for <strong>NGSI-LD</strong> operations. This means that <strong>NGSI-LD</strong> users agree to a common well defined set of rules for structuring their data, and then supplement this with the rest of the <strong>JSON-LD</strong> specification.</p>\n<p>Whilst interacting directly with <strong>NGSI-LD</strong> interface of the context broker the additional <strong>NGSI-LD</strong> rules must be respected. However after the data has been extracted it is possible to loosen this requirement and pass the results to third parties as <strong>JSON-LD</strong>.</p>\n<p>This tutorial is a simple introduction to the rules and restrictions behind <strong>NGSI-LD</strong> and  will create some <strong>NGSI-LD</strong> entities and then extract the data in different formats. The two main data formats are <em>normalized</em> and <em>key-value-pairs</em>. Data returned in the  <em>normalised</em> format respects the <strong>NGSI-LD</strong> rules and may be used directly by another context broker (or any other component offering an <strong>NGSI-LD</strong> interface). Data returned in the  <em>key-value-pairs</em> format is by definition not <strong>NGSI-LD</strong>.</p>\n<h2 id=\"content-negociation-and-the-content-type-and-accept-headers\">Content negociation and the <code>Content-Type</code> and <code>Accept</code> Headers</h2>\n<p>During content negociation, <strong>NGSI-LD</strong> offers data in one of three formats, these effect the structure of the payload body.</p>\n<ul>\n<li><code>Accept: application/json</code> - the response is in <strong>JSON</strong> format</li>\n<li><code>Accept: application/ld+json</code> - the response is in <strong>JSON-LD</strong> format</li>\n<li><code>Accept: application/geo+json</code> - the response is in <strong>GeoJSON</strong> or <strong>GeoJSON-LD</strong> format</li>\n</ul>\n<p>The major difference between <strong>JSON</strong> format and <strong>JSON-LD</strong> format, is that if <strong>JSON-LD</strong> format is chosen, then the <code>@context</code> is found as an additional attribute within the body of the response. if the <strong>JSON</strong> only format is used the <code>@context</code> is passed as an additional <code>Link</code> Header element and is not found in the response body.</p>\n<p>Similarly when sending <strong>NGSI-LD</strong> data to the context broker, an application may choose to send a payload including an additional <code>@context</code> attribute (in which case <code>Content-Type: application/ld+json</code>) or the application may send NGSI-LD data without an additional <code>@context</code> attribute (in which case <code>Content-Type: application/json</code> and the <code>Link</code> header must also be present).</p>\n<p>The <strong>GeoJSON</strong> format is only used when querying a context broker for existing data and returns the context in a format suitable for GIS systems. It is a recent addition to the <strong>NGSI-LD</strong> specification and therefore will not be discussed further here.</p>\n<h1 id=\"prerequisites\">Prerequisites</h1>\n<h2 id=\"docker\">Docker</h2>\n<p>To keep things simple all components will be run using <a href=\"https://www.docker.com\">Docker</a>. <strong>Docker</strong> is a container\ntechnology which allows to different components isolated into their respective environments.</p>\n<ul>\n<li>To install Docker on Windows follow the instructions <a href=\"https://docs.docker.com/docker-for-windows/\">here</a></li>\n<li>To install Docker on Mac follow the instructions <a href=\"https://docs.docker.com/docker-for-mac/\">here</a></li>\n<li>To install Docker on Linux follow the instructions <a href=\"https://docs.docker.com/install/\">here</a></li>\n</ul>\n<p><strong>Docker Compose</strong> is a tool for defining and running multi-container Docker applications. A\n<a href=\"https://raw.githubusercontent.com/Fiware/tutorials.Working-with-At-Context/master/docker-compose/orion-ld.yml\">YAML file</a> is used\nconfigure the required services for the application. This means all container services can be brought up in a single\ncommand. Docker Compose is installed by default as part of Docker for Windows and Docker for Mac, however Linux users\nwill need to follow the instructions found <a href=\"https://docs.docker.com/compose/install/\">here</a></p>\n<h2 id=\"cygwin\">Cygwin</h2>\n<p>We will start up our services using a simple bash script. Windows users should download <a href=\"http://www.cygwin.com/\">cygwin</a>\nto provide a command-line functionality similar to a Linux distribution on Windows.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Working with @context files","slug":"working-with-context-files"},{"content":"Prerequisites","slug":"prerequisites"}],"owner":"513743","collectionId":"37a6dc59-bcbb-4813-b1b3-5b088f4e3bdd","publishedId":"T1LV7iXM","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"233C68"},"publishDate":"2020-08-21T14:22:49.000Z"},"item":[{"name":"Reading @Context","item":[{"name":"Obtain the NGSI-LD Linked Data context","id":"1871d872-9b69-4147-811f-8a290ddc8e84","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:3004/ngsi-context.jsonld","description":"<p>The <strong>NGSI-LD</strong> <code>@context</code> serves to define all attributes when sending data to the context broker or retrieving data in <em>normalized</em> format. This <code>@context</code> must be used for all <strong>NGSI-LD</strong> to <strong>NGSI-LD</strong> interactions</p>\n","urlObject":{"protocol":"http","port":"3004","path":["ngsi-context.jsonld"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"1871d872-9b69-4147-811f-8a290ddc8e84"},{"name":"Obtain the JSON-LD Linked Data context","id":"67f456a8-ba34-4c33-8bf6-65af5ac36430","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:3004/json-context.jsonld","description":"<p>The <strong>JSON-LD</strong> <code>@context</code> can be used when querying the data and returning <em>key-values</em> data. Responses are <strong>JSON</strong> or <strong>JSON-LD</strong> and the data can be easily ingested and processed further by the receiving application.</p>\n<ul>\n<li><a href=\"http://localhost:3000/data-models/json-context.jsonld\"><code>json-context.jsonld</code></a> is a richer <strong>JSON-LD</strong> definition of the attributes of the data models.</li>\n<li><a href=\"http://localhost:3000/data-models/alternate-context.jsonld\"><code>alternate-context.jsonld</code></a> is an alternative <strong>JSON-LD</strong> definition of the attributes of the data models used by a third-party (the German sub-contractor of farm labourers). Internally their billing application used different short names for attributes. Their <code>@context</code> file reflects the agreed mapping between attribute names.</li>\n</ul>\n","urlObject":{"protocol":"http","port":"3004","path":["json-context.jsonld"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"67f456a8-ba34-4c33-8bf6-65af5ac36430"}],"id":"bca05a93-9b17-454c-9434-368a7969d15b","_postman_id":"bca05a93-9b17-454c-9434-368a7969d15b","description":""},{"name":"Linked Data using Orion-LD","item":[{"name":"Obtaining Version Information","id":"5433c7c0-0d6f-4b4a-bc5c-634a0b1705e3","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/version/","description":"<p>As usual, you can check if the Orion Context Broker is running by making an HTTP request to the exposed port.</p>\n<p>The response will look similar to the following:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">{\n    \"orion\": {\n        \"version\": \"1.15.0-next\",\n        \"uptime\": \"0 d, 3 h, 1 m, 51 s\",\n        \"git_hash\": \"af440c6e316075266094c2a5f3f4e4f8e3bb0668\",\n        \"compile_time\": \"Tue Jul 16 15:46:18 UTC 2019\",\n        \"compiled_by\": \"root\",\n        \"compiled_in\": \"51b4d802385a\",\n        \"release_date\": \"Tue Jul 16 15:46:18 UTC 2019\",\n        \"doc\": \"https://fiware-orion.readthedocs.org/en/master/\"\n    }\n}\n</code></pre>\n<p>The format of the version response has not changed. The <code>release_date</code> must be 16th July 2019 or later to be able to\nwork with the requests defined below.</p>\n","urlObject":{"protocol":"http","path":["version",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"5433c7c0-0d6f-4b4a-bc5c-634a0b1705e3"}],"id":"8702e883-0048-43e9-925a-0c10f6629062","description":"<h1 id=\"architecture\">Architecture</h1>\n<p>The demo application will send and receive NGSI-LD calls to a compliant context broker. Since the standardized NGSI-LD interface is available across\nmultiple context brokers, so we only need to pick one - for example the\n<a href=\"https://fiware-orion.readthedocs.io/en/latest/\">Orion Context Broker</a>. The application will therefore only make use of one FIWARE component.</p>\n<p>Currently, the Orion Context Broker relies on open source <a href=\"https://www.mongodb.com/\">MongoDB</a> technology to keep\npersistence of the context data it holds.</p>\n<p>To promote interoperability of data exchange, NGSI-LD context brokers explicitly expose a <a href=\"https://json-ld.org/spec/latest/json-ld/#the-context\">JSON-LD <code>@context</code> file</a> to define the data held within the context entities. This defines a unique URI for every entity type and every attribute so that other services outside of the NGSI domain are able to pick and choose the names of their data structures. Every <code>@context</code> file must be available on the\nnetwork. In our case the tutorial application will be used to host a series of static files.</p>\n<p>Therefore, the architecture will consist of three elements:</p>\n<ul>\n<li>The <a href=\"https://fiware-orion.readthedocs.io/en/latest/\">Orion Context Broker</a> which will receive requests using\n<a href=\"https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/spec/updated/full_api.json\">NGSI-LD</a></li>\n<li>The underlying <a href=\"https://www.mongodb.com/\">MongoDB</a> database :<ul>\n<li>Used by the Orion Context Broker to hold context data information such as data entities, subscriptions and\nregistrations</li>\n</ul>\n</li>\n<li>The <strong>Tutorial Application</strong> does the following:<ul>\n<li>Offers static <code>@context</code> files defining the context entities within the system.</li>\n</ul>\n</li>\n</ul>\n<p>Since all interactions between the three elements are initiated by HTTP requests, the elements can be containerized and\nrun from exposed ports.</p>\n<p><img src=\"https://fiware.github.io/tutorials.Working-with-At-Context/img/architecture.png\" alt /></p>\n<p>The necessary configuration information can be seen in the services section of the associated <code>orion-ld.yml</code> file:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">orion:\n    image: fiware/orion-ld\n    hostname: orion\n    container_name: fiware-orion\n    depends_on:\n        - mongo-db\n    networks:\n        - default\n    ports:\n        - \"1026:1026\"\n    command: -dbhost mongo-db -logLevel DEBUG\n    healthcheck:\n        test: curl --fail -s http://orion:1026/version || exit 1\n</code></pre>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">mongo-db:\n    image: mongo:3.6\n    hostname: mongo-db\n    container_name: db-mongo\n    expose:\n        - \"27017\"\n    ports:\n        - \"27017:27017\"\n    networks:\n        - default\n    command: --nojournal\n</code></pre>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">tutorial:\n    image: fiware/tutorials.ngsi-ld\n    hostname: tutorial\n    container_name: fiware-tutorial\n    networks:\n      default:\n        aliases:\n          - context\n    expose:\n      - 3000\n</code></pre>\n<p>All containers are residing on the same network - the Orion Context Broker is listening on Port <code>1026</code> and MongoDB is\nlistening on the default port <code>27017</code> and the tutorial app is listening on port <code>3000</code>. All containers are also exposing the same ports externally - this is purely for\nthe tutorial access - so that cUrl or Postman can access them without being part of the same network. The command-line\ninitialization should be self explanatory.</p>\n<h1 id=\"start-up\">Start Up</h1>\n<p>All services can be initialised from the command-line by running the\n<a href=\"https://github.com/FIWARE/tutorials.Working-with-At-Context/blob/master/services\">services</a> Bash script provided within the\nrepository. Please clone the repository and create the necessary images by running the commands as shown:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-bash\">git clone https://github.com/FIWARE/tutorials.Working-with-At-Context.git\ncd tutorials.Working-with-At-Context\n\n./services orion|scorpio\n</code></pre>\n<blockquote>\n<p><strong>Note:</strong> If you want to clean up and start over again you can do so with the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>./services stop\n</code></pre></blockquote>\n","event":[{"listen":"prerequest","script":{"id":"391fedfe-2adf-4403-a57a-a5ea43bbbe56","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"4114c796-0df5-4d11-9397-de5f68ed1bf2","type":"text/javascript","exec":[""]}}],"_postman_id":"8702e883-0048-43e9-925a-0c10f6629062"},{"name":"Creating your first Data Entity","id":"95499812-dd17-48c5-a894-0bab4f5ecb11","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/ld+json"}],"body":{"mode":"raw","raw":"{\n    \"id\": \"urn:ngsi-ld:Building:farm001\",\n    \"type\": \"Building\",\n    \"category\": {\n    \t\"type\": \"VocabProperty\",\n        \"vocab\": [\"farm\"]\n    },\n    \"address\": {\n        \"type\": \"Property\",\n        \"value\": {\n            \"streetAddress\": \"Großer Stern 1\",\n            \"addressRegion\": \"Berlin\",\n            \"addressLocality\": \"Tiergarten\",\n            \"postalCode\": \"10557\"\n        },\n        \"verified\": {\n\t\t\t\"type\": \"Property\",\n\t\t\t\"value\": true\n\t\t}\n    },\n    \"location\": {\n        \"type\": \"GeoProperty\",\n        \"value\": {\n             \"type\": \"Point\",\n             \"coordinates\": [13.3505, 52.5144]\n        }\n    },\n    \"name\": {\n        \"type\": \"Property\",\n        \"value\": \"Victory Farm\"\n    },\n    \"@context\": \"http://context/ngsi-context.jsonld\"\n}"},"url":"http://localhost:1026/ngsi-ld/v1/entities/","description":"<p>New context data entities can be created by making a POST request to the <code>/ngsi-ld/v1/entities</code> endpoint and supply an <code>@context</code> along with structured <strong>NGSI-LD</strong> data.</p>\n<p>The first request will take some time, as the context broker must navigate and load all of the files mentioned in the\n<code>@context</code>.</p>\n<p>Since the <code>Content-Type: application/ld+json</code> the <code>@context</code> is supplied in the body of the request. As with all <strong>NGSI-LD</strong> interactions, the core <strong>NGSI-LD</strong> <code>@context</code> (<a href=\"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld\"><code>https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld</code></a> is implicitly included as well.)</p>\n<p>This means that the actual <code>@context</code> is:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-jsonld\">{\n    \"@context\": [\n        \"http://context-provider:3000/data-models/ngsi-context.jsonld\",\n        \"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld\"\n    ]\n}\n</code></pre>\n<p>with the core <code>@context</code> being processed <strong>last</strong> and therefore overriding any terms previously defined with the same <code>@id</code>.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"95499812-dd17-48c5-a894-0bab4f5ecb11"},{"name":"Creating your Second Data Entity","id":"f944331c-0986-4010-a827-b372e6916d85","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"Link","type":"text","value":"<http://context/ngsi-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""}],"body":{"mode":"raw","raw":"{\n    \"id\": \"urn:ngsi-ld:Building:barn002\",\n    \"type\": \"Building\",\n    \"category\": {\n    \t\"type\": \"Property\",\n        \"value\": [\"barn\"]\n    },\n    \"address\": {\n        \"type\": \"Property\",\n        \"value\": {\n            \"streetAddress\": \"Straße des 17. Juni\",\n            \"addressRegion\": \"Berlin\",\n            \"addressLocality\": \"Tiergarten\",\n            \"postalCode\": \"10557\"\n        },\n        \"verified\": {\n\t\t\t\"type\": \"Property\",\n\t\t\t\"value\": true\n\t\t}\n    },\n     \"location\": {\n        \"type\": \"GeoProperty\",\n        \"value\": {\n             \"type\": \"Point\",\n              \"coordinates\": [13.3698, 52.5163]\n        }\n    },\n    \"name\": {\n        \"type\": \"Property\",\n        \"value\": \"Big Red Barn\"\n    }\n}"},"url":"http://localhost:1026/ngsi-ld/v1/entities/","description":"<p>Each subsequent entity must have a unique <code>id</code> for the given <code>type</code>.</p>\n<p>In this second case the <code>Content-Type: application/json</code> so the <code>@context</code> is supplied in the associated <code>Link</code> header of the request and not in the payload body.</p>\n<h3 id=\"using-core-context---defining-ngsi-ld-entities\">Using core <code>@context</code> - defining NGSI-LD entities</h3>\n<p>The core <code>@context</code> supplies the vocabulary for creating <strong>NGSI-LD</strong> data entities. Attributes such as  <code>id</code> and <code>type</code> ( which should be familiar to anyone who has used NGSI v2) are mapped to the standard <strong>JSON-LD</strong> <code>@id</code> and <code>@type</code> <a href=\"https://w3c.github.io/json-ld-syntax/#syntax-tokens-and-keywords\">keywords</a>. The <code>type</code> should refer to an included data model, in this case <code>Building</code> is being used as a short name\nfor the included URN <code>https://uri.fiware.org/ns/data-models#Building</code>. Thereafter each <em>property</em> is defined as a JSON\nelement containing two attributes, a <code>type</code> and a <code>value</code>.</p>\n<p>The <code>type</code> of a <em>property</em> attribute must be one of the following:</p>\n<ul>\n<li><code>\"GeoProperty\"</code>: <code>\"http://uri.etsi.org/ngsi-ld/GeoProperty\"</code> for locations. Locations should be specified as\nLongitude-Latitude pairs in <a href=\"https://tools.ietf.org/html/rfc7946\">GeoJSON format</a>. The preferred name for the\nprimary location attribute is <code>location</code></li>\n<li><code>\"Property\"</code>: <code>\"http://uri.etsi.org/ngsi-ld/Property\"</code> - for everything else.</li>\n<li>For time-based values, <code>\"Property\"</code> shall be used as well, but the property value should be Date, Time or DateTime\nstrings encoded in the <a href=\"https://en.wikipedia.org/wiki/ISO_8601\">ISO 8601 format</a> - e.g. <code>YYYY-MM-DDThh:mm:ssZ</code></li>\n</ul>\n<blockquote>\n<p><strong>Note:</strong> that for simplicity, this data entity has no relationships defined. Relationships must be given the\n<code>type=Relationship</code>. Relationships will be discussed in a subsequent tutorial.</p>\n</blockquote>\n<h3 id=\"defining-properties-of-properties-within-the-ngsi-ld-entity-definition\">Defining Properties-of-Properties within the NGSI-LD entity definition</h3>\n<p><em>Properties-of-Properties</em> is the NGSI-LD equivalent of metadata (i.e. <em>\"data about data\"</em>), it is use to describe\nproperties of the attribute value itself like accuracy, provider, or the units to be used. Some built-in metadata\nattributes already exist and these names are reserved:</p>\n<ul>\n<li><code>createdAt</code> (type: DateTime): attribute creation date as an ISO 8601 string.</li>\n<li><code>modifiedAt</code> (type: DateTime): attribute modification date as an ISO 8601 string.</li>\n</ul>\n<p>Additionally <code>observedAt</code>, <code>datasetId</code> and <code>instanceId</code> may optionally be added in some cases, and <code>location</code>,\n<code>observationSpace</code> and <code>operationSpace</code> have special meaning for Geoproperties.</p>\n<p>In the examples given above, one element of metadata (i.e. a <em>property-of-a-property</em>) can be found within the <code>address</code>\nattribute. a <code>verified</code> flag indicates whether the address has been confirmed. The commonest <em>property-of-a-property</em> is\n<code>unitCode</code> which should be used to hold the UN/CEFACT\n<a href=\"http://wiki.goodrelations-vocabulary.org/Documentation/UN/CEFACT_Common_Codes\">Common Codes</a> for Units of Measurement.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"f944331c-0986-4010-a827-b372e6916d85"},{"name":"Obtain Entity Data by type and linked context","id":"b2af262b-31a1-431e-b60b-ad81ce388901","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Link","type":"text","value":"<http://context/ngsi-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""},{"key":"Accept","value":"application/ld+json","type":"text","name":"Accept"}],"url":"http://localhost:1026/ngsi-ld/v1/entities?type=Building&options=keyValues","description":"<p>When filtering by <code>type</code>, a <a href=\"https://www.w3.org/wiki/LinkHeader\"><code>Link</code> header</a> must be supplied to associate the short form <code>type=\"Building\"</code>\nwith the FQN <code>https://uri.fiware.org/ns/data-models/Building</code>.</p>\n<p>If a reference to the supplied data is supplied, it is possible to return short name data and limit responses to a\nspecific <code>type</code> of data. For example, the request below returns the data of all <code>Building</code> entities within the context\ndata. Use of the <code>type</code> parameter limits the response to <code>Building</code> entities only, use of the <code>options=keyValues</code> query\nparameter reduces the response down to standard JSON-LD.</p>\n<p>Because of the use of the <code>options=keyValues</code>, the response consists of JSON only without the attribute definitions\n<code>type=\"Property\"</code> or any <em>properties-of-properties</em> elements. You can see that <code>Link</code> header from the request has been\nused as the <code>@context</code> returned in the response.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities"],"host":["localhost:1026"],"query":[{"key":"type","value":"Building"},{"description":{"content":"<ul>\n<li><code>keyValues</code> option in order to get a more compact and brief representation, including just attribute values</li>\n<li><code>values</code> option combined with a list of attribute values  <code>attrs</code>  for an ordered list of attributes only</li>\n</ul>\n","type":"text/plain"},"key":"options","value":"keyValues"}],"variable":[]}},"response":[],"_postman_id":"b2af262b-31a1-431e-b60b-ad81ce388901"},{"name":"Obtain Entity Data by FNQ type","id":"e01b9a55-e577-4b6e-b8d8-2521d0f33f4e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Accept","value":"application/ld+json","type":"text"}],"url":"http://localhost:1026/ngsi-ld/v1/entities?type=https://uri.fiware.org/ns/dataModels%23Building","description":"<p>This example returns the data of all <code>Building</code> entities within the context data The <code>type</code> parameter is mandatory for\nNGSI-LD and is used to filter the response. The Accept HTTP header is needed to retrieve JSON-LD content in the response body.</p>\n<p>Since no explicit <code>@context</code> was sent in the request, the response returns the Core <code>@context</code> by default (<code>https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld</code>) and\nall attributes are expanded whenever possible.</p>\n<ul>\n<li><code>id</code>, <code>type</code>, <code>location</code> and <code>name</code>are defined in the core context and are not expanded.</li>\n<li><code>address</code> has been mapped to <code>http://schema.org/address</code></li>\n<li><code>category</code> has been mapped to <code>https://uri.fiware.org/ns/data-models#category</code></li>\n</ul>\n<p>Note that if an attribute has not been not associated to an FQN when the entity was created, the short name will\n<strong>always</strong> be displayed.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities"],"host":["localhost:1026"],"query":[{"key":"type","value":"https://uri.fiware.org/ns/dataModels%23Building"}],"variable":[]}},"response":[],"_postman_id":"e01b9a55-e577-4b6e-b8d8-2521d0f33f4e"},{"name":"Obtain Entity Data by id","id":"6e0f2c4f-b7e7-44ae-8188-0023ad935095","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Accept","value":"application/ld+json","type":"text"},{"key":"Link","value":"<http://context/ngsi-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\"","type":"text"}],"url":"http://localhost:1026/ngsi-ld/v1/entities/urn:ngsi-ld::pig002","description":"<p>This example returns the data of <code>urn:ngsi-ld:Building:farm001</code>. The NGSI-LD <code>@context</code> is supplied as a <a href=\"https://www.w3.org/wiki/LinkHeader\"><code>Link</code> header</a> to define the entities returned. The <code>ngsi-context.jsonld</code> <code>@context</code> file is just supplying short names for every attribute.</p>\n<p>The full link header syntax can be seen below:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-text\">Link: &lt;https://fiware.github.io/data-models/context.jsonld&gt;; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\n</code></pre>\n<p>The standard HTTP <code>Link</code> header allows metadata (in this case the <code>@context</code>) to be passed in without actually touching\nthe resource in question. In the case of NGSI-LD, the metadata is a file in <code>application/ld+json</code> format.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities","urn:ngsi-ld::pig002"],"host":["localhost:1026"],"query":[{"disabled":true,"description":{"content":"<p>Entity type, to avoid ambiguity in case there are several entities with the same entity id</p>\n","type":"text/plain"},"key":"type","value":"Store"},{"disabled":true,"description":{"content":"<p>Ordered list of attribute names to display</p>\n","type":"text/plain"},"key":"attrs","value":"name"}],"variable":[]}},"response":[],"_postman_id":"6e0f2c4f-b7e7-44ae-8188-0023ad935095"},{"name":"Filter context data by attribute value","id":"40e61360-a25c-47c4-bec2-d19d75c28199","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Link","type":"text","value":"<http://context/json-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""},{"key":"Accept","value":"application/ld+json","type":"text","name":"Accept"}],"url":"http://localhost:1026/ngsi-ld/v1/entities/?type=Building&q=name==\"Big Red Barn\"&options=keyValues","description":"<p>This example returns all <code>Building</code> entities with the <code>name</code> attribute <em>Big Red Barn</em>. Filtering can be done using\nthe <code>q</code> parameter - if a string has spaces in it, it can be URL encoded and held within double quote characters <code>\"</code> =\n<code>%22</code>. Since <code>options=keyValues</code> is sent, this will effect the structure of the payload and we will need to supply a different <code>@context</code> file - <code>json-context.jsonld</code></p>\n<p>The use of the <code>Link</code> header and the <code>options=keyValues</code> parameter reduces the response to short form key-values <strong>JSON-LD</strong></p>\n<p>This <strong>JSON-LD</strong> is no longer <strong>NGSI-LD</strong> (since the <code>type</code> and <code>value</code> elements have been removed) and the <code>@context</code> used reflects this. The <code>json-context.jsonld</code> file does not merely define the attribute names, it also includes additional <strong>JSON-LD</strong> information within it such as the following:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json-ld\">{\n    \"barn\": \"https://wiki.openstreetmap.org/wiki/Tag:building%3Dbarn\",\n    \"category\": {\n        \"@id\": \"https://uri.fiware.org/ns/data-models#category\",\n        \"@type\": \"@vocab\"\n    }\n}\n</code></pre>\n<p>This indicates the <code>category</code> in this <strong>JSON-LD</strong> response holds an enumerated value (<code>@vocab</code>) and that the value <code>barn</code> is defined by a full URL. This differs compared to the  <code>ngsi-context.jsonld</code> <code>@context</code> file where all we can say is that there is an attribute with the full URL <code>https://uri.fiware.org/ns/data-models#category</code>, because in a normalized <strong>NGSI-LD</strong> response the <code>category</code> attribute would hold a JSON object (with a <code>type</code> and <code>value</code>) not a string.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities",""],"host":["localhost:1026"],"query":[{"key":"type","value":"Building"},{"key":"q","value":"name==\"Big Red Barn\""},{"description":{"content":"<ul>\n<li><code>keyValues</code> option in order to get a more compact and brief representation, including just attribute values</li>\n<li><code>values</code> option combined with a list of attribute values  <code>attrs</code>  for an ordered list of attributes only</li>\n</ul>\n","type":"text/plain"},"key":"options","value":"keyValues"}],"variable":[]}},"response":[],"_postman_id":"40e61360-a25c-47c4-bec2-d19d75c28199"},{"name":"Using an alternative @context","id":"e754504c-bd22-4917-a405-16160452d7be","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Link","type":"text","value":"<http://context/alternate-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""},{"key":"Accept","name":"Accept","type":"text","value":"application/ld+json"}],"url":"http://localhost:1026/ngsi-ld/v1/entities/?type=Gebäude&q=name==\"Big Red Barn\"&options=keyValues","description":"<p>The simple <strong>NGSI-LD</strong> <code>@context</code> is merely a mechanism for mapping URNs. It is therefore possible to retrieve <em>the same data</em> using a different set of short names.</p>\n<p>The <code>alternate-context.jsonld</code> maps the names of various attributes to their equivalents in German. If it is supplied in the request a query can be made using alternate short names (e.g. <code>type=Building</code> becomes <code>type=Gebäude</code>)</p>\n<p>The response is returned in JSON-LD format with short form attribute names (<code>addresse</code>, <code>katagorie</code>) which correspond to the short names provided in the alternate context. Note that core context terms (<code>id</code>, <code>type</code> etc.) cannot be overridden directly but would require an additional <strong>JSON-LD</strong> expansion/compaction operation.</p>\n<p>It should also be noted that the sub-attributes of the <code>addrese</code> have also not been amended, since <code>address</code> = <code>addrese</code> =<code>http://schema.org/address</code> and this\ndefinition defines the sub-attributes.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities",""],"host":["localhost:1026"],"query":[{"key":"type","value":"Gebäude"},{"key":"q","value":"name==\"Big Red Barn\""},{"description":{"content":"<ul>\n<li><code>keyValues</code> option in order to get a more compact and brief representation, including just attribute values</li>\n<li><code>values</code> option combined with a list of attribute values  <code>attrs</code>  for an ordered list of attributes only</li>\n</ul>\n","type":"text/plain"},"key":"options","value":"keyValues"}],"variable":[]}},"response":[],"_postman_id":"e754504c-bd22-4917-a405-16160452d7be"},{"name":"Filter context data by attribute in an Array","id":"d5313cf2-c1fb-4ad0-9620-e55dc560b215","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Link","type":"text","value":"<http://context/ngsi-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""},{"key":"Accept","value":"application/ld+json","type":"text","name":"Accept"}],"url":"http://localhost:1026/ngsi-ld/v1/entities/?type=Building&q=category==\"barn\",\"farm_auxiliary\"&options=keyValues","description":"<p>Within the standard <code>Building</code> model, the <code>category</code> attribute refers to an array of strings. This example returns all\n<code>Building</code> entities with a <code>category</code> attribute which contains either <code>commercial</code> or <code>office</code> strings. Filtering can be\ndone using the <code>q</code> parameter, comma separating the acceptable values.</p>\n<p>The response is returned in JSON-LD format with short form attribute names.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities",""],"host":["localhost:1026"],"query":[{"key":"type","value":"Building"},{"key":"q","value":"category==\"barn\",\"farm_auxiliary\""},{"description":{"content":"<ul>\n<li><code>keyValues</code> option in order to get a more compact and brief representation, including just attribute values</li>\n<li><code>values</code> option combined with a list of attribute values  <code>attrs</code>  for an ordered list of attributes only</li>\n</ul>\n","type":"text/plain"},"key":"options","value":"keyValues"}],"variable":[]}},"response":[],"_postman_id":"d5313cf2-c1fb-4ad0-9620-e55dc560b215"},{"name":"Filter context data by sub-attribute value","id":"ad58f308-4ff3-4c58-9fcd-e8976cb82826","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Link","type":"text","value":"<http://context/json-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""},{"key":"Accept","value":"application/ld+json","type":"text"}],"url":"http://localhost:1026/ngsi-ld/v1/entities/?type=Building&q=address%5BaddressLocality%5D==\"Tiergarten\"&options=keyValues","description":"<p>This example returns all stores found in the Tiergarten District.</p>\n<p>Filtering can be done using the <code>q</code> parameter - sub-attributes are annotated using the bracket syntax e.g.\n<code>q=address[addressLocality]==\"Tiergarten\"</code>.</p>\n<p>Use of the <code>Link</code> header and the <code>options=keyValues</code> parameter reduces the response to JSON-LD.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities",""],"host":["localhost:1026"],"query":[{"key":"type","value":"Building"},{"key":"q","value":"address%5BaddressLocality%5D==\"Tiergarten\""},{"description":{"content":"<ul>\n<li><code>keyValues</code> option in order to get a more compact and brief representation, including just attribute values</li>\n<li><code>values</code> option combined with a list of attribute values  <code>attrs</code>  for an ordered list of attributes only</li>\n</ul>\n","type":"text/plain"},"key":"options","value":"keyValues"}],"variable":[]}},"response":[],"_postman_id":"ad58f308-4ff3-4c58-9fcd-e8976cb82826"},{"name":"Filter context data by metadata value","id":"1a2110ac-916c-463c-b325-6cd312f55c1b","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Link","type":"text","value":"<http://context/json-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""},{"key":"Accept","value":"application/json","type":"text"}],"url":"http://localhost:1026/ngsi-ld/v1/entities/?type=Building&q=address.verified==true&options=keyValues","description":"<p>This example returns the data of all <code>Building</code> entities with a verified address. The <code>verified</code> attribute is an example\nof a <em>Property-of-a-Property</em></p>\n<p>Metadata queries (i.e. Properties of Properties) are annotated using the dot syntax e.g. <code>q=address.verified==true</code>.</p>\n<p>Because of the use of the <code>options=keyValues</code> together with the Accept HTTP header (<code>application/json</code>), the response\nconsists of JSON only without the attribute <code>type</code> and <code>metadata</code> elements.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities",""],"host":["localhost:1026"],"query":[{"key":"type","value":"Building"},{"key":"q","value":"address.verified==true"},{"description":{"content":"<ul>\n<li><code>keyValues</code> option in order to get a more compact and brief representation, including just attribute values</li>\n<li><code>values</code> option combined with a list of attribute values  <code>attrs</code>  for an ordered list of attributes only</li>\n</ul>\n","type":"text/plain"},"key":"options","value":"keyValues"}],"variable":[]}},"response":[],"_postman_id":"1a2110ac-916c-463c-b325-6cd312f55c1b"},{"name":"Filter context data by distance","id":"6943ebaf-ddf1-4412-abcd-af6197cd8e87","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Link","type":"text","value":"<http://context/json-context.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\""},{"key":"Accept","type":"text","value":"application/json"}],"url":"http://localhost:1026/ngsi-ld/v1/entities/?type=Building&geometry=Point&coordinates=%5B13.3777,52.5162%5D&georel=near%3BmaxDistance==800&options=keyValues","description":"<p>This example return all buildings within 800m the <strong>Brandenburg Gate</strong> in <strong>Berlin</strong> (<em>52.5162N 13.3777W</em>). To make a\ngeo-query request, three parameters must be specified, <code>geometry</code>, <code>coordinates</code> and <code>georel</code>.</p>\n<p>The <code>coordinates</code> parameter is  represented in\n<a href=\"https://tools.ietf.org/html/rfc7946\">geoJSON</a> including the square brackets.</p>\n<p>Note that by default the geo-query will be applied to the <code>location</code> attribute, as this is default specified in NGSI-LD.\nIf another attribute is to be used, an additional <code>geoproperty</code> parameter is required.</p>\n<p>Because of the use of the <code>options=keyValues</code> together with the Accept HTTP header (<code>application/json</code>), the response\nconsists of JSON only without the attribute <code>type</code> and <code>metadata</code> elements.</p>\n","urlObject":{"protocol":"http","path":["ngsi-ld","v1","entities",""],"host":["localhost:1026"],"query":[{"key":"type","value":"Building"},{"key":"geometry","value":"Point"},{"key":"coordinates","value":"%5B13.3777,52.5162%5D"},{"description":{"content":"<p>Ordered list of attribute names to display</p>\n","type":"text/plain"},"key":"georel","value":"near%3BmaxDistance==800"},{"key":"options","value":"keyValues"}],"variable":[]}},"response":[],"_postman_id":"6943ebaf-ddf1-4412-abcd-af6197cd8e87"}],"event":[{"listen":"prerequest","script":{"id":"3f85b567-512e-461f-81ce-4fa7aceb9c21","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"3b5ad0d2-9d3f-48b8-b8b6-324544a0a0e1","type":"text/javascript","exec":[""]}}],"variable":[{"key":"json-context.jsonld","value":"http://context/json-context.jsonld"},{"key":"ngsi-context.jsonld","value":"http://context/ngsi-context.jsonld"},{"key":"context-broker","value":"localhost:1026"},{"key":"alternate-context.jsonld","value":"http://context/alternate-context.jsonld"}]}