{"info":{"_postman_id":"20842d0b-0e06-4d56-8229-56138ff4f45f","name":"FIWARE Getting Started","description":"<html><head></head><body><p>Let’s start with the data from a supermarket chain’s store finder and create a very simple <em>“Powered by FIWARE”</em> application by passing in the address and location of each store as context data to the FIWARE context broker.</p>\n<p>The <code>docker-compose</code> file for this tutorial can be found on GitHub:</p>\n<img src=\"https://fiware.github.io/tutorials.Getting-Started/icon/GitHub-Mark-32px.png\" alt=\"GitHub\">\n\n<p><a href=\"https://github.com/Fiware/tutorials.Getting-Started\">FIWARE 101: An Introduction to the FIWARE Platform</a></p>\n<h1 id=\"architecture\">Architecture</h1>\n<p>Our demo application will only make use of one FIWARE component - the <a href=\"https://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-broker\">Orion Context Broker</a> . Usage of the Orion Context Broker is sufficient for an application to qualify as <em>“Powered by FIWARE”</em>.</p>\n<p>Currently, the Orion Context Broker relies on open source <a href=\"https://www.mongodb.com/\">MongoDB</a> technology to keep persistence of the context data it holds. Therefore, the architecture will consist of two elements:</p>\n<ul>\n<li><p>The Orion Context Broker server which will receive requests using NGSI</p>\n</li>\n<li><p>The underlying MongoDB database associated to the Orion Context Broker server</p>\n</li>\n</ul>\n<p>Since all interactions between the two elements are initiated by HTTP requests, the entities can be containerized and run from exposed ports.</p>\n<img src=\"https://fiware.github.io/tutorials.Getting-Started/img//architecture.png\">\n\n<h1 id=\"prerequisites\">Prerequisites</h1>\n<h2 id=\"docker\">Docker</h2>\n<p>To keep things simple both components will be run using <a href=\"https://www.docker.com\">Docker</a>. <strong>Docker</strong> is a container technology which allows to different components isolated into their respective environments.</p>\n<ul>\n<li><p>To install Docker on Windows follow the instructions <a href=\"https://docs.docker.com/docker-for-windows/\">here</a></p>\n</li>\n<li><p>To install Docker on Mac follow the instructions <a href=\"https://docs.docker.com/docker-for-mac/\">here</a></p>\n</li>\n<li><p>To install Docker on Linux follow the instructions <a href=\"https://docs.docker.com/install/\">here</a></p>\n</li>\n</ul>\n<h1 id=\"starting-the-containers\">Starting the Containers</h1>\n<h2 id=\"initialization\">Initialization</h2>\n<p>First pull the necessary Docker images from Docker Hub and create a network for our containers to connect to:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker pull mongo:3.6\ndocker pull fiware/orion\ndocker network create fiware_default\n\n</code></pre>\n<h2 id=\"start-up\">Start Up</h2>\n<p>A Docker container running a MongoDB database can be started and connected to the network with the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker run -d --name=context-db --network=fiware_default \\\n  --expose=27017 mongo:3.6 --bind_ip_all --smallfiles\n\n</code></pre>\n<p>The Orion Context Broker can be started and connected to the network with the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker run -d --name orion  --network=fiware_default \\\n  -p 1026:1026  fiware/orion -dbhost context-db\n\n</code></pre>\n<p>You can check if the Orion Context Broker is running by making an HTTP request to the exposed port:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">curl -X GET http://localhost:1026/version\n\n</code></pre>\n<p>Alternatively run all your curl commands from within the container network:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker run --network fiware_default --rm appropriate/curl -s \\\n  -X GET http://orion:1026/version\n\n</code></pre>\n<p><strong>What if I get an error response?</strong></p>\n<p>If you get an error response, the Orion Content Broker cannot be found where expected<br>for this tutorial - you will need to substitute the URL and port in each Postman request<br>with the corrected ip address. All the Postman requests in this tutorial assume<br>that orion is available on <code>localhost:1026</code>.</p>\n<p>Try the following remedies:</p>\n<ul>\n<li>To check that the dockers container are running try the following:</li>\n</ul>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker ps\n\n</code></pre>\n<p>You should see two containers running. If orion is not running, you can restart the<br>containers as necessary. This command will also display open port information.</p>\n<ul>\n<li>If you have installed <a href=\"https://docs.docker.com/machine/\"><code>docker-machine</code></a> and <a href=\"https://www.virtualbox.org/\">Virtual Box</a>, you will need to retrieve the virtual host ip as shown:</li>\n</ul>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">curl -X GET http://$(docker-machine ip default):1026/version\n\n</code></pre>\n<p>If you need to update the location of orion:</p>\n<ol>\n<li><p>Click on the elipsis <code>...</code> at the head of the imported postman collection</p>\n</li>\n<li><p>Select <code>edit</code> from the dropdown</p>\n</li>\n<li><p>Click on the <code>variables</code> tab and alter the value from <code>localhost:1026</code> as necessary.</p>\n</li>\n</ol>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Architecture","slug":"architecture"},{"content":"Prerequisites","slug":"prerequisites"},{"content":"Starting the Containers","slug":"starting-the-containers"}],"owner":"513743","collectionId":"20842d0b-0e06-4d56-8229-56138ff4f45f","publishedId":"SWLcdUXj","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2020-01-06T10:05:09.000Z"},"item":[{"name":"Obtaining Version Information","id":"64444fc0-67ea-4198-9b9d-630f8540cf40","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/version/","description":"<p>Once the Orion Context Broker is running, You can check the status by making an HTTP request to the exposed port. \nIf the response is blank, this is usually because the MongoDB database holding the context information is not running or not connected.</p>\n<blockquote>\n<p><strong>Troubleshooting:</strong> What if the response is blank ?</p>\n<ul>\n<li>To check that a docker container is running try</li>\n</ul>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-bash\">docker ps\n</code></pre>\n<p>You should see two containers running. If orion is not running, you can restart the containers as necessary.</p>\n</blockquote>\n","urlObject":{"protocol":"http","path":["version",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"64444fc0-67ea-4198-9b9d-630f8540cf40"},{"name":"Creating your first Data Entity","id":"e359340f-8f8a-418b-aa37-2eda047a2386","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"id\": \"urn:ngsi-ld:Store:001\",\n    \"type\": \"Store\",\n    \"address\": {\n        \"type\": \"PostalAddress\",\n        \"value\": {\n            \"streetAddress\": \"Bornholmer Straße 65\",\n            \"addressRegion\": \"Berlin\",\n            \"addressLocality\": \"Prenzlauer Berg\",\n            \"postalCode\": \"10439\"\n        },\n        \"metadata\": {\n    \t\t\"verified\": {\n        \t\t\"value\": true,\n        \t\t\"type\": \"Boolean\"\n    \t\t}\n    \t}\n    },\n    \"location\": {\n        \"type\": \"geo:json\",\n        \"value\": {\n             \"type\": \"Point\",\n             \"coordinates\": [13.3986, 52.5547]\n        }\n    },\n    \"name\": {\n        \"type\": \"Text\",\n        \"value\": \"Bösebrücke Einkauf\"\n    }\n}"},"url":"http://localhost:1026/v2/entities/","description":"<h2 id=\"creating-context-data\">Creating Context Data</h2>\n<p>At its heart, FIWARE is a system for managing context information, so lets add some context data into the system by creating a  new entity (a store in <strong>Berlin</strong>). Any entity must have a <code>id</code> and <code>type</code> attributes, additional attributes are optional and will depend on the system being described. Each additional attribute should also have a defined <code>type</code> and a <code>value</code> attribute.</p>\n","urlObject":{"protocol":"http","path":["v2","entities",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"e359340f-8f8a-418b-aa37-2eda047a2386"},{"name":"Creating your Second Data Entity","id":"989851ff-f538-4e64-8a27-65a118a8815f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n  \"type\": \"Store\",\n    \"id\": \"urn:ngsi-ld:Store:002\",\n    \"address\": {\n        \"type\": \"PostalAddress\",\n        \"value\": {\n            \"streetAddress\": \"Friedrichstraße 44\",\n            \"addressRegion\": \"Berlin\",\n            \"addressLocality\": \"Kreuzberg\",\n            \"postalCode\": \"10969\"\n        },\n        \"metadata\": {\n    \t\t\"verified\": {\n        \t\t\"value\": true,\n        \t\t\"type\": \"Boolean\"\n    \t\t}\n    \t}\n    },\n    \"location\": {\n        \"type\": \"geo:json\",\n        \"value\": {\n             \"type\": \"Point\",\n             \"coordinates\": [13.3903, 52.5075]\n        }\n    },\n    \"name\": {\n        \"type\": \"Text\",\n        \"value\": \"Checkpoint Markt\"\n    }\n}"},"url":"http://localhost:1026/v2/entities/","urlObject":{"protocol":"http","path":["v2","entities",""],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"989851ff-f538-4e64-8a27-65a118a8815f"},{"name":"Retrieving Context Information","id":"5c9949d8-9306-4ac0-9507-9dc6c122418b","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/v2/entities","description":"<p>This example returns the full data context</p>\n","urlObject":{"protocol":"http","path":["v2","entities"],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"5c9949d8-9306-4ac0-9507-9dc6c122418b"},{"name":"Obtain Entity Data by id","id":"75bb0012-88ec-4edd-8559-f19c77ad2bb4","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001?options=keyValues","description":"<p>This example returns the context data of <code>store1</code>. The <code>id</code> of the entity should be unique or the <code>type</code> parameter should also be used.</p>\n<p>Because of the use of the <code>options=keyValues</code>, the response consists of JSON only without the attribute <code>type</code> elements.</p>\n","urlObject":{"protocol":"http","path":["v2","entities","urn:ngsi-ld:Store:001"],"host":["localhost:1026"],"query":[{"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"},{"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":"75bb0012-88ec-4edd-8559-f19c77ad2bb4"},{"name":"Obtain Entity Data by type","id":"d5c28b0c-224a-4a61-a74c-e233b112c644","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/v2/entities/?type=Store&options=keyValues","description":"<p>This example returns the data of all <code>Store</code> entities within the context data. </p>\n<p>The <code>type</code> parameter limits the response to store entities only.\nBecause of the use of the <code>options=keyValues</code>, the response consists of JSON only without the attribute <code>type</code> elements.</p>\n","urlObject":{"protocol":"http","path":["v2","entities",""],"host":["localhost:1026"],"query":[{"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"},{"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"},{"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":"d5c28b0c-224a-4a61-a74c-e233b112c644"},{"name":"Filter context data by attribute value","id":"fcbde4dd-b8fa-42b7-bacf-158e7d6ecb1d","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/v2/entities/?q=name=='Checkpoint Markt'&type=Store&options=keyValues","description":"<h2 id=\"filter-context-data-by-comparing-the-values-of-an-attribute\">Filter context data by comparing the values of an attribute</h2>\n<p>This example returns the data of all <code>Store</code> entities found with the name <em>Checkpoint Markt</em>. </p>\n<p>Filtering can be done using the <code>q</code> parameter - if a string has spaces in it, it can be URL encoded and held within single quote characters <code>'</code> = <code>%27</code></p>\n<p>Because of the use of the <code>options=keyValues</code>, the response consists of JSON only without the attribute <code>type</code> and <code>metadata</code> elements.</p>\n","urlObject":{"protocol":"http","path":["v2","entities",""],"host":["localhost:1026"],"query":[{"key":"q","value":"name=='Checkpoint Markt'"},{"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"},{"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"},{"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":"fcbde4dd-b8fa-42b7-bacf-158e7d6ecb1d"},{"name":"Filter context data by sub-attribute value","id":"2c5d1c0a-9d26-4422-8d07-8cf7ab5fa309","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/v2/entities/?q=address.addressLocality=='Kreuzberg'&type=Store&options=keyValues","description":"<h2 id=\"filter-context-data-by-comparing-the-values-of-an-attribute\">Filter context data by comparing the values of an attribute</h2>\n<p>This example returns the data of all <code>Store</code> entities found in the <strong>Kreuzberg</strong> district of Berlin.</p>\n<p>Filtering can be done using the <code>q</code> parameter - sub-attributes are annotated using the dot syntax e.g. <code>address.addressLocality</code></p>\n<p>Because of the use of the <code>options=keyValues</code>, the response consists of JSON only without the attribute <code>type</code> and <code>metadata</code> elements.</p>\n","urlObject":{"protocol":"http","path":["v2","entities",""],"host":["localhost:1026"],"query":[{"key":"q","value":"address.addressLocality=='Kreuzberg'"},{"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"},{"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":"2c5d1c0a-9d26-4422-8d07-8cf7ab5fa309"},{"name":"Filter context data by querying metadata","id":"3f9d8e7d-82fe-49ae-8825-d516b9c686fb","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/v2/entities/?mq=address.verified==true&type=Store&options=keyValues","description":"<h2 id=\"filter-context-data-by-comparing-the-values-of-an-metadata-attribute\">Filter context data by comparing the values of an metadata attribute</h2>\n<p>This example returns the data of all <code>Store</code> entities with a verified address.</p>\n<p>Metadata queries can be made using the <code>mq</code> parameter.</p>\n","urlObject":{"protocol":"http","path":["v2","entities",""],"host":["localhost:1026"],"query":[{"key":"mq","value":"address.verified==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"},{"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":"3f9d8e7d-82fe-49ae-8825-d516b9c686fb"},{"name":"Filter context data by distance","id":"8e8dee67-577a-4a86-9e31-68c920adf9ba","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:1026/v2/entities/?georel=near;maxDistance:1500&geometry=point&coords=52.5162,13.3777&type=Store&options=keyValues","description":"<h2 id=\"filter-context-data-by-comparing-the-values-of-a-geopoint-attribute\">Filter context data by comparing the values of a geo:point attribute</h2>\n<p>This example returns the data of all <code>Store</code> entities found within 1.5km the <strong>Brandenburg Gate</strong>  in <strong>Berlin</strong> (<em>52.5162N 13.3777W</em>)</p>\n","urlObject":{"protocol":"http","path":["v2","entities",""],"host":["localhost:1026"],"query":[{"key":"georel","value":"near;maxDistance:1500"},{"key":"geometry","value":"point"},{"key":"coords","value":"52.5162,13.3777"},{"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"},{"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"},{"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":"8e8dee67-577a-4a86-9e31-68c920adf9ba"}],"event":[{"listen":"prerequest","script":{"id":"29de01fb-29bc-418f-96df-f6b5f1ce1236","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"04e10871-c7b3-450d-b3d1-89d8fec68108","type":"text/javascript","exec":[""]}}],"variable":[{"key":"orion","value":"localhost:1026","type":"string"}]}