Introduction

MineWhat’s API

The MineWhat API is the interface that a developer can use to send or recieve and data from our system. We make periodical updates to the API. See the changelog for more details.

Access

All calls to the API require an access_token that defines the customer making the call. Any registered MineWhat user can get this token from the API settings page on their account

You could use the API to either send transactional data to our servers and increase insight accuracy or you could use it to extract validated data from any of the insights. Please visit the website for more info on product features.

Collection

Set Customer Email

SDK js:

MWSDK.trackUser(email_id, data);

Example MWSDK.trackUser('abc@gmail.com', {tags: ['premiumuser', 'above60']});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackUser', email_id, data]);

Example _mwapi.push(['trackUser', 'abc@gmail.com', {tags: ['premiumuser', 'above60']}]);

Users can clear cache and cookies from browser. Help us associate logged in users with their multiple session online by sending user email when he signs in.

Parameters

Parameter Description
email_id Email Id of the signed in customer
tags Array of user tags you want us to track

Track Product View Event

SDK js:

MWSDK.trackEvent('product', {pid: pid, associated_ids: associated_ids});

Example MWSDK.trackEvent('product', {pid: 'YZ1546', associated_ids: ['YZ1546A']});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackEvent', 'product', {pid: pid, associated_ids: associated_ids}]);

Example _mwapi.push(['trackEvent', 'product', {pid: 'YZ1546', associated_ids: ['YZ1546A']}]);

Send us product view details. It will help us provide you with better analysis.

Parameters

Parameter Description
pid Product ID. The unique identifier of the product you want us to track
associated_ids The array of associated product ids

Associated IDs

Array of associated products

Example: [pid1, pid2, ….]

Track Add To Cart Event

SDK js:

MWSDK.trackEvent('addtocart', {pid: pid, sku: sku, parent_pid: parent_pid, qty: qty, bundle: bundle});

Example MWSDK.trackEvent('addtocart', {pid: 'YZ1546A', sku: 'YZ1546ALRG', parent_pid: 'YZ1546', qty: 2, bundle: [{pid: 'AB1546A', sku: 'AB1546ASML', price: 159}, {pid: 'D1546A', sku: 'D1546AML', price: 200}]});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackEvent', 'addtocart', {pid: pid, sku: sku, parent_pid: parent_pid, qty: qty, bundle: bundle}]);

Example _mwapi.push(['trackEvent', 'addtocart', {pid: 'YZ1546A', sku: 'YZ1546ALRG', parent_pid: 'YZ1546', qty: 2, bundle: [{pid: 'AB1546A', sku: 'AB1546ASML', price: 159}, {pid: 'D1546A', sku: 'D1546AML', price: 200}]}]);

Send us add to cart details. It will help us provide you with better analysis.

Parameters

Parameter Description
pid Product ID. The unique identifier of the product of the product you want us to track
parent_pid Parent Product ID. The unique identifier of the parent product(incase of variant products) you want us to track
sku The sku of the item
qty The quantity of items remaining in the stock
bundle The array of items in bundle

Bundle

Array of individual products incase of bundle product

Example: [{pid: pid, sku: sku, price: price}, …..]

Parameter Description
pid Product ID. The unique identifier of the product of the product you want us to track
sku The sku of the item
price The price of product

Track Remove From Cart Event

SDK js:

MWSDK.trackEvent('removecart', {pid: pid, sku: sku, parent_pid: parent_pid, qty: qty, bundle: bundle});

Example MWSDK.trackEvent('removecart', {pid: 'YZ1546A', sku: 'YZ1546ALRG', parent_pid: 'YZ1546', qty: 2, bundle: [{pid: 'AB1546A', sku: 'AB1546ASML', price: 159}, {pid: 'D1546A', sku: 'D1546AML', price: 200}]});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackEvent', 'removecart', {pid: pid, sku: sku, parent_pid: parent_pid, qty: qty, bundle: bundle}]);

Example _mwapi.push(['trackEvent', 'removecart', {pid: 'YZ1546A', sku: 'YZ1546ALRG', parent_pid: 'YZ1546', qty: 2, bundle: [{pid: 'AB1546A', sku: 'AB1546ASML', price: 159}, {pid: 'D1546A', sku: 'D1546AML', price: 200}]}]);

Send us remove from cart details. It will help us provide you with better analysis.

Parameters

Parameter Description
pid Product ID. The unique identifier of the product of the product you want us to track
parent_pid Parent Product ID. The unique identifier of the parent product(incase of variant products) you want us to track
sku The sku of the item
qty The quantity of items remaining in the stock
bundle The array of items in bundle

Bundle

Array of individual products incase of bundle product

Example: [{pid: pid, sku: sku, price: price}, ….]

Parameter Description
pid Product ID. The unique identifier of the product of the product you want us to track
sku The sku of the item
price The price of product

Track Cart Info

SDK js:

MWSDK.trackEvent('bag', {products: products});

Example MWSDK.trackEvent('bag', {products: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', qty: 2, price: 359, parent_pid: 'YZ1546', bundle: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', price: 359}]}]});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackEvent', 'bag', {products: products}]);

