Skip to content

Analytics API: Scans

Gene Stevens edited this page Mar 10, 2012 · 1 revision

This API initiates a download of scan activity. Filters can be used to narrow the search as well as to manage the download size.

URI for Scans

  • Format: /analytics/scans
  • Verbs: GET

Output Columns

  • short_id: The short item ID which was scanned
  • item_id: The item ID (product ID) which was scanned (as provided by the customer)
  • item_category: The category of the product which was scanned
  • timestamp: The time in UTC when the scan happened
  • scan_type: The scan type
  • latitude: The latitude recorded for the scan
  • longitude: The longitude recorded for the scan
  • country: (e.g., "US") - The country code recorded for the scan
  • region: (e.g., "CO") - The region (state) recorded for the scan
  • city: (e.g., "Denver") - The name of the city recorded for the scan
  • user_id: A unique identifier for the user
  • distance: (eg 0.979861410543302) - Distance from the supplied lat/lng pair
  • distance_units: (eg "kilometer") - what unit of distance is being used (this will align with the distance provided to the query by the user)

###Notes user_id is anonymized user_id will be empty or null if uniqueness cannot be determined user_id is a "best guess" with regard to third party scanning apps scan_type is currently "scan" or "vscan" to differentiate between scans and "virtual" scans. Virtual scans occur when a user shares something that was scanned physically and the recipient views it. In this sense the recipient also "scanned" it but not in a physical sense. latitude and longitude are only as good as the quality of the device and its network distance and distance_units are only output when querying by latitude and longitude

Output Filters

Output Filters are specified as Query Parameters submitted against the standard URI and can be used to refine searches.

  • short_id: (e.g., "ab12") - Exact match only
  • item_id: (e.g., "item-0002") - Exact match only
  • item_category: (e.g., "Inventory") - Exact match only
  • timestamp: A range search only (no exact match), actual parameters consist of one or both of the following. Values are date or date + time, and are accepted as UTC if a timezone is not provided.
  • timestamp_from: (e.g., "2012-02-16", "2012-02-16 07:01:54", "2012-02-16 07:01:54+05") - only values on or after this date/time
  • timestamp_to: (e.g., "2012-02-16", "2012-02-16 07:01:54", "2012-02-16 07:01:54+05") - only values on or before this date/time
  • scan_type: (e.g., "scan") - Exact match only
  • country: (e.g., "US") - Exact match only
  • region: (e.g., "CO") - Exact match only
  • city: (e.g., "Denver") - Exact match only
  • user_id: (e.g., "28d2d5adcedf14fc450689a5201effab") - Exact match only

GET Requests

CSV Example

Example CSV curl request

curl -v -k -X GET \
	-H 'X-ActiveTag-AccessToken: 99065137-f220-4282-b228-07d97935b41d' \
	-H 'Accept: text/csv' \
	'https://api.taglabsinc.com/analytics/scans'

Example CSV curl response

< HTTP/1.1 200 OK
< Date: Thu, 01 Mar 2012 20:44:59 GMT
< Server: Apache/2.2.20 (Ubuntu) mod_ssl/2.2.20 OpenSSL/1.0.0e
< Content-disposition: attachment;filename=scans.csv
< Transfer-Encoding: chunked
< Content-Type: text/csv;charset=utf-8
<
short_id,item_id,item_category,timestamp,scan_type,latitude,longitude,country,region,city,user_id
ab12,item-0001,Inventory,"2012-02-27 19:27:49",scan,,,,,,28d2d5adcedf14fc450689a5201effab
ab12,item-0001,Inventory,"2012-02-27 17:32:50",virtual,,,,,,28d2d5adcedf14fc450689a5201effab
ab12,item-0001,Inventory,"2012-02-27 18:17:16",virtual,,,,,,28d2d5adcedf14fc450689a5201effab
cd34,item-0002,Inventory,"2012-02-27 19:12:55",scan,,,,,,28d2d5adcedf14fc450689a5201effab
ab12,item-0001,Inventory,"2012-02-26 07:23:21",virtual,,,,,,28d2d5adcedf14fc450689a5201effab
ab12,item-0001,Inventory,"2012-02-27 06:53:29",virtual,,,,,,28d2d5adcedf14fc450689a5201effab

XML Example

Example XML curl request

curl -v -k -X GET \
	-H 'X-ActiveTag-AccessToken: 99065137-f220-4282-b228-07d97935b41d' \
	-H 'Accept: application/xml' \
	'https://api.estevens.eng.taglabsinc.net/analytics/scans'

Example XML curl response

