{"id":758,"date":"2023-09-07T11:09:59","date_gmt":"2023-09-07T10:09:59","guid":{"rendered":"https:\/\/www.mycelium.es\/api-guia-rapida\/"},"modified":"2023-11-13T09:44:37","modified_gmt":"2023-11-13T08:44:37","slug":"api-quickstart","status":"publish","type":"page","link":"https:\/\/www.mycelium.es\/en\/api-quickstart\/","title":{"rendered":"API &#8211; Quickstart"},"content":{"rendered":"<section class=\"wpb-content-wrapper\"><p>[vc_section full_width=&#8221;stretch_row_content&#8221; el_id=&#8221;guia-rapida&#8221;][vc_row][vc_column][vc_tta_tour controls_size=&#8221;md&#8221; active_section=&#8221;1&#8243; no_fill_content_area=&#8221;true&#8221; el_class=&#8221;tour-guia-rapida&#8221;][vc_tta_section title=&#8221;Overview&#8221; tab_id=&#8221;overview&#8221;][vc_column_text]<\/p>\n<h1>API \u2013 Quickstart<\/h1>\n<div>\n<p>Get started quickly with and overview of the components involved in a typical solutions and practical examples on how to connect a device and how to integrate an external system to the SDS Platform.<\/p>\n<\/div>\n<p>[\/vc_column_text][vc_column_text]<\/p>\n<h3 class=\"level1\">OVERVIEW<\/h3>\n<div>\n<div class=\"wpb_text_column wpb_content_element \">\n<div class=\"wpb_wrapper\">\n<p>Before starting your project, you need to have a clear understanding of the components involved in your solution. The following questions will help you clarify what you may need.<\/p>\n<\/div>\n<\/div>\n<div class=\"standard-number-list list-divider bullet-top\">\n<ol>\n<li><strong>Devices<\/strong><br \/>\nFrom where are you trying to retrieve information or what device will you send instructions to? Common examples are utilities meters, temperature sensors, doors lock\/unlock mechanisms, etc.<\/li>\n<li><strong>Connectivity<\/strong><br \/>\nDoes the device already has connectivity and allows to configure parameters to be sent, or do you need to provide connectivity through a gateway?<\/li>\n<li><strong>SDS Platform<\/strong><br \/>\nWill you use the platform as the user interface to provide your solution or will you create or use and external system<\/li>\n<li><strong>External System<\/strong><br \/>\nWill you develop your own external application or are you integrating a 3rd party system?<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p>[\/vc_column_text][\/vc_tta_section][vc_tta_section title=&#8221;Connect a Device&#8221; tab_id=&#8221;connect-a-device&#8221;][vc_empty_space][vc_column_text]<\/p>\n<h3 class=\"level1\">CONNECT A DEVICE<\/h3>\n<div>\n<p>In this example we will send a reading from a device to the platform through the Devices API. PHP has been used as scripting language, but you can select the language of your choice.<\/p>\n<\/div>\n<p>[\/vc_column_text][vc_column_text]<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/*\r\n\r\nThis example sends a numerical measurement (10.5) from sensor\r\n\r\nSENSOR001, owned by provider PROVIDER001, identified by token:\r\n\r\n79d2dfe9ea9af9dd015befebda62180673314c8abb8898d626c66959448cae0d\r\n\r\nAnd then prints the platform server reply.\r\n\r\n*\/\r\n\r\n$providername = \u2018PROVIDER001\u2019;\r\n\r\n$sensorname = \u2018SENSOR001\u2019;\r\n\r\n$token = \u201979d2dfe9ea9af9dd015befebda62180673314c8abb8898d626c66959448cae0d\u2019;\r\n\r\n$value = \u201810.5\u2019;\r\n\r\n$json = \u2018{\u00abobservations\u00bb:&#x5B;{\u00abvalue\u00bb:\u00bb\u2018.$value.\u2018\u00bb}]}\u2019;\r\n\r\n$api_request_url = \u2018&#x5B;DEVICES API URL]\/data\/\u2019.$providername.\u2018\/\u2019.$sensorname;\r\n\r\n$ch = curl_init();\r\n\r\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);\r\n\r\ncurl_setopt($ch, CURLOPT_HEADER, TRUE);\r\n\r\ncurl_setopt($ch, CURLOPT_CUSTOMREQUEST, \u2018PUT\u2019);\r\n\r\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $json);\r\n\r\ncurl_setopt($ch, CURLOPT_HTTPHEADER, array(\u2018IDENTITY_KEY: \u2018.$token,\u2018Content-Type: application\/json\u2019));\r\n\r\ncurl_setopt($ch, CURLOPT_URL, $api_request_url);\r\n\r\n$api_response = curl_exec($ch);\r\n\r\n$api_response_info = curl_getinfo($ch);\r\n\r\ncurl_close($ch);\r\n\r\n$api_response_header = trim(substr($api_response, 0, $api_response_info&#x5B;\u2018header_size\u2019]));\r\n\r\necho $api_response_header;\r\n\r\n<\/pre>\n<p>[\/vc_column_text][\/vc_tta_section][vc_tta_section title=&#8221;Integrate an Application&#8221; tab_id=&#8221;integrate-ann-application&#8221;][vc_empty_space][vc_column_text]<\/p>\n<h3 class=\"level1\">INTEGRATE AN APPLICATION<\/h3>\n<div>\n<p>Let\u2019s read some data from the temperature sensor we have just connected (see \u201cConnect Device\u201d) through the Applications API, and insert into an external database.<\/p>\n<\/div>\n<p>[\/vc_column_text][vc_column_text]<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/*\r\n\r\nThis example gets the list of raw measurements sent by a temperature sensor, which ID is 5123, from 2016-10-10 00:00:00 UTC to 2016-10-11 00:00:00 UTC.\r\n\r\nThe user who\u2019s sending the request is identified by token:\r\n\r\n0a2fb1d34c30dab68c6cf36c7218b4b332059e19db35c6fc9f6c56fd30d0223d\r\n\r\nAfter the request, it prints the list as a HTML table.\r\n\r\n*\/\r\n\r\n$sensorid = \u20185123\u2019;\r\n\r\n$begin = \u20181476057600\u2019; \/\/ 2016-10-10 00:00:00 UTC\r\n\r\n$end = \u20181476144000\u2019; \/\/ 2016-10-11 00:00:00 UTC\r\n\r\n$apiKey = \u20180a2fb1d34c30dab68c6cf36c7218b4b332059e19db35c6fc9f6c56fd30d0223d\u2019;\r\n\r\n$api_request_url = \u2018http:\/\/api.smartdatasystem.es\/v1\/measurements?sensorid=\u2019.$sensorid.\u2018&amp;amp;amp;begin=\u2019.$begin.\u2018&amp;amp;amp;end=\u2019.$end;\r\n\r\n$ch = curl_init();\r\n\r\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);\r\n\r\ncurl_setopt($ch, CURLOPT_HEADER, TRUE);\r\n\r\ncurl_setopt($ch, CURLOPT_CUSTOMREQUEST, \u2018GET\u2019);\r\n\r\ncurl_setopt($ch, CURLOPT_HTTPHEADER, array(\u2018apiKey: \u2018.$apiKey,\u2018Content-Type: application\/json\u2019));\r\n\r\ncurl_setopt($ch, CURLOPT_URL, $api_request_url);\r\n\r\n$api_response = curl_exec($ch);\r\n\r\n$api_response_info = curl_getinfo($ch);\r\n\r\n$results = json_decode(trim(substr($api_response, $api_response_info&#x5B;\u2018header_size\u2019])))-&amp;amp;gt;measurements;\r\n\r\ncurl_close($ch);\r\n\r\n<\/pre>\n<p>[\/vc_column_text][\/vc_tta_section][\/vc_tta_tour][\/vc_column][\/vc_row][\/vc_section]<\/p>\n<\/section>","protected":false},"excerpt":{"rendered":"<p>[vc_section full_width=&#8221;stretch_row_content&#8221; el_id=&#8221;guia-rapida&#8221;][vc_row][vc_column][vc_tta_tour controls_size=&#8221;md&#8221; active_section=&#8221;1&#8243; no_fill_content_area=&#8221;true&#8221; el_class=&#8221;tour-guia-rapida&#8221;][vc_tta_section title=&#8221;Overview&#8221; tab_id=&#8221;overview&#8221;][vc_column_text] API \u2013 Quickstart Get started quickly with and overview of the components involved in a typical solutions and practical examples on how to connect a device and how to integrate an external system to the SDS Platform. [\/vc_column_text][vc_column_text] OVERVIEW Before starting &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"API &#8211; Quickstart\" class=\"read-more button\" href=\"https:\/\/www.mycelium.es\/en\/api-quickstart\/#more-758\" aria-label=\"Read more about API &#8211; Quickstart\">Seguir Leyendo<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":{"0":"post-758","1":"page","2":"type-page","3":"status-publish","5":"infinite-scroll-item"},"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>API - Quickstart - Mycelium<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mycelium.es\/en\/api-quickstart\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"API - Quickstart - Mycelium\" \/>\n<meta property=\"og:description\" content=\"[vc_section full_width=&#8221;stretch_row_content&#8221; el_id=&#8221;guia-rapida&#8221;][vc_row][vc_column][vc_tta_tour controls_size=&#8221;md&#8221; active_section=&#8221;1&#8243; no_fill_content_area=&#8221;true&#8221; el_class=&#8221;tour-guia-rapida&#8221;][vc_tta_section title=&#8221;Overview&#8221; tab_id=&#8221;overview&#8221;][vc_column_text] API \u2013 Quickstart Get started quickly with and overview of the components involved in a typical solutions and practical examples on how to connect a device and how to integrate an external system to the SDS Platform. [\/vc_column_text][vc_column_text] OVERVIEW Before starting ... Seguir Leyendo\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mycelium.es\/en\/api-quickstart\/\" \/>\n<meta property=\"og:site_name\" content=\"Mycelium\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-13T08:44:37+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.mycelium.es\/en\/api-quickstart\/\",\"url\":\"https:\/\/www.mycelium.es\/en\/api-quickstart\/\",\"name\":\"API - Quickstart - Mycelium\",\"isPartOf\":{\"@id\":\"https:\/\/www.mycelium.es\/en\/#website\"},\"datePublished\":\"2023-09-07T10:09:59+00:00\",\"dateModified\":\"2023-11-13T08:44:37+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.mycelium.es\/en\/api-quickstart\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.mycelium.es\/en\/api-quickstart\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.mycelium.es\/en\/api-quickstart\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/www.mycelium.es\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API &#8211; Quickstart\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.mycelium.es\/en\/#website\",\"url\":\"https:\/\/www.mycelium.es\/en\/\",\"name\":\"Mycelium\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.mycelium.es\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.mycelium.es\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.mycelium.es\/en\/#organization\",\"name\":\"Mycelium\",\"alternateName\":\"Mycelium\",\"url\":\"https:\/\/www.mycelium.es\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.mycelium.es\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.mycelium.es\/wp-content\/uploads\/2023\/08\/logo-sds.png\",\"contentUrl\":\"https:\/\/www.mycelium.es\/wp-content\/uploads\/2023\/08\/logo-sds.png\",\"width\":396,\"height\":38,\"caption\":\"Mycelium\"},\"image\":{\"@id\":\"https:\/\/www.mycelium.es\/en\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"API - Quickstart - Mycelium","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mycelium.es\/en\/api-quickstart\/","og_locale":"en_US","og_type":"article","og_title":"API - Quickstart - Mycelium","og_description":"[vc_section full_width=&#8221;stretch_row_content&#8221; el_id=&#8221;guia-rapida&#8221;][vc_row][vc_column][vc_tta_tour controls_size=&#8221;md&#8221; active_section=&#8221;1&#8243; no_fill_content_area=&#8221;true&#8221; el_class=&#8221;tour-guia-rapida&#8221;][vc_tta_section title=&#8221;Overview&#8221; tab_id=&#8221;overview&#8221;][vc_column_text] API \u2013 Quickstart Get started quickly with and overview of the components involved in a typical solutions and practical examples on how to connect a device and how to integrate an external system to the SDS Platform. [\/vc_column_text][vc_column_text] OVERVIEW Before starting ... Seguir Leyendo","og_url":"https:\/\/www.mycelium.es\/en\/api-quickstart\/","og_site_name":"Mycelium","article_modified_time":"2023-11-13T08:44:37+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mycelium.es\/en\/api-quickstart\/","url":"https:\/\/www.mycelium.es\/en\/api-quickstart\/","name":"API - Quickstart - Mycelium","isPartOf":{"@id":"https:\/\/www.mycelium.es\/en\/#website"},"datePublished":"2023-09-07T10:09:59+00:00","dateModified":"2023-11-13T08:44:37+00:00","breadcrumb":{"@id":"https:\/\/www.mycelium.es\/en\/api-quickstart\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mycelium.es\/en\/api-quickstart\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.mycelium.es\/en\/api-quickstart\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/www.mycelium.es\/en\/"},{"@type":"ListItem","position":2,"name":"API &#8211; Quickstart"}]},{"@type":"WebSite","@id":"https:\/\/www.mycelium.es\/en\/#website","url":"https:\/\/www.mycelium.es\/en\/","name":"Mycelium","description":"","publisher":{"@id":"https:\/\/www.mycelium.es\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mycelium.es\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mycelium.es\/en\/#organization","name":"Mycelium","alternateName":"Mycelium","url":"https:\/\/www.mycelium.es\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mycelium.es\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.mycelium.es\/wp-content\/uploads\/2023\/08\/logo-sds.png","contentUrl":"https:\/\/www.mycelium.es\/wp-content\/uploads\/2023\/08\/logo-sds.png","width":396,"height":38,"caption":"Mycelium"},"image":{"@id":"https:\/\/www.mycelium.es\/en\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.mycelium.es\/en\/wp-json\/wp\/v2\/pages\/758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mycelium.es\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mycelium.es\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mycelium.es\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mycelium.es\/en\/wp-json\/wp\/v2\/comments?post=758"}],"version-history":[{"count":3,"href":"https:\/\/www.mycelium.es\/en\/wp-json\/wp\/v2\/pages\/758\/revisions"}],"predecessor-version":[{"id":790,"href":"https:\/\/www.mycelium.es\/en\/wp-json\/wp\/v2\/pages\/758\/revisions\/790"}],"wp:attachment":[{"href":"https:\/\/www.mycelium.es\/en\/wp-json\/wp\/v2\/media?parent=758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}