Example _mwapi.push(['trackEvent', 'bag', {products: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', qty: 2, price: 359, parent_pid: 'YZ1546', bundle: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', price: 359}]}]}]);

Send us cart details. It will help us provide you with better analysis.

Parameters

Parameter Description
products The products inside cart which you want us to track

Items

Array of products in the cart

Example: [{pid: pid, sku: sku, qty: qty, price: price, parent_pid: parent_pid, bundle: bundle}, ….]

Parameter Description
pid Product ID The unique identifier of the product of the product you want us to track
sku The sku of the item
qty The quantity of items
price The price of product
parent_pid Parent Product ID. The unique identifier of the parent product(incase of variant products) you want us to track
bundle The array of items in bundle

Track Buy Event

SDK js:

MWSDK.trackEvent('buy', {products: products, order: order});

Example MWSDK.trackEvent('buy', {products: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', qty: 2, price: 359, revenue: 710, parent_pid: 'YZ1546', bundle: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', price: 359}]}], order: {order_number: 'ABDFGERSA123', revenue: 700, discount: 20, shipping: 10, payment: 'cod', email: 'abc@gmail.com', created_at: '2016-05-12 12:00:12 -0400'}});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackEvent', 'buy', {products: products, order: order}]);

Example _mwapi.push(['trackEvent', 'buy', {products: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', qty: 2, price: 359, revenue: 710, parent_pid: 'YZ1546', bundle: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', price: 359}]}], order: {order_number: 'ABDFGERSA123', revenue: 700, discount: 20, shipping: 10, payment: 'cod', email: 'abc@gmail.com', created_at: '2016-05-12 12:00:12 -0400'}}]);

Send us purchase details. It will help us provide you with better analysis.

Parameters

Parameter Description
products The list of ordered products you want us to track
order The order details

Products

Array of products bought

Example: [{pid: pid, sku: sku, qty: qty, price: price, parent_pid: parent_pid, bundle: bundle}, ….]

Parameter Description
pid Product ID. The unique identifier of the product of the product you want us to track
sku The sku of the item
qty The quantity of items
price The price of product
revenue Total revenue on the product after product level discount
parent_pid Parent Product ID. The unique identifier of the parent product(incase of variant products) you want us to track
bundle The array of items in bundle

Order

Parameter Description
order_number The unique order number
revenue Total order revenue after cart level discount + shipping charges(if any)
discount Total discount applied on order
shipping Total shipping charge for the order
payment The Payment method used for purchase
email The email id of user who made the order
created_at The time of order in the format YYYY-MM-DD HH:mm:ss ZZ

Track Canceled Orders

SDK js:

MWSDK.trackEvent('cancel', {products: products, order: order});

Example MWSDK.trackEvent('cancel', {products: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', qty: 2, price: 359, parent_pid: 'YZ1546', bundle: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', price: 359}]}], order: {order_number: 'ABDFGERSA123', payment: 'cod', email: 'abc@gmail.com'}});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackEvent', 'cancel', {products: products, order: order}]);

Example _mwapi.push(['trackEvent', 'cancel', {products: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', qty: 2, price: 359, parent_pid: 'YZ1546', bundle: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', price: 359}]}], order: {order_number: 'ABDFGERSA123', payment: 'cod', email: 'abc@gmail.com'}}]);

Send us order cancel details. It will help us provide you with better analysis.

Parameters

Parameter Description
products The list of products in the canceled order
order The order details

Products

Array of products canceled

Example: [{pid: pid, sku: sku, qty: qty, price: price, parent_pid: parent_pid, bundle: bundle}, ….]

Parameter Description
pid Product ID. The unique identifier of the product of the product you want us to track
sku The sku of the item
qty The quantity of items
price The price of product
parent_pid Parent Product ID. The unique identifier of the parent product(incase of variant products) you want us to track
bundle The array of items in bundle

Order

Parameter Description
order_number The unique order number
payment The Payment method used for purchase
email The email id of user who requested order cancel

Track Returns

SDK js:

MWSDK.trackEvent('return', {products: products, order: order});

Example MWSDK.trackEvent('return', {products: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', qty: 2, price: 359, parent_pid: 'YZ1546', bundle: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', price: 359}]}], order: {order_number: 'ABDFGERSA123', payment: 'cod', email: 'abc@gmail.com'}});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackEvent', 'return', {products: products, order: order}]);