< HTTP/1.1 200 OK
< Date: Thu, 01 Mar 2012 20:52:24 GMT
< Server: Apache/2.2.20 (Ubuntu) mod_ssl/2.2.20 OpenSSL/1.0.0e
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< Content-Type: text/xml;charset=utf-8
<
<?xml version="1.0"?>
<scans>
<row><short_id>a7q7</short_id><item_id>item-0001</item_id><item_category>Inventory</item_category><timestamp>2012-02-27 19:27:49</timestamp><scan_type>scan</scan_type><latitude></latitude><longitude></longitude><country></country><region></region><city></city><user_id>28d2d5adcedf14fc450689a5201effab</user_id></row>
<row><short_id>a7q7</short_id><item_id>item-0001</item_id><item_category>Inventory</item_category><timestamp>2012-02-27 17:32:50</timestamp><scan_type>virtual</scan_type><latitude></latitude><longitude></longitude><country></country><region></region><city></city><user_id>28d2d5adcedf14fc450689a5201effab</user_id></row>
<row><short_id>a7q7</short_id><item_id>item-0001</item_id><item_category>Inventory</item_category><timestamp>2012-02-27 18:17:16</timestamp><scan_type>virtual</scan_type><latitude></latitude><longitude></longitude><country></country><region></region><city></city><user_id>28d2d5adcedf14fc450689a5201effab</user_id></row>
<row><short_id>ef1t</short_id><item_id>item-0002</item_id><item_category>Inventory</item_category><timestamp>2012-02-27 19:12:55</timestamp><scan_type>scan</scan_type><latitude></latitude><longitude></longitude><country></country><region></region><city></city><user_id>28d2d5adcedf14fc450689a5201effab</user_id></row>
<row><short_id>a7q7</short_id><item_id>item-0001</item_id><item_category>Inventory</item_category><timestamp>2012-02-26 07:23:21</timestamp><scan_type>virtual</scan_type><latitude></latitude><longitude></longitude><country></country><region></region><city></city><user_id>28d2d5adcedf14fc450689a5201effab</user_id></row>
</scans>

Filter Example

Example country and region filter curl request

curl -v -k -X GET \
	-H 'X-ActiveTag-AccessToken: 99065137-f220-4282-b228-07d97935b41d' \
	-H 'Accept: text/csv' \
	'https://api.taglabsinc.com/analytics/scans?country=US&region=CO'

Example country and region filter curl response

< HTTP/1.1 200 OK
< Date: Thu, 01 Mar 2012 21:02:16 GMT
< Server: Apache/2.2.20 (Ubuntu) mod_ssl/2.2.20 OpenSSL/1.0.0e
< Content-disposition: attachment;filename=scans.csv
< Transfer-Encoding: chunked
< Content-Type: text/csv;charset=utf-8
<
short_id,gene_id,item_category,timestamp,scan_type,latitude,longitude,country,region,city,user_id
cd34,item-0002,Inventory,"2012-02-16 07:01:54",scan,39.558300,-105.083801,US,CO,Denver,28d2d5adcedf14fc450689a5201effab
ab12,item-0001,Inventory,"2012-02-17 12:02:11",scan,39.558300,-105.083801,US,CO,Aurora,28d2d5adcedf14fc450689a5201effab
ab12,item-0001,Inventory,"2012-02-15 09:14:24",scan,39.558300,-105.083801,US,CO,Broomfield,28d2d5adcedf14fc450689a5201effab
ab12,item-0001,Inventory,"2012-02-15 08:21:11",virtual,39.558300,-105.083801,US,CO,Denver,28d2d5adcedf14fc450689a5201effab
cd34,item-0002,Inventory,"2012-02-16 08:24:06",scan,39.558300,-105.083801,US,CO,Aurora,28d2d5adcedf14fc450689a5201effab
cd34,item-0002,Inventory,"2012-02-17 16:11:22",virtual,39.558300,-105.083801,US,CO,Denver,28d2d5adcedf14fc450689a5201effab
cd34,item-0002,Inventory,"2012-02-17 15:11:56",scan,39.558300,-105.083801,US,CO,Denver,28d2d5adcedf14fc450689a5201effab
cd34,item-0002,Inventory,"2012-02-15 05:11:43",scan,39.558300,-105.083801,US,CO,Denver,28d2d5adcedf14fc450689a5201effab
cd34,item-0002,Inventory,"2012-02-16 11:31:25",virtual,39.558300,-105.083801,US,CO,Denver,28d2d5adcedf14fc450689a5201effab

Clone this wiki locally