{"id":4793,"date":"2014-06-09T14:47:50","date_gmt":"2014-06-09T14:47:50","guid":{"rendered":"https:\/\/www.gosquared.com\/blog\/?p=4793"},"modified":"2019-11-28T12:09:24","modified_gmt":"2019-11-28T12:09:24","slug":"api-update-trends-custom-dates","status":"publish","type":"post","link":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates","title":{"rendered":"API update: Custom dates for Trends"},"content":{"rendered":"<p>When we re-launched our homepage last month with the headline &#8216;easy to use real-time web analytics&#8217;, we weren&#8217;t simply referring to the dashboards our customers use everyday. We&#8217;ve always taken great pride in providing APIs that are similarly a joy to use.<\/p>\n<p>For the non-engineers reading this post, API stands for application programming interface and it puts the power of our analytics engine in the hands of anyone who wants to develop with it. While this post will primarily be of interest to GoSquared developers, anyone can get started using our APIs, for example to extract historical data with <a href=\"https:\/\/www.gosquared.com\/developer\/api\/trends\/v2\/\">live examples in our documentation.<\/a> <\/p>\n<p>Since launching V2 of our Trends API last October, we&#8217;ve had tons of great feedback from the community. We&#8217;re thrilled to hear that our customers love the API for its speed, developer-friendly structure and powerful data resource. We want to support developers using the API as much as possible and there was one niggling limitation that has been cropping up in feedback.. The greatest limitation with the current Trends API has been the inability to query dimension data for a custom time period (except for the &#8220;aggregate&#8221; dimension, which was supported).<\/p>\n<p>As a reminder, in Trends a dimension is a bunch of metrics broken down by a certain attribute. So, for example, you might have total website visits broken down by browser, and that would look like the following:<\/p>\n<p><code>https:\/\/api.gosquared.com\/trends\/v2\/browser?api_key=demo&amp;site_token=GSN-106863-S&amp;limit=3<\/code><\/p>\n<pre style=\"font-size: 0.7em; line-height: 1.2em;\"><code class=\"language-javascript\">\r\n{\r\n  \"list\": [{\r\n    \"id\": \"chrome\",\r\n    \"browser\": \"chrome\",\r\n    \"metrics\": {\r\n      \"visits\": 245618\r\n    }\r\n  }, {\r\n    \"id\": \"firefox\",\r\n    \"browser\": \"firefox\",\r\n    \"metrics\": {\r\n      \"visits\": 45777\r\n    }\r\n  }, {\r\n    \"id\": \"mobilesafari\",\r\n    \"browser\": \"mobilesafari\",\r\n    \"metrics\": {\r\n      \"visits\": 37816\r\n    }\r\n  }],\r\n  \"cardinality\": 27,\r\n  \"dimension\": \"browser\",\r\n  \"range\": {\r\n    \"from\": \"2014-06-02T00:00:00\",\r\n    \"to\": \"2014-06-09T23:59:59\"\r\n  },\r\n  \"interval\": \"day\"\r\n}\r\n<\/code><\/pre>\n<h2>The News<\/h2>\n<p>I&#8217;m glad to announce that we have implemented custom time period querying on all dimensions, now live on the Trends API.<\/p>\n<h2>Usage<\/h2>\n<p>To control the start and end time for the query, include the <code>from<\/code> and <code>to<\/code> parameters in the request. For example:<\/p>\n<p><code>http:\/\/api.gosquared.com\/trends\/v2\/browser?api_key=demo&amp;site_token=GSN-106863-S&amp;from=2014-04-01&amp;to=2014-05-23<\/code><\/p>\n<ul>\n<li>If you omit the <code>to<\/code> parameter, it will default to latest.<\/li>\n<li>If both params are omitted, the default period is the current week, like before.<\/li>\n<li>The smallest granularity is &#8216;day&#8217;, so changing the timestamps at a more granular level (e.g. &#8216;hour&#8217;) won&#8217;t change the query period.<\/li>\n<li>The time range being queried will be sent back in the response under the &#8220;range&#8221; object, so you know exactly what period the data represents.<\/li>\n<\/ul>\n<p>Peruse the <a href=\"https:\/\/www.gosquared.com\/developer\/api\/trends\/v2\/\" target=\"_blank\" rel=\"noopener noreferrer\">developer docs<\/a>\u00a0for everything you need to know about the API and harnessing its capabilities. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>When we re-launched our homepage last month with the headline &#8216;easy to use real-time web analytics&#8217;, we weren&#8217;t simply referring&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1586],"tags":[],"class_list":["post-4793","post","type-post","status-publish","format-standard","hentry","category-gosquared-updates"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v18.6 (Yoast SEO v19.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>API update: Custom dates for Trends - GoSquared Blog<\/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.gosquared.com\/blog\/api-update-trends-custom-dates\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"API update: Custom dates for Trends\" \/>\n<meta property=\"og:description\" content=\"When we re-launched our homepage last month with the headline &#8216;easy to use real-time web analytics&#8217;, we weren&#8217;t simply referring...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates\" \/>\n<meta property=\"og:site_name\" content=\"GoSquared Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GoSquared\" \/>\n<meta property=\"article:published_time\" content=\"2014-06-09T14:47:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-11-28T12:09:24+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@TheDeveloper\" \/>\n<meta name=\"twitter:site\" content=\"@GoSquared\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Geoff Wagstaff\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\",\"name\":\"GoSquared\",\"url\":\"https:\/\/www.gosquared.com\/blog\/\",\"sameAs\":[\"https:\/\/instagram.com\/gosquaredteam\",\"https:\/\/www.linkedin.com\/company\/go-squared-ltd.\",\"https:\/\/www.facebook.com\/GoSquared\",\"https:\/\/twitter.com\/GoSquared\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png\",\"contentUrl\":\"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png\",\"width\":1270,\"height\":250,\"caption\":\"GoSquared\"},\"image\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#website\",\"url\":\"https:\/\/www.gosquared.com\/blog\/\",\"name\":\"GoSquared Blog\",\"description\":\"Turn visitors into customers.\",\"publisher\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.gosquared.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#webpage\",\"url\":\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates\",\"name\":\"API update: Custom dates for Trends - GoSquared Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#website\"},\"datePublished\":\"2014-06-09T14:47:50+00:00\",\"dateModified\":\"2019-11-28T12:09:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.gosquared.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API update: Custom dates for Trends\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#webpage\"},\"author\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/56a3341790c8a0603f96066fb8d42448\"},\"headline\":\"API update: Custom dates for Trends\",\"datePublished\":\"2014-06-09T14:47:50+00:00\",\"dateModified\":\"2019-11-28T12:09:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#webpage\"},\"wordCount\":370,\"publisher\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\"},\"articleSection\":[\"GoSquared Updates\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/56a3341790c8a0603f96066fb8d42448\",\"name\":\"Geoff Wagstaff\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/66792d2e4d04406697b9a5f322664691590a386bc15b7146d143bbca07aa8889?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/66792d2e4d04406697b9a5f322664691590a386bc15b7146d143bbca07aa8889?s=96&d=mm&r=g\",\"caption\":\"Geoff Wagstaff\"},\"sameAs\":[\"https:\/\/twitter.com\/TheDeveloper\"],\"url\":\"https:\/\/www.gosquared.com\/blog\/author\/echo\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"API update: Custom dates for Trends - GoSquared Blog","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.gosquared.com\/blog\/api-update-trends-custom-dates","og_locale":"en_US","og_type":"article","og_title":"API update: Custom dates for Trends","og_description":"When we re-launched our homepage last month with the headline &#8216;easy to use real-time web analytics&#8217;, we weren&#8217;t simply referring...","og_url":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates","og_site_name":"GoSquared Blog","article_publisher":"https:\/\/www.facebook.com\/GoSquared","article_published_time":"2014-06-09T14:47:50+00:00","article_modified_time":"2019-11-28T12:09:24+00:00","twitter_card":"summary_large_image","twitter_creator":"@TheDeveloper","twitter_site":"@GoSquared","twitter_misc":{"Written by":"Geoff Wagstaff","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/www.gosquared.com\/blog\/#organization","name":"GoSquared","url":"https:\/\/www.gosquared.com\/blog\/","sameAs":["https:\/\/instagram.com\/gosquaredteam","https:\/\/www.linkedin.com\/company\/go-squared-ltd.","https:\/\/www.facebook.com\/GoSquared","https:\/\/twitter.com\/GoSquared"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png","contentUrl":"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png","width":1270,"height":250,"caption":"GoSquared"},"image":{"@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/www.gosquared.com\/blog\/#website","url":"https:\/\/www.gosquared.com\/blog\/","name":"GoSquared Blog","description":"Turn visitors into customers.","publisher":{"@id":"https:\/\/www.gosquared.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.gosquared.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#webpage","url":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates","name":"API update: Custom dates for Trends - GoSquared Blog","isPartOf":{"@id":"https:\/\/www.gosquared.com\/blog\/#website"},"datePublished":"2014-06-09T14:47:50+00:00","dateModified":"2019-11-28T12:09:24+00:00","breadcrumb":{"@id":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.gosquared.com\/blog"},{"@type":"ListItem","position":2,"name":"API update: Custom dates for Trends"}]},{"@type":"Article","@id":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#article","isPartOf":{"@id":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#webpage"},"author":{"@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/56a3341790c8a0603f96066fb8d42448"},"headline":"API update: Custom dates for Trends","datePublished":"2014-06-09T14:47:50+00:00","dateModified":"2019-11-28T12:09:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.gosquared.com\/blog\/api-update-trends-custom-dates#webpage"},"wordCount":370,"publisher":{"@id":"https:\/\/www.gosquared.com\/blog\/#organization"},"articleSection":["GoSquared Updates"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/56a3341790c8a0603f96066fb8d42448","name":"Geoff Wagstaff","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/66792d2e4d04406697b9a5f322664691590a386bc15b7146d143bbca07aa8889?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/66792d2e4d04406697b9a5f322664691590a386bc15b7146d143bbca07aa8889?s=96&d=mm&r=g","caption":"Geoff Wagstaff"},"sameAs":["https:\/\/twitter.com\/TheDeveloper"],"url":"https:\/\/www.gosquared.com\/blog\/author\/echo"}]}},"wps_subtitle":"Dimensions can now be queried using a date range defined by you","_links":{"self":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts\/4793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/comments?post=4793"}],"version-history":[{"count":0,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts\/4793\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/media?parent=4793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/categories?post=4793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/tags?post=4793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}