{"info":{"_postman_id":"20842d0b-0e06-4d56-8229-56138ff4f45f","name":"FIWARE Getting Started","description":"Let’s start with the data from a supermarket chain’s store finder and create a very simple _“Powered by FIWARE”_ application by passing in the address and location of each store as context data to the FIWARE context broker.\n\nThe `docker-compose` file for this tutorial can be found on GitHub:\n\n<img src=\"https://fiware.github.io/tutorials.Getting-Started/icon/GitHub-Mark-32px.png\" alt=\"GitHub\">\n\n[FIWARE 101: An Introduction to the FIWARE Platform](https://github.com/Fiware/tutorials.Getting-Started)\n\n# Architecture\n\nOur demo application will only make use of one FIWARE component - the [Orion Context Broker](https://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-broker) . Usage of the Orion Context Broker is sufficient for an application to qualify as _“Powered by FIWARE”_.\n\nCurrently, the Orion Context Broker relies on open source [MongoDB](https://www.mongodb.com/) technology to keep persistence of the context data it holds. Therefore, the architecture will consist of two elements:\n\n- The Orion Context Broker server which will receive requests using NGSI\n    \n- The underlying MongoDB database associated to the Orion Context Broker server\n    \n\nSince all interactions between the two elements are initiated by HTTP requests, the entities can be containerized and run from exposed ports.\n\n<img src=\"https://fiware.github.io/tutorials.Getting-Started/img//architecture.png\">\n\n# Prerequisites\n\n## Docker\n\nTo keep things simple both components will be run using [Docker](https://www.docker.com). **Docker** is a container technology which allows to different components isolated into their respective environments.\n\n- To install Docker on Windows follow the instructions [here](https://docs.docker.com/docker-for-windows/)\n    \n- To install Docker on Mac follow the instructions [here](https://docs.docker.com/docker-for-mac/)\n    \n- To install Docker on Linux follow the instructions [here](https://docs.docker.com/install/)\n    \n\n# Starting the Containers\n\n## Initialization\n\nFirst pull the necessary Docker images from Docker Hub and create a network for our containers to connect to:\n\n``` console\ndocker pull mongo:3.6\ndocker pull fiware/orion\ndocker network create fiware_default\n\n ```\n\n## Start Up\n\nA Docker container running a MongoDB database can be started and connected to the network with the following command:\n\n``` console\ndocker run -d --name=context-db --network=fiware_default \\\n  --expose=27017 mongo:3.6 --bind_ip_all --smallfiles\n\n ```\n\nThe Orion Context Broker can be started and connected to the network with the following command:\n\n``` console\ndocker run -d --name orion  --network=fiware_default \\\n  -p 1026:1026  fiware/orion -dbhost context-db\n\n ```\n\nYou can check if the Orion Context Broker is running by making an HTTP request to the exposed port:\n\n``` console\ncurl -X GET http://localhost:1026/version\n\n ```\n\nAlternatively run all your curl commands from within the container network:\n\n``` console\ndocker run --network fiware_default --rm appropriate/curl -s \\\n  -X GET http://orion:1026/version\n\n ```\n\n**What if I get an error response?**\n\nIf you get an error response, the Orion Content Broker cannot be found where expected  \nfor this tutorial - you will need to substitute the URL and port in each Postman request  \nwith the corrected ip address. All the Postman requests in this tutorial assume  \nthat orion is available on `localhost:1026`.\n\nTry the following remedies:\n\n- To check that the dockers container are running try the following:\n    \n\n``` console\ndocker ps\n\n ```\n\nYou should see two containers running. If orion is not running, you can restart the  \ncontainers as necessary. This command will also display open port information.\n\n- If you have installed [<code>docker-machine</code>](https://docs.docker.com/machine/) and [Virtual Box](https://www.virtualbox.org/), you will need to retrieve the virtual host ip as shown:\n    \n\n``` console\ncurl -X GET http://$(docker-machine ip default):1026/version\n\n ```\n\nIf you need to update the location of orion:\n\n1. Click on the elipsis `...` at the head of the imported postman collection\n    \n2. Select `edit` from the dropdown\n    \n3. Click on the `variables` tab and alter the value from `localhost:1026` as necessary.","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json"},"item":[{"name":"Obtaining Version Information","id":"64444fc0-67ea-4198-9b9d-630f8540cf40","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://{{orion}}/version/","description":"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.\n\n>**Troubleshooting:** What if the response is blank ?\n>\n> * To check that a docker container is running try\n>\n>```bash\n>docker ps\n>```\n>\n>You should see two containers running. If orion is not running, you can restart the containers as necessary."},"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://{{orion}}/v2/entities/","description":"## Creating Context Data\n\nAt 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 **Berlin**). Any entity must have a `id` and `type` attributes, additional attributes are optional and will depend on the system being described. Each additional attribute should also have a defined `type` and a `value` attribute."},"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://{{orion}}/v2/entities/"},"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://{{orion}}/v2/entities","description":"This example returns the full data context"},"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":{"raw":"http://{{orion}}/v2/entities/urn:ngsi-ld:Store:001?options=keyValues","protocol":"http","host":["{{orion}}"],"path":["v2","entities","urn:ngsi-ld:Store:001"],"query":[{"key":"options","value":"keyValues","description":"* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values  `attrs`  for an ordered list of attributes only"},{"key":"type","value":"Store","description":"Entity type, to avoid ambiguity in case there are several entities with the same entity id","disabled":true},{"key":"attrs","value":"name","description":"Ordered list of attribute names to display","disabled":true}]},"description":"This example returns the context data of `store1`. The `id` of the entity should be unique or the `type` parameter should also be used.\n\nBecause of the use of the `options=keyValues`, the response consists of JSON only without the attribute `type` elements."},"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":{"raw":"http://{{orion}}/v2/entities/?type=Store&options=keyValues","protocol":"http","host":["{{orion}}"],"path":["v2","entities",""],"query":[{"key":"type","value":"Store","description":"Entity type, to avoid ambiguity in case there are several entities with the same entity id"},{"key":"options","value":"keyValues","description":"* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values  `attrs`  for an ordered list of attributes only"},{"key":"attrs","value":"name","description":"Ordered list of attribute names to display","disabled":true}]},"description":"This example returns the data of all `Store` entities within the context data. \n\nThe `type` parameter limits the response to store entities only.\nBecause of the use of the `options=keyValues`, the response consists of JSON only without the attribute `type` elements."},"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":{"raw":"http://{{orion}}/v2/entities/?q=name=='Checkpoint Markt'&type=Store&options=keyValues","protocol":"http","host":["{{orion}}"],"path":["v2","entities",""],"query":[{"key":"q","value":"name=='Checkpoint Markt'"},{"key":"type","value":"Store","description":"Entity type, to avoid ambiguity in case there are several entities with the same entity id"},{"key":"options","value":"keyValues","description":"* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values  `attrs`  for an ordered list of attributes only"},{"key":"attrs","value":"name","description":"Ordered list of attribute names to display","disabled":true}]},"description":"## Filter context data by comparing the values of an attribute\n\nThis example returns the data of all `Store` entities found with the name *Checkpoint Markt*. \n\nFiltering can be done using the `q` parameter - if a string has spaces in it, it can be URL encoded and held within single quote characters `'` = `%27`\n\nBecause of the use of the `options=keyValues`, the response consists of JSON only without the attribute `type` and `metadata` elements."},"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":{"raw":"http://{{orion}}/v2/entities/?q=address.addressLocality=='Kreuzberg'&type=Store&options=keyValues","protocol":"http","host":["{{orion}}"],"path":["v2","entities",""],"query":[{"key":"q","value":"address.addressLocality=='Kreuzberg'"},{"key":"type","value":"Store","description":"Entity type, to avoid ambiguity in case there are several entities with the same entity id"},{"key":"options","value":"keyValues","description":"* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values  `attrs`  for an ordered list of attributes only"}]},"description":"## Filter context data by comparing the values of an attribute\n\nThis example returns the data of all `Store` entities found in the **Kreuzberg** district of Berlin.\n\nFiltering can be done using the `q` parameter - sub-attributes are annotated using the dot syntax e.g. `address.addressLocality`\n\nBecause of the use of the `options=keyValues`, the response consists of JSON only without the attribute `type` and `metadata` elements."},"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":{"raw":"http://{{orion}}/v2/entities/?mq=address.verified==true&type=Store&options=keyValues","protocol":"http","host":["{{orion}}"],"path":["v2","entities",""],"query":[{"key":"mq","value":"address.verified==true"},{"key":"type","value":"Store","description":"Entity type, to avoid ambiguity in case there are several entities with the same entity id"},{"key":"options","value":"keyValues","description":"* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values  `attrs`  for an ordered list of attributes only"}]},"description":"## Filter context data by comparing the values of an metadata attribute\n\nThis example returns the data of all `Store` entities with a verified address.\n\nMetadata queries can be made using the `mq` parameter."},"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":{"raw":"http://{{orion}}/v2/entities/?georel=near;maxDistance:1500&geometry=point&coords=52.5162,13.3777&type=Store&options=keyValues","protocol":"http","host":["{{orion}}"],"path":["v2","entities",""],"query":[{"key":"georel","value":"near;maxDistance:1500"},{"key":"geometry","value":"point"},{"key":"coords","value":"52.5162,13.3777"},{"key":"type","value":"Store","description":"Entity type, to avoid ambiguity in case there are several entities with the same entity id"},{"key":"options","value":"keyValues","description":"* `keyValues` option in order to get a more compact and brief representation, including just attribute values\n* `values` option combined with a list of attribute values  `attrs`  for an ordered list of attributes only"},{"key":"attrs","value":"name","description":"Ordered list of attribute names to display","disabled":true}]},"description":"## Filter context data by comparing the values of a geo:point attribute\n\nThis example returns the data of all `Store` entities found within 1.5km the **Brandenburg Gate**  in **Berlin** (*52.5162N 13.3777W*)"},"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"}]}