{"id":6445,"date":"2014-05-27T06:42:07","date_gmt":"2014-05-27T12:42:07","guid":{"rendered":"http:\/\/www.eagleeyenetworks.com\/?p=6445"},"modified":"2020-09-08T10:30:26","modified_gmt":"2020-09-08T15:30:26","slug":"working-api-getting-previews","status":"publish","type":"post","link":"https:\/\/www.een.com\/nl\/blog\/working-api-getting-previews\/","title":{"rendered":"Our Video API: Getting Previews"},"content":{"rendered":"<p>This blog post is an example of how you can use the Eagle Eye Networks <a href=\"https:\/\/www.een.com\/product\/api-categories\/\">Video API<\/a>&nbsp;to embed the preview stream on another site. This is a common request from businesses that want to show their visitors the inside of their facility without a password. Home owners associations, pet hotels, and amusement parks are all examples of this.<\/p>\n<h4>Background<\/h4>\n<p>The&nbsp;<a href=\"https:\/\/www.een.com\/product\/api-categories\/\">Video API<\/a>&nbsp;makes it very easy to get the preview stream for all the cameras in an account. The preview stream is a series of JPEG images and requires authentication. Our code today will show how to use the&nbsp;<a href=\"http:\/\/apidocs.eagleeyenetworks.com\/\">API<\/a>&nbsp;to provide the images on a webpage without authentication.<\/p>\n<h4>Step 1:<\/h4>\n<p>We are going to use the code at&nbsp;<a href=\"https:\/\/github.com\/mcotton\/watcher\">mcotton\/watcher<\/a>&nbsp;to run a Node.js server that will login, subscribe to the poll stream, notify the client and proxy the image requests. We could remove the poll stream to make the example very basic but it is worth going through it now.<\/p>\n<p>Download or clone the&nbsp;<a href=\"https:\/\/github.com\/mcotton\/watcher\">git repository<\/a>. Keep watching our blog as we add more examples in different languages.<\/p>\n<h4>Step 2:<\/h4>\n<p>You will need to have&nbsp;<a href=\"http:\/\/nodejs.org\/\">Node.js<\/a> installed (current version is v0.10.26). Once it is installed, open up the command line in the same directory as the example code, you can install the dependencies by running<\/p>\n<p>Edit the file named config.js, replace \u2018your_username\u2019 and \u2018your_password\u2019 with your username and password<\/p>\n<p>Save the file and start the server<\/p>\n<h4>Step 3:<\/h4>\n<p>You can now open a browser at go to&nbsp;<a href=\"http:\/\/localhost:3000\/\">localhost:3000<\/a>&nbsp;and you will see previews show up as they become available on the server.<\/p>\n<p>The code does the following items: authenticates, authorizes, gets a list of devices, subscribes to the poll stream for each of them, listens to the poll stream and notifies the client when a new preview is available.<\/p>\n<p>Because we are subscribed to the poll stream we are only fetching previews when they are available. This makes it very bandwidth efficient.<\/p>\n<h4>Conclusion:<\/h4>\n<p>You can now treat the image URLs just like static assets on your server. You can put it behind your own firewall or you can make it publicly available. In both cases your username and password are safely stored on the server and never sent to the client.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog post is an example of how you can use the Eagle Eye Networks Video API&nbsp;to embed the preview stream on another site. This is a common request from &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.een.com\/nl\/blog\/working-api-getting-previews\/\"> <span class=\"screen-reader-text\">Our Video API: Getting Previews<\/span> Lees verder &raquo;<\/a><\/p>\n","protected":false},"author":5,"featured_media":13236,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","footnotes":""},"categories":[232],"tags":[1279,1275,1273,1272],"class_list":["post-6445","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-apis","tag-cloud-computing","tag-cloud-video-surveillance","tag-video-management-software"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/posts\/6445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/comments?post=6445"}],"version-history":[{"count":0,"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/posts\/6445\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/media\/13236"}],"wp:attachment":[{"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/media?parent=6445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/categories?post=6445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.een.com\/nl\/wp-json\/wp\/v2\/tags?post=6445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}