{"id":54,"date":"2018-07-01T20:23:33","date_gmt":"2018-07-01T20:23:33","guid":{"rendered":"https:\/\/dev.foxtrackr.com\/?page_id=54"},"modified":"2018-07-12T09:00:06","modified_gmt":"2018-07-12T09:00:06","slug":"getting-started-with-api","status":"publish","type":"page","link":"https:\/\/dev.foxtrackr.com\/?page_id=54","title":{"rendered":"Getting Started With API"},"content":{"rendered":"<p>That&#8217;s your first steps with Foxtrackr for developing your own integration based on our API. This page will help you finding the right way for getting start with the Foxtrackr API.<\/p>\n<h2>Different Type of integration<\/h2>\n<p>There are two different ways to integrate with Foxtrackr:<\/p>\n<ul>\n<li>The PULL api : In this implementation model you do not need to store the Foxtrackr data on your side. You only design a front-end or mobile application and you access the data from our API. In this approach you do not really need to have a backend infrastructure.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-62\" src=\"https:\/\/dev.foxtrackr.com\/wp-content\/uploads\/2018\/07\/Foxtrackr_pull_API2.png\" alt=\"\" width=\"524\" height=\"122\" srcset=\"https:\/\/dev.foxtrackr.com\/wp-content\/uploads\/2018\/07\/Foxtrackr_pull_API2.png 524w, https:\/\/dev.foxtrackr.com\/wp-content\/uploads\/2018\/07\/Foxtrackr_pull_API2-300x70.png 300w\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" \/><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>The PUSH api : in the implementation model you receive a trigger every time a new information has been pushed by one of your devices. You will select and store the information you need into your own backend solution. Then your front-end application will get the Foxtrackr data from you own server.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-61\" src=\"https:\/\/dev.foxtrackr.com\/wp-content\/uploads\/2018\/07\/Foxtrackr_push_API.png\" alt=\"\" width=\"566\" height=\"128\" srcset=\"https:\/\/dev.foxtrackr.com\/wp-content\/uploads\/2018\/07\/Foxtrackr_push_API.png 566w, https:\/\/dev.foxtrackr.com\/wp-content\/uploads\/2018\/07\/Foxtrackr_push_API-300x68.png 300w\" sizes=\"auto, (max-width: 566px) 100vw, 566px\" \/><\/p>\n<p>The two method are not incompatible, for certain operation like the device configuration you need to use the PULL api. You can also choose to store the location in your backend and use the PUSH api for this and in parallel use the PULL api for battery or temperature. This is on your own.<\/p>\n<p>What <strong>you must not do<\/strong> is to is a PULL api on regular basis (like every 1 minute) to find new information and fulfill your backend database. For such operations you need to use on of the PUSH solution otherwise your access can be block for abuse.<\/p>\n<h2>The Pull Api<\/h2>\n<p>From the Pull API you can access to all the various information provided by the tracker but not only. The IngeniousThings (Mother company of Foxtrackr) IoT platform is offering api to manage accounts, devices, group, alarming&#8230; all these functions are accessible and can be automated with the API. This helps you to build end-user applications, specific to your use-case with no need of a backend and its associated operations.<\/p>\n<p>The Pull API is split into 2 parts:<\/p>\n<ul>\n<li>The\u00a0 <a href=\"https:\/\/dev.foxtrackr.com\/swagger-api-foxtrackr\/?urls.primaryName=common-api\">IoT platform API<\/a> where you can access endpoint to manage users, groups, devices, sigfox backends&#8230; And where your can login.<\/li>\n<li>The <a href=\"https:\/\/dev.foxtrackr.com\/swagger-api-foxtrackr\/?urls.primaryName=foxtrackr-api-v3#\/\">Foxtrackr API<\/a> where you can access endpoint for all the Fotrackr specific data and actions.<\/li>\n<\/ul>\n<p>The link above are detailing each of the API endpoint with the model to be used. From these portal you can test online the APIs before implementing your own software.<\/p>\n<p>The fist step is to login on the API to get a JWT (Json Web Token) this is a kind of dynamic API key used for identifying you. It contains you authorization on the API. This token have a duration so it needs to be renewed before ending. this Token will be added then in all the API endpoint in the Authorization field for allowing access.<\/p>\n<p>To obtain your JWT Token, you need to use the <a href=\"https:\/\/dev.foxtrackr.com\/swagger-api-foxtrackr\/?urls.primaryName=common-api#\/Sign-in-up-api\/signInUserUsingPOST\">\/sign\/3.0\/in<\/a> endpoint.<\/p>\n<h2>The Push Api<\/h2>\n<p>The Push Api is not only an API, there are different solution to obtain the data from our servers:<\/p>\n<ul>\n<li>From the Pull Api you can obtain the list of devices updated since your last call and then request for the different informations for that device. This is basically a Push over Pull Api. This solution is not efficient because you it will need a lot of communication to the status endpoint for not a lot of positive response.<\/li>\n<\/ul>\n<p>To access the list of updated devices just request the endpoint <strong>\/devices\/3.0\/listUpdated\/<em>group<\/em>\/-1\/<\/strong> with group replaced by the Base64 group name you want to get devices update status. -1 is used to indicate we want to list updated devices since last call. A timestamp in ms\u00a0 since UTC Epoc can be used instead. This returns a list of DeviceId for being pulled.<\/p>\n<ul>\n<li>You can assign a callback url for a group of devices. In this case for every data update from one of the devices belonging to this group, the given url will be called with a POST message containing the new information received.<\/li>\n<\/ul>\n<p>To activate the Http Push, you need to edit your device group (or create a specific one) and set the Url target. Then for each of the device incoming message a Http POST will be performed on this callback Url with the device information details in the body.<\/p>\n<p>The message format is described in the api-doc, in the Model part under name\u00a0<a href=\"https:\/\/dev.foxtrackr.com\/swagger-api-foxtrackr\/\">FoxtrackrPushMessage<\/a><\/p>\n<ul>\n<li>You can activate MQTT for a group of devices. This is working the same way as the previous one. But instead of getting a POST, the data will be sent to MQTT channel. Your backend can connect to our MQTT server to receive the informations. This is our favorite integration way as this solution is reliable: it stores the information until you get them.<\/li>\n<\/ul>\n<p>To activate MQTT, you need to edit your device group (or create a specific one) and switch this option on. The message format is the same as for HTTP Post but you filter your subscription based on topics.<\/p>\n<p>The topic format is the following : foxtrackr\/{device_id}\/3.0\/{message_type}<\/p>\n<p>To subscribe to the topic, you need to request a user account on our MQTT infrastructure by <a href=\"https:\/\/dev.foxtrackr.com\/?page_id=84\">contacting us<\/a>.<\/p>\n<p>To access the MQTT Service, you can get more details on the <a href=\"https:\/\/dev.foxtrackr.com\/?p=109\">Foxtrackr MQTT page<\/a>.<\/p>\n<h2>Next steps<\/h2>\n<p>Before starting your code, we recommend you to see the platform <a href=\"https:\/\/dev.foxtrackr.com\/?page_id=74\">main development concepts<\/a> about right management, group management&#8230;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>That&#8217;s your first steps with Foxtrackr for developing your own integration based on our API. This page will help you finding the right way for getting start with the Foxtrackr API. Different Type of integration There are two different ways to integrate with Foxtrackr: The PULL api : In this implementation model you do not &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/dev.foxtrackr.com\/?page_id=54\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Getting Started With API&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-54","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P9HKNr-S","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":74,"url":"https:\/\/dev.foxtrackr.com\/?page_id=74","url_meta":{"origin":54,"position":0},"title":"Main dev concepts","author":"foxtrackr","date":"July 4, 2018","format":false,"excerpt":"The API access is restricted for the most of the end points and for using it you need to login and get a JWT token. This Token contains a list of ACL attached to the user account and a list of GROUPS attached to the user account. The following paragraphs\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":68,"url":"https:\/\/dev.foxtrackr.com\/?page_id=68","url_meta":{"origin":54,"position":1},"title":"Features","author":"foxtrackr","date":"July 3, 2018","format":false,"excerpt":"Foxtrackr cube firmware features Version 3.0 (Current) Scheduled position report (cumulative) : the device report its position on regular basis ( from 10 minutes to multiple days. Scheduled position report on hold (cumulative) : the device reports its position when not moving on regular basis. Scheduled position report on movement\u2026","rel":"","context":"Similar post","block_context":{"text":"Similar post","link":""},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/dev.foxtrackr.com\/index.php?rest_route=\/wp\/v2\/pages\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.foxtrackr.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/dev.foxtrackr.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/dev.foxtrackr.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.foxtrackr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=54"}],"version-history":[{"count":11,"href":"https:\/\/dev.foxtrackr.com\/index.php?rest_route=\/wp\/v2\/pages\/54\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/dev.foxtrackr.com\/index.php?rest_route=\/wp\/v2\/pages\/54\/revisions\/114"}],"wp:attachment":[{"href":"https:\/\/dev.foxtrackr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}