Example _mwapi.push(['trackEvent', 'return', {products: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', qty: 2, price: 359, parent_pid: 'YZ1546', bundle: [{pid: 'YZ1546A', sku: 'YZ1546ALRG', price: 359}]}], order: {order_number: 'ABDFGERSA123', payment: 'cod', email: 'abc@gmail.com'}}]);

Send us product return details. It will help us provide you with better analysis.

Parameters

Parameter Description
products The list of products returned
order The order details

Products

Array of products returned

Example: [{pid: pid, sku: sku, qty: qty, price: price, parent_pid: parent_pid, bundle: bundle}, ….]

Parameter Description
pid Product ID. The unique identifier of the product of the product you want us to track
sku The sku of the item
qty The quantity of items
price The price of product
parent_pid Parent Product ID. The unique identifier of the parent product(incase of variant products) you want us to track
bundle The array of items in bundle

Order

Parameter Description
order_number The unique order number
payment The Payment method used for purchase
email The email id of user who made the return

Track Product Custom Event

SDK js:

MWSDK.trackEvent('custom', {pid: pid, metric: metric, attribute: attribute, url: url});

Example MWSDK.trackEvent('custom', {pid: 'YZ1546', metric: 'quickview', attribute: {collection: '50%SALE_PAGE'}, url: 'www.yourstore.com/pid/12'});

Script js:

window._mwapi = window._mwapi || [];
_mwapi.push(['trackEvent', 'custom', {pid: pid, metric: metric, attribute: attribute, url: url}]);

Example _mwapi.push(['trackEvent', 'custom', {pid: 'YZ1546', metric: 'quickview', attribute: {collection: '50%SALE_PAGE'}, url: 'www.yourstore.com/pid/12'}]);

Send us custom events to track.

Parameters

Parameter Description
pid Product ID. The unique identifier of the product you want us to track
metric Custom metric you want us to track
attribute Custom attribute you want us to track
url The product url

Attribute

Object containing attribute and attribute value mapping.

Example: {‘collection’: ‘50%SALE_PAGE’}

Automation

Get List of Insights

API shell:

curl -H "MW-Token: <apikey>" -H "Content-Type: application/json" -X GET https://api.minewhat.com/v1/insights?domain=<domain_key>

Example:
curl -H "MW-Token: 123456ab78cd9e01" -H "Content-Type: application/json" -X GET https://api.minewhat.com/v1/insights?domain=sandbox_sandbox

Response:
{status: "ok", data: {insights: [{id: "52eb4b1b8b7a5800000002cd", name: "Products under Designer Collection that were viewed via search more often", metric: "searchviews", order: "topk"}, ...]}}

You can get all the insights you have created or system created with this API.

Filters

Parameter Description
domain domain key
metric views/purchases/revenue(optional)
order topk/leastk(optional)

Response

Response of an insight list call

{status: “ok”, data: {insights: [{id: id, name: name, metric: metric, order: order}, …]}}

Parameter Description
id The exact id of the Insight
name Name of the insight,
metric The metric of the insight
order topk/leastk

Get Items of an Insight

API shell:

curl -H "MW-Token: <apikey>" -H "Content-Type: application/json" -X GET http://api.minewhat.com/v1/insights/<insightid>?domain=<domain_key>

Example:
curl -H "MW-Token: 123456ab78cd9e01" -H "Content-Type: application/json" -X GET http://api.minewhat.com/v1/insights/52eb4b1b8b7a5800000002cd?domain=sandbox_sandbox

Response:
{status: "ok", data: {id: "52eb4b1b8b7a5800000002cd" , name: "Most Converting Products From Mobile" , metric: "conversionrate", order: "topk", itemtype: "products", date: {fromDate: "2014-08-14", toDate: "2014-08-20", dataValidFrom: "2014-08-01", dataValidTo: "2014-08-25", format: "YYYY-MM-DD"}, insight: {"all-items": [{id: "AX12", name: "Blue Jeans", price: "$99", brand: "dkny", brandid: 56, categories: ["men", "jeans"], categoryids: [2, 34], m1: 2045, m2: 26, m3: 2574, m4: "1.27%", m5: 25}, ...]}, metricnames: {m1name: "Views", m2name: "Purchases", m3name: "Revenue", m4name: "Conversion rate", m5name: "Avg. Time Spent"}}}

You can get all the items of the insights so that you can connect back to any automation systems like Email, Landing Page automation etc

Parameters

Parameter Description
id Unique identifier of the insight (obtained with insight list api)
limit Max. entries in the response (maximum: 250, default: 50)
domain domain key

Response

Response of an insight call

{status: “ok”, data: {id: ins_id , name: ins_name , metric: metric, order: order, itemtype: itemtype, date: {fromDate: fromDate, toDate: toDate, dataValidFrom: dataValidFrom, dataValidTo: dataValidTo, format: “YYYY-MM-DD”}, insight: {“ins_group”: [{id: product_id, name: product_name, price: price, brand: brand, brandid: brandid, categories: categories, categoryids: categoryids, m1: m1, m2: m2, m3: m3, m4: m4, m5: m5}, …]}, metricnames: {m1name: m1name, m2name: m2name, m3name: m3name, m4name: m4name, m5name: m5name}}}

Parameter Description
ins_id Unique identifier of the insight
ins_name Name of Insight
metric views/purchases/revenue/avgtimespent/conversionrate
order topk/leastk
itemtype products/brands/category
product_id Unique identifier of the insight.
product_name Name of the product
brand Brand name
brandid Brand ID
categories Category list
categoryids Category ID list
m1name…m5name Metric names
m1…m5 Metric values
date The date object for which above metric were achieved