Datatrics API

The Datatrics API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients, and we support cross-origin resource sharing to allow you to interact securely with our API from a client-side web application (though you should remember that you should never expose your secret API key in any public website's client-side code). JSON will be returned in all responses from the API, including errors (though if you're using API bindings, we will convert the response to the appropriate language-specific object).

Standard Parameters

projectid:
int The ID of the project.
dimensionidid:
int The ID of a specific dimension.
period:
string Possible values: day, week, month, year, range
date:
string 2014-05-01 or when period is a range: 2014-05-01,2014-05-20
sort:
string A valid key. For example: created
order:
string asc or desc
limit:
string Default: 1000
offset:
string Default: 0
q:
string A search query.


Operators:
= Equal
!= Not equal
>= Greater than equal to
> Greater than
<= Lower than equal to
< Lower than
== Exists
=== Size
-- Contains

Examples:
  • firstname=John|lastname!=Johnson|age>50
API Endpoint
https://api.datatrics.com/1.1/:method/:actionhttps://api.datatrics.com/1.1/:method/:actionhttps://api.datatrics.com/1.1/:method/:action
Libaries
Libraries are available for PHP & Node.JS.

$ curl https://api.datatrics.com/:method/:action \
               -d "variable1=value1&variable2=value2&variable3=value3" \require 'DatatricsAPI.php';
$api = new DatatricsAPI('1.1', 'YOUR APIKEY HERE');
$result = $api->:method->:action(array(
	'projectid' => :projectid
));
var DatatricsAPI = require('DatatricsAPI');
var Datatrics = new DatatricsAPI( '1.1', 'YOUR-API-TOKEN' )

Datatrics.api(:method, :action, {
  projectid:   :projectid,
  period:   'day',
  date:     'today'
}, (err, responseObject) {
    // your code
});

Authentication

All Datatrics API methods require authentication by using an API-key. API-keys and optional restrictions can be managed in our application.

https://api.datatrics.com/1.1/:method/:action?apikey=yourapikeyhttps://api.datatrics.com/1.1/:method/:action?apikey=yourapikey

Users

The User Object

User object

name required
string Username
password required
string Password
company optional
string Name of the company
country optional
string User's country
language optional
string User's language
Endpoint
 https://api.datatrics.com/1.1/Users/User Object
Call

                                $result = $api->Users->User Object(array(
name => :name
password => :password
company => :company
country => :country
language => :language
));
Response
null

Add a new user

Add a new user account to the Datatrics platform.

User object

name required
string Username
password required
string Password
company optional
string Name of the company
country optional
string User's country
language optional
string User's language
sendmail optional
string Send welcome email
sendpasswordmail optional
string Send password email
Endpoint
 https://api.datatrics.com/1.1/Users/addUser
Call

                                $result = $api->Users->addUser(array(
name => :name
password => :password
company => :company
country => :country
language => :language
sendmail => :sendmail
sendpasswordmail => :sendpasswordmail
));
Response
null

Get a user

Get user by login name.

User object

userLogin required
string Username
Endpoint
 https://api.datatrics.com/1.1/Users/getUser
Call

                                $result = $api->Users->getUser(array(
userLogin => :userLogin
));
Response
null

Update a user

Update properties of existing user.

User object

name required
string Username
password optional
string Password
email optional
string Email address
alias optional
string User's alias
profileimg optional
url User's profile image
Endpoint
 https://api.datatrics.com/1.1/Users/updateUser
Call

                                $result = $api->Users->updateUser(array(
name => :name
password => :password
email => :email
alias => :alias
profileimg => :profileimg
));
Response
null

Projects

The Project Object

Project object

projectid required
integer Project id
limits optional
Object Object containing the trics and channels limit
trics optional
integer Number of allowed trics
channels optional
integer Number of allowed trics
created optional
datetime Date and time of creation
updated optional
datetime Date and time when last updated
status optional
string Project status
mode optional
string Production or demo mode
name required
string Project name
main_url required
url Website url
ecommerce optional
integer E-commerce enabled 1 or 0
sitesearch optional
integer Site search enabled 1 or 0
sitesearch_keyword_parameters optional
string Site search keywords. Keywords are split with a comma
sitesearch_category_parameters optional
string Site search categories. Categories are split with a comma
timezone optional
string PHP timezone
currency optional
string Currency
excluded_ips optional
string Excluded ip's for the Datatrics Tracker. IP's are split with a comma
excluded_parameters optional
string Excluded parameters for the Datatrics Tracker. Parameters are split with a comma
excluded_user_agents optional
string Excluded user agents for the Datatrics Tracker. User agents are split with a comma
group optional
string Project group
type optional
string e.g. website, app, mobile
usage optional
Object Object containing the trics and channels usage
trics optional
integer Number of allowed trics
channels optional
integer Number of allowed trics
Endpoint
 https://api.datatrics.com/1.1/Projects/Project Object
Call

                                $result = $api->Projects->Project Object(array(
projectid => :projectid
limits => :limits
created => :created
updated => :updated
status => :status
mode => :mode
name => :name
main_url => :main_url
ecommerce => :ecommerce
sitesearch => :sitesearch
sitesearch_keyword_parameters => :sitesearch_keyword_parameters
sitesearch_category_parameters => :sitesearch_category_parameters
timezone => :timezone
currency => :currency
excluded_ips => :excluded_ips
excluded_parameters => :excluded_parameters
excluded_user_agents => :excluded_user_agents
group => :group
type => :type
usage => :usage
));
Response
null

Add a new Project

Add a new project to the Datatrics platform.

projectname required
string Name of the project
projecturl required
url Project website
userLogin required
string Users login name
pid optional
integer Product subscription id
timezone optional
string PHP Timezone
billingcycle optional
string Billing cycle options: yearly, quarterly, monthly, weekly and daily
sendemail optional
integer Send email enabled 1 or 0
coupon optional
string Discount coupon
demo optional
integer Demo enabled 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Projects/addProject
Call

                                $result = $api->Projects->addProject(array(
projectname => :projectname
projecturl => :projecturl
userLogin => :userLogin
pid => :pid
timezone => :timezone
billingcycle => :billingcycle
sendemail => :sendemail
coupon => :coupon
demo => :demo
));
Response
{
    "result": "success",
    "message": "ok"
}

Get Projects

Get a list of all projects.

Endpoint
 https://api.datatrics.com/1.1/Projects/getProjects
Call

                                $result = $api->Projects->getProjects(array(
));
Response
null

Get a Project

Get a specific project.

projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Projects/getProject
Call

                                $result = $api->Projects->getProject(array(
projectid => :projectid
));
Response
null

Update a project

Update a specific project.

projectid required
integer Project id
projectname optional
string Name of the project
projecturl optional
url Project website
ecommerce optional
integer E-commerce enabled 1 or 0
currency optional
string Currency
timezone optional
string PHP Timezone
Endpoint
 https://api.datatrics.com/1.1/POST
Call

                                $result = $api->Projects->updateProject(array(
projectid => :projectid
projectname => :projectname
projecturl => :projecturl
ecommerce => :ecommerce
currency => :currency
timezone => :timezone
));
Response
{
    "result": "success",
    "message": "ok"
}

Delete a Project

Delete a specific project.

projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Projects/deleteProject
Call

                                $result = $api->Projects->deleteProject(array(
projectid => :projectid
));
Response
{
    "result": "success",
    "message": "ok"
}

Upgrade a project

Upgrade the subscription of a specific project.

projectid required
integer Project id
pid required
integer Product subscription id
billingcycle optional
string Billing cycle options: yearly, quarterly, monthly, weekly and daily
Endpoint
 https://api.datatrics.com/1.1/POST
Call

                                $result = $api->Projects->upgradeProject(array(
projectid => :projectid
pid => :pid
billingcycle => :billingcycle
));
Response
{
    "result": "success",
    "message": "ok"
}

Add a user to a project

Add a user to a specific project.

projectid required
integer Project id
email required
string New users email address
access required
string New users access level admin or view
language optional
string New users language settings. Default is 'en'
Endpoint
 https://api.datatrics.com/1.1/Projects/addProjectUser
Call

                                $result = $api->Projects->addProjectUser(array(
projectid => :projectid
email => :email
access => :access
language => :language
));
Response
{
    "result": "success",
    "message": "ok"
}

Get project users

Get all the users of a specific project.

projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Projects/getTeam
Call

                                $result = $api->Projects->getTeam(array(
projectid => :projectid
));
Response
[
    {
        "login": "pepijn@datatrics.com",
        "alias": "Pepijn Yben",
        "email": "pepijn@datatrics.com",
        "profileimg": null,
        "access": "admin"
    }
]

Channels

The Channel Object

Channel object

channelid required
integer Channel id
channel required
string Channel type
projectid required
integer Project id
channelname required
string Name of the channel
period required
string Update once every week, day or hour
settings required
Object Object containing the settings for that specific channel. For example oauth tokens.
status optional
int Channel status 1 or 0
created optional
datetime Date and time of creation
updated optional
datetime Date and time when last updated
Endpoint
 https://api.datatrics.com/1.1/Channels/Channel Object
Call

                                $result = $api->Channels->Channel Object(array(
channelid => :channelid
channel => :channel
projectid => :projectid
channelname => :channelname
period => :period
settings => :settings
status => :status
created => :created
updated => :updated
));
Response
null

Add a Channel

Add a channel to the Datatrics platform.

channelid required
integer Channel id
channel required
string Channel type
projectid required
integer Project id
channelname required
string Name of the channel
period required
string Update once every week, day or hour
settings required
Object Object containing the settings for that specific channel. For example oauth tokens.
status optional
int Channel status 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Channels/addChannel
Call

                                $result = $api->Channels->addChannel(array(
channelid => :channelid
channel => :channel
projectid => :projectid
channelname => :channelname
period => :period
settings => :settings
status => :status
));
Response
{
    "result": "success",
    "message": "ok"
}

Get Channels

Get all channels

projectid optional
integer Project id
channel optional
string Channel type
Endpoint
 https://api.datatrics.com/1.1/Channels/getChannels
Call

                                $result = $api->Channels->getChannels(array(
projectid => :projectid
channel => :channel
));
Response
null

Get Channel

projectid optional
integer Project id
channel required
string Channel type
Endpoint
 https://api.datatrics.com/1.1/Channels/getChannel
Call

                                $result = $api->Channels->getChannel(array(
projectid => :projectid
channel => :channel
));
Response
{
    "channel": "Twitter",
    "name": "Twitter",
    "type": "interaction",
    "short_description": "Twitter is a social network used by millions of people, and thousands more are signing up every day to send short messages to groups of friends.",
    "description": "Connect with friends and other fascinating people. Get updates about the things which you are intested. And see how events turn out in real team, from any angle.",
    "use": "",
    "tags": "",
    "third_party": "1",
    "active": "1",
    "popularity": "12",
    "featured": "1",
    "created": "0000-00-00 00:00:00",
    "settings": null
}

Update a channel

Update a specific channel

channelid required
integer Channel id
projectid required
integer Project id
channelname optional
string Name of the channel
period optional
string Update once every week, day or hour
settings optional
Object Object containing the settings for that specific channel. For example oauth tokens.
status optional
int Channel status 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Channels/updateChannel
Call

                                $result = $api->Channels->updateChannel(array(
channelid => :channelid
projectid => :projectid
channelname => :channelname
period => :period
settings => :settings
status => :status
));
Response
{
    "result": "success",
    "message": "ok"
}

Delete a channel

Delete a specific channel.

channelid required
integer Channel id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Channels/deleteChannel
Call

                                $result = $api->Channels->deleteChannel(array(
channelid => :channelid
projectid => :projectid
));
Response
{
    "result": "success",
    "message": "ok"
}

Trics

The Tric Object

Tric object

tricid required
integer Tric id
projectid required
integer Project id
settings optional
Object Object containing the settings for the tric
status optional
string Tric status 1 or 0
created optional
datetime Date and time of creation
updated optional
datetime Date and time when last updated
namespace optional
string Tric namespace
type optional
enum To do
config optional
string To do
icon optional
string Containing icon class
short_description optional
string Trics short description
features optional
string To do
description optional
string Trics description
categories optional
string Trics categories. Categories are split with a comma
images optional
url Trics image
video optional
url Trics video
tags optional
string Tags for the tric. Tags are split with a comma
price optional
double The price of the tric
activatable optional
int Is the tric enabled to activate. Expects 1 or 0
post-activation optional
string To do
public optional
string To do
popularity optional
int Popularity of the tric
featured optional
int Feature state of tric. Expects 1 or 0
developerid optional
int Id of the developer who created the tric.
requirements optional
string To do
integrations optional
string To do
Endpoint
 https://api.datatrics.com/1.1/Trics/Tric Object
Call

                                $result = $api->Trics->Tric Object(array(
tricid => :tricid
projectid => :projectid
settings => :settings
status => :status
created => :created
updated => :updated
namespace => :namespace
type => :type
config => :config
icon => :icon
short_description => :short_description
features => :features
description => :description
categories => :categories
images => :images
video => :video
tags => :tags
price => :price
activatable => :activatable
post-activation => :post-activation
public => :public
popularity => :popularity
featured => :featured
developerid => :developerid
requirements => :requirements
integrations => :integrations
));
Response
{
    "tricid": "1209018481507385",
    "projectid": "xxxxxx",
    "settings": [],
    "status": "1",
    "created": "2015-03-08 15:51:23",
    "updated": "2015-06-14 00:00:54",
    "namespace": "buying-phase",
    "version": "1",
    "name": "Buying Phase",
    "type": "custom",
    "config": null,
    "icon": "fa fa-recycle",
    "short_description": "",
    "features": "",
    "description": "",
    "categories": "sales",
    "images": "",
    "video": "",
    "tags": "",
    "price": "",
    "activatable": "1",
    "post-activation": "",
    "public": "public",
    "popularity": "0",
    "featured": "0",
    "developerid": "2147483647",
    "requirements": "",
    "integrations": ""
}

Add a Tric

Add a new tric to the Datatrics platform.

tricid required
integer Tric id
projectid required
integer Project id
settings optional
Object Object containing the settings for the tric
status optional
string Tric status 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Trics/addTrics
Call

                                $result = $api->Trics->addTrics(array(
tricid => :tricid
projectid => :projectid
settings => :settings
status => :status
));
Response
{
    "result": "success",
    "message": "ok"
}

Get all Trics

Get a list of trics.

projectid optional
integer Project id
category optional
string Tric category
Endpoint
 https://api.datatrics.com/1.1/Trics/getTrics
Call

                                $result = $api->Trics->getTrics(array(
projectid => :projectid
category => :category
));
Response
[
    {
        "tricid": "xxxxxx",
        "projectid": "xxxxxx",
        "settings": [],
        "status": "1",
        "created": "2015-03-08 15:51:23",
        "updated": "2015-06-14 00:00:54",
        "namespace": "buying-phase",
        "version": "1",
        "name": "Buying Phase",
        "type": "custom",
        "config": null,
        "icon": "fa fa-recycle",
        "short_description": "",
        "features": "",
        "description": "",
        "categories": "sales",
        "images": "",
        "video": "",
        "tags": "",
        "price": "",
        "activatable": "1",
        "post-activation": "",
        "public": "public",
        "popularity": "0",
        "featured": "0",
        "developerid": "xxxxxx",
        "requirements": "",
        "integrations": ""
    }
]

Get a Tric

Get a specific tric.

tricid optional
integer Tric id
projectid optional
integer Project id
namespace optional
string Tric namespace
Endpoint
 https://api.datatrics.com/1.1/Trics/getTric
Call

                                $result = $api->Trics->getTric(array(
tricid => :tricid
projectid => :projectid
namespace => :namespace
));
Response
{
    "tricid": "xxxxxx",
    "projectid": "xxxxxx",
    "settings": [],
    "status": "1",
    "created": "2015-03-08 15:51:23",
    "updated": "2015-06-14 00:00:54",
    "namespace": "buying-phase",
    "version": "1",
    "name": "Buying Phase",
    "type": "custom",
    "config": null,
    "icon": "fa fa-recycle",
    "short_description": "",
    "features": "",
    "description": "",
    "categories": "sales",
    "images": "",
    "video": "",
    "tags": "",
    "price": "",
    "activatable": "1",
    "post-activation": "",
    "public": "public",
    "popularity": "0",
    "featured": "0",
    "developerid": "xxxxxx",
    "requirements": "",
    "integrations": ""
}

Update a Tric

Update a specific tric from a specific project.

tricid required
integer Tric id
projectid required
integer Project id
settings optional
Object Object containing the settings for the tric
status optional
string Tric status 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Trics/updateTric
Call

                                $result = $api->Trics->updateTric(array(
tricid => :tricid
projectid => :projectid
settings => :settings
status => :status
));
Response
{
    "result": "success",
    "message": "ok"
}

Delete a Tric

Delete a specific tric from a specific project.

tricid required
integer Tric id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Trics/deleteTric
Call

                                $result = $api->Trics->deleteTric(array(
tricid => :tricid
projectid => :projectid
));
Response
{
    "result": "success",
    "message": "ok"
}

Do a Tric (endpoint)

tricid required
integer Tric id
projectid required
integer Project id
endpoint required
string To do?
Endpoint
 https://api.datatrics.com/1.1/Trics/doTric
Call

                                $result = $api->Trics->doTric(array(
tricid => :tricid
projectid => :projectid
endpoint => :endpoint
));
Response
{
    "result": "success",
    "message": "ok"
}

Next Best Action

The Next Best Action Object

Next Best Action object

nextbestactionid optional
integer Next Best Action id
created optional
datetime Date and time of creation
date optional
date Date for execution
status optional
string Next Best Action status; suggested, scheduled, removed or finished
tric optional
string Tric name
channel optional
string The Next Best Actions channel
author optional
string Author of the Next Best Action
nextbestaction optional
string Description of the Next Best Action
nextbestaction_html optional
string Html description of the Next Best Action
who optional
Object Object containing the who properties for the Next Best Action
segmentid optional
integer Segment id
profileid optional
integer Profile id
source optional
string Profile source
label optional
string Label for the who object
what optional
Object Object containing the what properties for the Next Best Action
categoryid optional
integer Category id
itemid optional
integer Item id
keyword optional
string Keywords for the items
source optional
string Profile source
label optional
string Label for the who object
when optional
Object Object containing the when properties for the Next Best Action
date optional
date Date of execution
hourofday optional
integer Hour of execution
dayofweek optional
string Day of the week of execution
dayofmonth optional
integer Day of the month of execution
temp optional
integer What temperature it must be for it to execute
label optional
string Label for the when object
how optional
Object Object containing the how properties for the Next Best Action
channel optional
string The name of the channel
label optional
string Label for the how object
results optional
Object Object containing the expected results for the Next Best Action
potential optional
integer Potential of the Next Best Action
opportunity optional
integer Opportunity of the Next Best Action
engagement optional
integer Engagement of the Next Best Action
Endpoint
 https://api.datatrics.com/1.1/NextBestActions/Next Best Action Object
Call

                                $result = $api->NextBestActions->Next Best Action Object(array(
nextbestactionid => :nextbestactionid
created => :created
date => :date
status => :status
tric => :tric
channel => :channel
author => :author
nextbestaction => :nextbestaction
nextbestaction_html => :nextbestaction_html
who => :who
what => :what
when => :when
how => :how
results => :results
));
Response
{
    "who": {
        "label": "profiles with customer type \"Single-minded\""
    },
    "what": {
        "label": "Acryl kussens"
    },
    "when": {
        "hourofday": 17,
        "dayofweek": "Monday",
        "label": "Monday around 17 o'clock"
    },
    "how": {
        "label": "mail"
    },
    "result": {
        "potential": 100,
        "opportunity": 3800,
        "engagement": 45
    },
    "status": "suggested",
    "tric": "Increase Sales",
    "channel": "Mail",
    "author": "Datatrics",
    "date": "2015-08-24",
    "nextbestaction": "Contact profiles with customer type \"Single-minded\" on Monday around 17 o'clock through mail with content about Acryl kussens",
    "nextbestaction_html": "Contact profiles with customer type \"Single-minded\"<\/span> on Monday around 17 o'clock<\/span> through mail<\/span> with content about Acryl kussens<\/span>",
    "objecttype": "nextbestaction",
    "nextbestactionid": "143980222722231",
    "created": "2015-08-17 09:21:12"
}

Add a new Next Best Action

Add a new Next Best Action to the Datatrics platform.

projectid required
integer Project ID
nextbestaction required
object See the "Next Best Action object"
Endpoint
 https://api.datatrics.com/1.1/NextBestActions/addNextBestAction
Call

                                $result = $api->NextBestActions->addNextBestAction(array(
projectid => :projectid
nextbestaction => :nextbestaction
));
Response
{
    "result": "success",
    "message": "ok"
}

Get Next Best Actions

Get a list of all Next Best Actions.

projectid required
integer Project id
period optional
string Period enum; week, day or hour
limit optional
int Limit of items returned. Default is 500
offset optional
int Query offset
sort optional
string Sort items by fields. Fore example date; default potential
order optional
string Sorting order ASC or DESC
onlyids optional
boolean Return only ids true or false
q optional
object Search query, see: Search Queries
Endpoint
 https://api.datatrics.com/1.1/NextBestActions/getNextBestActions
Call

                                $result = $api->NextBestActions->getNextBestActions(array(
projectid => :projectid
period => :period
limit => :limit
offset => :offset
sort => :sort
order => :order
onlyids => :onlyids
q => :q
));
Response
[
    {
        "who": {
            "label": "profiles with customer type \"Single-minded\""
        },
        "what": {
            "label": "Acryl kussens"
        },
        "when": {
            "hourofday": 17,
            "dayofweek": "Monday",
            "label": "Monday around 17 o'clock"
        },
        "how": {
            "label": "mail"
        },
        "result": {
            "potential": 100,
            "opportunity": 3800,
            "engagement": 45
        },
        "status": "suggested",
        "tric": "Increase Sales",
        "channel": "Mail",
        "author": "Datatrics",
        "date": "2015-08-24",
        "nextbestaction": "Contact profiles with customer type \"Single-minded\" on Monday around 17 o'clock through mail with content about Acryl kussens",
        "nextbestaction_html": "Contact profiles with customer type \"Single-minded\"<\/span> on Monday around 17 o'clock<\/span> through mail<\/span> with content about Acryl kussens<\/span>",
        "objecttype": "nextbestaction",
        "nextbestactionid": "143980222722231",
        "created": "2015-08-17 09:21:12"
    }
]

Get a Next Best Action

Get a specific Next Best Action.

projectid required
integer Project id
nextbestactionid required
integer Next Best Action id
Endpoint
 https://api.datatrics.com/1.1/NextBestActions/getNextBestAction
Call

                                $result = $api->NextBestActions->getNextBestAction(array(
projectid => :projectid
nextbestactionid => :nextbestactionid
));
Response
{
    "who": {
        "label": "profiles with customer type \"Single-minded\""
    },
    "what": {
        "label": "Acryl kussens"
    },
    "when": {
        "hourofday": 17,
        "dayofweek": "Monday",
        "label": "Monday around 17 o'clock"
    },
    "how": {
        "label": "mail"
    },
    "result": {
        "potential": 100,
        "opportunity": 3800,
        "engagement": 45
    },
    "status": "suggested",
    "tric": "Increase Sales",
    "channel": "Mail",
    "author": "Datatrics",
    "date": "2015-08-24",
    "nextbestaction": "Contact profiles with customer type \"Single-minded\" on Monday around 17 o'clock through mail with content about Acryl kussens",
    "nextbestaction_html": "Contact profiles with customer type \"Single-minded\"<\/span> on Monday around 17 o'clock<\/span> through mail<\/span> with content about Acryl kussens<\/span>",
    "objecttype": "nextbestaction",
    "nextbestactionid": "143980222722231",
    "created": "2015-08-17 09:21:12"
}

Update a Next Best Action

Update a specific Next Best Action.

projectid required
integer Project id
nextbestactionid required
integer Next Best Action id
nextbestaction required
object See the "Next Best Action object"
Endpoint
 https://api.datatrics.com/1.1/POST
Call

                                $result = $api->NextBestActions->updateNextBestAction(array(
projectid => :projectid
nextbestactionid => :nextbestactionid
nextbestaction => :nextbestaction
));
Response
{
    "result": "success",
    "message": "ok"
}

Delete a Next Best Action

Delete a specific Next Best Action.

projectid required
integer Project id
nextbestactionid required
integer Next Best Action id
Endpoint
 https://api.datatrics.com/1.1/NextBestActions/removeNextBestAction
Call

                                $result = $api->NextBestActions->removeNextBestAction(array(
projectid => :projectid
nextbestactionid => :nextbestactionid
));
Response
{
    "result": "success",
    "message": "ok"
}

Assign a Next Best Action

Assign a Next Best Action to a user.

projectid required
integer Project id
nextbestactionid required
integer Next Best Action id
users required
array Array with the logins of users the Next Best Action should be assigned to
Endpoint
 https://api.datatrics.com/1.1/POST
Call

                                $result = $api->NextBestActions->assignNextBestAction(array(
projectid => :projectid
nextbestactionid => :nextbestactionid
users => :users
));
Response
{
    "result": "success",
    "message": "ok"
}

Schedule a Next Best Action

Schedule a specific Next Best Action.

projectid required
integer Project id
nextbestactionid required
integer Next Best Action id
Endpoint
 https://api.datatrics.com/1.1/NextBestActions/scheduleNextBestAction
Call

                                $result = $api->NextBestActions->scheduleNextBestAction(array(
projectid => :projectid
nextbestactionid => :nextbestactionid
));
Response
{
    "result": "success",
    "message": "ok"
}

Buckets

Standard Buckets

behavior:
Contains all user events.
audience:
Contains all profiles & segments.
catalog:
Contains all categories and sales items.
conversions:
Contains all conversions.
scorecards:
Contains all scorecards.
interactions:
Contains all interaction.

The Bucket Object

Bucket object

name required
string Bucket name
Endpoint
 https://api.datatrics.com/1.1/Buckets/Bucket Object
Call

                                $result = $api->Buckets->Bucket Object(array(
name => :name
));
Response
{
    "name": "audience"
}

Create a Bucket

Create a new bucket.

projectid required
integer Project id
bucket required
string Name of the new bucket
Endpoint
 https://api.datatrics.com/1.1/Buckets/createBucket
Call

                                $result = $api->Buckets->createBucket(array(
projectid => :projectid
bucket => :bucket
));
Response
{
    "result": "success",
    "message": "ok"
}

Get all Buckets

Get all buckets of specific project.

projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Buckets/getBuckets
Call

                                $result = $api->Buckets->getBuckets(array(
projectid => :projectid
));
Response
[
    {
        "name": "audience"
    },
    {
        "name": "scorecards"
    }
]

Get a Bucket

Get stats from a specific bucket.

projectid required
integer Project id
bucket required
string Name of the new bucket
Endpoint
 https://api.datatrics.com/1.1/Buckets/getBucket
Call

                                $result = $api->Buckets->getBucket(array(
projectid => :projectid
bucket => :bucket
));
Response
{
    "ns": "project_255062.scorecards",
    "count": 0,
    "size": 0,
    "storageSize": 8192,
    "numExtents": 1,
    "nindexes": 2,
    "lastExtentSize": 8192,
    "paddingFactor": 1,
    "systemFlags": 1,
    "userFlags": 0,
    "totalIndexSize": 16352,
    "indexSizes": {
        "_id_": 8176,
        "profileid_1_source_1_scorecardtype_1_updated_-1": 8176
    },
    "ok": 1
}

Delete a Bucket

Delete a specific bucket from a project.

projectid required
integer Project id
bucket required
string Name of the new bucket
Endpoint
 https://api.datatrics.com/1.1/Buckets/deleteBucket
Call

                                $result = $api->Buckets->deleteBucket(array(
projectid => :projectid
bucket => :bucket
));
Response
{
    "result": "success",
    "message": "ok"
}

Add a Object

Add a object to a specific bucket.

projectid required
integer Project id
bucket required
string Name of the new bucket
object required
object Object to be placed in the bucket
Endpoint
 https://api.datatrics.com/1.1/Buckets/addObject
Call

                                $result = $api->Buckets->addObject(array(
projectid => :projectid
bucket => :bucket
object => :object
));
Response
{
    "result": "success",
    "message": "ok"
}

Get Objects

Get all objects from a specific bucket.

projectid required
integer Project id
bucket required
string Name of the new bucket
q optional
object Object with query parameters
limit optional
integer Limit of results
offset optional
integer Offset for query
sort optional
string Sorting order of results; ASC or DESC
fields optional
array Array of requested fields
Endpoint
 https://api.datatrics.com/1.1/Buckets/getObjects
Call

                                $result = $api->Buckets->getObjects(array(
projectid => :projectid
bucket => :bucket
q => :q
limit => :limit
offset => :offset
sort => :sort
fields => :fields
));
Response
null

Get a Object

Get a specific object from a bucket.

projectid required
integer Project id
bucket required
string Name of the new bucket
objectid required
integer Object id
q optional
object Object with query parameters
Endpoint
 https://api.datatrics.com/1.1/Buckets/getObject
Call

                                $result = $api->Buckets->getObject(array(
projectid => :projectid
bucket => :bucket
objectid => :objectid
q => :q
));
Response
null

Scorecards

Set a Scorecard

Add data to a new or existing scorecard.

Endpoint
 https://api.datatrics.com/1.1/Scorecards/setScorecard
Call

                                $result = $api->Scorecards->setScorecard(array(
));
Response
null

Get a Scorecard

Get a scorecard by the scorecardkey

projectid required
integer Project id
scorecardkey required
string Scorecard key
Endpoint
 https://api.datatrics.com/1.1/Scorecards/getScorecard
Call

                                $result = $api->Scorecards->getScorecard(array(
projectid => :projectid
scorecardkey => :scorecardkey
));
Response
null

Get Scorecards

Get all scorecards per project id.

projectid required
integer Project id
scorecardtype optional
string Scorecard type
period optional
string Period enum; week, day or hour
date optional
datetime Date of scorecard; 2015-06-23
limit optional
int Limit of scorecards returned. Default is 1000
offset optional
int Query offset
sort optional
string Sort scorecards by fields. Fore example date
order optional
string Sorting order ASC or DESC
q optional
object See: Search Queries
Endpoint
 https://api.datatrics.com/1.1/Scorecards/getScorecards
Call

                                $result = $api->Scorecards->getScorecards(array(
projectid => :projectid
scorecardtype => :scorecardtype
period => :period
date => :date
limit => :limit
offset => :offset
sort => :sort
order => :order
q => :q
));
Response
null

Audience

The Profile Object

Profile object

firstname optional
string Customers first name
lastname optional
string Customers last name
name optional
string Customers full name
email optional
string Customers email address
created optional
datetime Date and time of creation
updated optional
datetime Date and time when last updated
verified optional
integer If user is verified. Expects 1 or 0
tags optional
string Customer tags. Tags are separated with a comma
status optional
string Customers status. Expects 'active' or 'not active'
company optional
string Customers company
address optional
string Customers address
city optional
string Customers city
zip optional
string Customers zip code
phone optional
string Customers phone number
region optional
string Customers region
accepts_marketing optional
integer If customer accepts newsletters. Expects 1 or 0
source required
string The source of this customer
profileid required
integer Customers id
objecttype optional
string Object type
sales optional
integer To do
potential optional
integer To do
engagement optional
integer To do
opportunity optional
integer To do
similarity optional
integer To do
time optional
integer To do
day optional
string To do
products optional
array Array containing all suggested products To do
categories optional
array Array containing all suggested categories To do
Endpoint
 https://api.datatrics.com/1.1/Audience/Profile Object
Call

                                $result = $api->Audience->Profile Object(array(
firstname => :firstname
lastname => :lastname
name => :name
email => :email
created => :created
updated => :updated
verified => :verified
tags => :tags
status => :status
company => :company
address => :address
city => :city
zip => :zip
phone => :phone
region => :region
accepts_marketing => :accepts_marketing
source => :source
profileid => :profileid
objecttype => :objecttype
sales => :sales
potential => :potential
engagement => :engagement
opportunity => :opportunity
similarity => :similarity
time => :time
day => :day
products => :products
categories => :categories
));
Response
null

Add a Profile

Add a new profile to the Datatrics platform.

projectid required
integer Project id
profileid required
integer Profile id
source required
string The source of this profile
profile required
Object See "The Profile Object"
Endpoint
 https://api.datatrics.com/1.1/Audience/addProfile
Call

                                $result = $api->Audience->addProfile(array(
projectid => :projectid
profileid => :profileid
source => :source
profile => :profile
));
Response
{
    "result": "success",
    "message": "ok"
}

Get all Profiles

Get all profiles from a specific project.

projectid required
integer Project id
limit optional
int Limit of profiles returned. Default is 1000
offset optional
int Query offset
sort optional
string Sort profiles by fields. Fore example date
order optional
string Sorting order ASC or DESC
q optional
object Search query, see: Search Queries
Endpoint
 https://api.datatrics.com/1.1/Audience/getProfiles
Call

                                $result = $api->Audience->getProfiles(array(
projectid => :projectid
limit => :limit
offset => :offset
sort => :sort
order => :order
q => :q
));
Response
null

Get a Profile

Get a specific profile.

projectid required
integer Project id
profileid required
integer Profile id
source required
string The source of this profile
only_extended optional
string Only return fields added by Datatrics
Endpoint
 https://api.datatrics.com/1.1/Audience/getProfile
Call

                                $result = $api->Audience->getProfile(array(
projectid => :projectid
profileid => :profileid
source => :source
only_extended => :only_extended
));
Response
null

Update a profile

Update a specific profile.

projectid required
integer Project id
profileid required
integer Profile id
source required
string The source of this profile
profile required
Object See "The Profile Object"
Endpoint
 https://api.datatrics.com/1.1/Audience/updateProfile
Call

                                $result = $api->Audience->updateProfile(array(
projectid => :projectid
profileid => :profileid
source => :source
profile => :profile
));
Response
{
    "result": "success",
    "message": "ok"
}

Delete a Profile

Delete a specific profile.

projectid required
integer Project id
profileid required
integer Profile id
source required
string The source of this profile
Endpoint
 https://api.datatrics.com/1.1/Audience/deleteProfile
Call

                                $result = $api->Audience->deleteProfile(array(
projectid => :projectid
profileid => :profileid
source => :source
));
Response
{
    "result": "success",
    "message": "ok"
}

Behavior

The Event Object

Event object

Endpoint
 https://api.datatrics.com/1.1/Behavior/Event Object
Call

                                $result = $api->Behavior->Event Object(array(
));
Response
null

Add an Event

Add a new event to the Datatrics platform.

projectid required
integer Project id
eventid required
integer Interaction id
source required
string The source of this interaction
event required
Object See "The Event Object"
Endpoint
 https://api.datatrics.com/1.1/Behavior/addEvent
Call

                                $result = $api->Behavior->addEvent(array(
projectid => :projectid
eventid => :eventid
source => :source
event => :event
));
Response
{
    "result": "success",
    "message": "ok"
}

Update an Event

Update an specific event.

projectid required
integer Project id
eventid required
integer Event id
source required
string The source of this interaction
event required
Object See "The Event Object"
Endpoint
 https://api.datatrics.com/1.1/Behavior/updateEvent
Call

                                $result = $api->Behavior->updateEvent(array(
projectid => :projectid
eventid => :eventid
source => :source
event => :event
));
Response
{
    "result": "success",
    "message": "ok"
}

Get Events

Get all events of a specific project.

projectid required
integer Project id
limit optional
int Limit of events returned. Default is 1000
offset optional
int Query offset
sort optional
string Sort events by fields. Fore example date
order optional
string Sorting order ASC or DESC
q optional
object Search query, see: Search Queries
Endpoint
 https://api.datatrics.com/1.1/Behavior/getEvents
Call

                                $result = $api->Behavior->getEvents(array(
projectid => :projectid
limit => :limit
offset => :offset
sort => :sort
order => :order
q => :q
));
Response
null

Get a Event

Get a specific event.

projectid required
integer Project id
eventid required
integer Event id
source required
string The source of this profile
Endpoint
 https://api.datatrics.com/1.1/Behavior/getEvent
Call

                                $result = $api->Behavior->getEvent(array(
projectid => :projectid
eventid => :eventid
source => :source
));
Response
null

Interaction

The Interaction Object

Interaction object

Endpoint
 https://api.datatrics.com/1.1/Interaction/Interaction Object
Call

                                $result = $api->Interaction->Interaction Object(array(
));
Response
null

Add an interaction

Add a new interaction to the Datatrics platform.

projectid required
integer Project id
interactionid required
integer Interaction id
source required
string The source of this interaction
interaction required
Object See "The Interaction Object"
Endpoint
 https://api.datatrics.com/1.1/Interaction/addInteraction
Call

                                $result = $api->Interaction->addInteraction(array(
projectid => :projectid
interactionid => :interactionid
source => :source
interaction => :interaction
));
Response
{
    "result": "success",
    "message": "ok"
}

Get an interaction

Get aa specific interaction.

projectid required
integer Project id
profileid required
integer Profile id
source required
string The source of this profile
Endpoint
 https://api.datatrics.com/1.1/Interaction/getInteraction
Call

                                $result = $api->Interaction->getInteraction(array(
projectid => :projectid
profileid => :profileid
source => :source
));
Response
null

Get interactions

Get all interactions

projectid required
integer Project id
limit optional
int Limit of interactions returned. Default is 1000
offset optional
int Query offset
sort optional
string Sort interactions by fields. Fore example date
order optional
string Sorting order ASC or DESC
q optional
object See: Search Queries
Endpoint
 https://api.datatrics.com/1.1/Interaction/getInteractions
Call

                                $result = $api->Interaction->getInteractions(array(
projectid => :projectid
limit => :limit
offset => :offset
sort => :sort
order => :order
q => :q
));
Response
null

Catalog

The Item Object

Item object

sku optional
string Product sku code
name optional
string Product name
categories optional
array Product categories
price optional
double Product price
description optional
string Product description
short_description optional
string Product short description
status optional
integer Product status. Expects 1 or 0
weight optional
double Product weight
url optional
string Product url
objecttype optional
string Object type
itemid required
integer Product id
source required
string The source of this customer
sales optional
integer To do
potential optional
integer To do
engagement optional
integer To do
opportunity optional
integer To do
similarity optional
integer To do
Endpoint
 https://api.datatrics.com/1.1/Catalog/Item Object
Call

                                $result = $api->Catalog->Item Object(array(
sku => :sku
name => :name
categories => :categories
price => :price
description => :description
short_description => :short_description
status => :status
weight => :weight
url => :url
objecttype => :objecttype
itemid => :itemid
source => :source
sales => :sales
potential => :potential
engagement => :engagement
opportunity => :opportunity
similarity => :similarity
));
Response
{
    "sku": "Product 1",
    "name": "Product 1",
    "categories": [
        {
            "categoryid": "3",
            "name": "Kleding"
        }
    ],
    "price": "100.0000",
    "description": "Product 1",
    "short_description": "Product 1",
    "status": "1",
    "weight": "100.0000",
    "url": "product-1",
    "objecttype": "item",
    "itemid": "1",
    "source": "Magento",
    "sales": 873,
    "potential": 56,
    "engagement": 73,
    "opportunity": 760,
    "similarity": 61
}

Add a Item

Add a new item to the Datatrics platform.

projectid required
integer Project id
itemid required
integer Item id
source required
string The source of this item
item required
Object See "The Item Object"
Endpoint
 https://api.datatrics.com/1.1/Catalog/addItem
Call

                                $result = $api->Catalog->addItem(array(
projectid => :projectid
itemid => :itemid
source => :source
item => :item
));
Response
{
    "result": "success",
    "message": "ok"
}

Get Item

Get a specific item.

projectid required
integer Project id
itemid required
integer Item id
source required
string The source of this item
only_extended optional
string Only return fields added by Datatrics
Endpoint
 https://api.datatrics.com/1.1/Catalog/getItem
Call

                                $result = $api->Catalog->getItem(array(
projectid => :projectid
itemid => :itemid
source => :source
only_extended => :only_extended
));
Response
{
    "sku": "Product 1",
    "name": "Product 1",
    "categories": [
        {
            "categoryid": "3",
            "name": "Kleding"
        }
    ],
    "price": "100.0000",
    "description": "Product 1",
    "short_description": "Product 1",
    "status": "1",
    "weight": "100.0000",
    "url": "product-1",
    "objecttype": "item",
    "itemid": "1",
    "source": "Magento",
    "sales": 873,
    "potential": 56,
    "engagement": 73,
    "opportunity": 760,
    "similarity": 61
}

Get Items

Get all items of a specific project.

projectid required
integer Project id
limit optional
int Limit of items returned. Default is 1000
offset optional
int Query offset
sort optional
string Sort items by fields. Fore example date
order optional
string Sorting order ASC or DESC
q optional
object Search query, see: Search Queries
Endpoint
 https://api.datatrics.com/1.1/Catalog/getItems
Call

                                $result = $api->Catalog->getItems(array(
projectid => :projectid
limit => :limit
offset => :offset
sort => :sort
order => :order
q => :q
));
Response
[
    {
        "sku": "Product 1",
        "name": "Product 1",
        "categories": [
            {
                "categoryid": "3",
                "name": "Kleding"
            }
        ],
        "price": "100.0000",
        "description": "Product 1",
        "short_description": "Product 1",
        "status": "1",
        "weight": "100.0000",
        "url": "product-1",
        "objecttype": "item",
        "itemid": "1",
        "source": "Magento",
        "sales": 873,
        "potential": 56,
        "engagement": 73,
        "opportunity": 760,
        "similarity": 61
    }
]

The Category Object

Category object

categoryid required
integer Category id
name optional
string Category name
Endpoint
 https://api.datatrics.com/1.1/Catalog/Category Object
Call

                                $result = $api->Catalog->Category Object(array(
categoryid => :categoryid
name => :name
));
Response
{
    "categoryid": "3",
    "name": "Kleding"
}

Add a Category

Add a new category to the Datatrics platform.

projectid required
integer Project id
categoryid required
integer Category id
source required
string The source of this category
category required
Object See "The Category Object"
Endpoint
 https://api.datatrics.com/1.1/Catalog/addCategory
Call

                                $result = $api->Catalog->addCategory(array(
projectid => :projectid
categoryid => :categoryid
source => :source
category => :category
));
Response
{
    "result": "success",
    "message": "ok"
}

Get a Category

Get a specific category.

projectid required
integer Project id
categoryid required
integer Category id
source required
string The source of this category
Endpoint
 https://api.datatrics.com/1.1/Catalog/getCategory
Call

                                $result = $api->Catalog->getCategory(array(
projectid => :projectid
categoryid => :categoryid
source => :source
));
Response
{
    "categoryid": "3",
    "name": "Kleding"
}

Get Categories

Get all categories of a project.

projectid required
integer Project id
limit optional
int Limit of category returned. Default is 1000
offset optional
int Query offset
sort optional
string Sort category by fields. Fore example date
order optional
string Sorting order ASC or DESC
q optional
object Search query, see: Search Queries
Endpoint
 https://api.datatrics.com/1.1/Catalog/getCatagories
Call

                                $result = $api->Catalog->getCatagories(array(
projectid => :projectid
limit => :limit
offset => :offset
sort => :sort
order => :order
q => :q
));
Response
[
    {
        "categoryid": "3",
        "name": "Kleding"
    }
]

Sales

The Conversion Object

Conversion object

created optional
datetime Date and time of creation
discount optional
double Conversion discount
shipping optional
double Conversion shipping costs
tax optional
double Conversion tax
currency optional
string Conversion currency
subtotal optional
double Conversion subtotal
ip optional
string Customer ip
store optional
string Store name
status optional
string Conversion status
profileid optional
integer Customer id
items optional
array Array containing item objects. See "The Item Object"
conversionid required
integer Conversion id
source required
string The source of the conversion
objecttype optional
string Object type
Endpoint
 https://api.datatrics.com/1.1/Sales/Conversion Object
Call

                                $result = $api->Sales->Conversion Object(array(
created => :created
discount => :discount
shipping => :shipping
tax => :tax
currency => :currency
subtotal => :subtotal
ip => :ip
store => :store
status => :status
profileid => :profileid
items => :items
conversionid => :conversionid
source => :source
objecttype => :objecttype
));
Response
{
    "created": "2015-06-25 10:01:48",
    "discount": "0.0000",
    "shipping": "0.0000",
    "tax": "10.3959",
    "currency": "EUR",
    "subtotal": "49.5041",
    "ip": "134.23.91.13",
    "store": "DemoStore",
    "status": "pending",
    "profileid": "21341",
    "items": [
        {
            "itemid": "151427",
            "sku": "8718138817300",
            "quantity": "1.0000",
            "name": "Shirt Large Blue",
            "price": "24.7521",
            "total": "24.7521"
        },
        {
            "itemid": "151428",
            "sku": "8718588321550",
            "quantity": "1.0000",
            "name": "Shirt Large Red",
            "price": "24.7520",
            "total": "24.7520"
        }
    ],
    "conversionid": "102346347",
    "source": "Magento",
    "objecttype": "conversion"
}

Add Conversion

projectid required
integer Project id
conversionid required
integer Conversion id
source required
string The source of this conversion
interaction required
Object See "The Conversion Object"
Endpoint
 https://api.datatrics.com/1.1/Sales/addConversion
Call

                                $result = $api->Sales->addConversion(array(
projectid => :projectid
conversionid => :conversionid
source => :source
interaction => :interaction
));
Response
null

Get Conversion

Get a specific conversion.

projectid required
integer Project id
conversionid required
integer Conversion id
source required
string The source of this conversion
Endpoint
 https://api.datatrics.com/1.1/Sales/getConversion
Call

                                $result = $api->Sales->getConversion(array(
projectid => :projectid
conversionid => :conversionid
source => :source
));
Response
{
    "created": "2015-06-25 10:01:48",
    "discount": "0.0000",
    "shipping": "0.0000",
    "tax": "10.3959",
    "currency": "EUR",
    "subtotal": "49.5041",
    "ip": "134.23.91.13",
    "store": "DemoStore",
    "status": "pending",
    "profileid": "21341",
    "items": [
        {
            "itemid": "151427",
            "sku": "8718138817300",
            "quantity": "1.0000",
            "name": "Shirt Large Blue",
            "price": "24.7521",
            "total": "24.7521"
        },
        {
            "itemid": "151428",
            "sku": "8718588321550",
            "quantity": "1.0000",
            "name": "Shirt Large Red",
            "price": "24.7520",
            "total": "24.7520"
        }
    ],
    "conversionid": "102346347",
    "source": "Magento",
    "objecttype": "conversion"
}

Get Conversions

Returns the conversions in the given project.

projectid required
integer Project id
limit optional
int Limit of conversion returned. Default is 1000
offset optional
int Query offset
sort optional
string Sort conversion by fields. Fore example date
order optional
string Sorting order ASC or DESC
q optional
object See: Search Queries
Endpoint
 https://api.datatrics.com/1.1/Sales/getConversions
Call
$ curl https://api.datatrics.com/Sales/getConversions \
						   -d "description=Customer for test@example.com" \
                                $result = $api->Sales->getConversions(array(
projectid => :projectid
limit => :limit
offset => :offset
sort => :sort
order => :order
q => :q
));
Response
[
    {
        "created": "2015-06-25 10:01:48",
        "discount": "0.0000",
        "shipping": "0.0000",
        "tax": "10.3959",
        "currency": "EUR",
        "subtotal": "49.5041",
        "ip": "134.23.91.13",
        "store": "DemoStore",
        "status": "pending",
        "profileid": "21341",
        "items": [
            {
                "itemid": "151427",
                "sku": "8718138817300",
                "quantity": "1.0000",
                "name": "Shirt Large Blue",
                "price": "24.7521",
                "total": "24.7521"
            },
            {
                "itemid": "151428",
                "sku": "8718588321550",
                "quantity": "1.0000",
                "name": "Shirt Large Red",
                "price": "24.7520",
                "total": "24.7520"
            }
        ],
        "conversionid": "102346347",
        "source": "Magento",
        "objecttype": "conversion"
    }
]

Triggers

The Trigger Object

Trigger object

triggerid required
integer Trigger id
projectid required
integer Project id
name required
string Trigger name
description optional
string Trigger description
rules optional
string JCSDL String containing the rules
status optional
string Trigger status 1 or 0
enabled optional
boolean Boolean for if the trigger has been triggered
objects optional
array Array containing all matched objects
nextbestaction optional
integer ID of the associated Next Best Action
notified optional
boolean If the user is notified that the trigger has been triggered
created optional
datetime Date and time of creation
updated optional
datetime Date and time when last updated
Endpoint
 https://api.datatrics.com/1.1/Trigger/Trigger Object
Call

                                $result = $api->Trigger->Trigger Object(array(
triggerid => :triggerid
projectid => :projectid
name => :name
description => :description
rules => :rules
status => :status
enabled => :enabled
objects => :objects
nextbestaction => :nextbestaction
notified => :notified
created => :created
updated => :updated
));
Response
{
    "triggerid": "20150720024307743",
    "projectid": "254062",
    "name": "Nameless Trigger",
    "description": null,
    "rules": "\/\/%20JCSDL_MASTER%202566c0bcab1d53302d95317f586b0ad3%20AND%0A\/\/%20JCSDL_VERSION%202.0%0A\/\/%20JCSDL_START%2034d63b62c134c90819def9b5cfb07b39%20Items.engagement,greaterThan,20-2%201%0AItems.engagement%20%3E=%2080%0A\/\/%20JCSDL_END%0AAND%0A\/\/%20JCSDL_START%2046ba5119c0dd4ec7706d7dce08f6e506%20Items.potential,equals,19-2%202%0AItems.potential%20==%2080%0A\/\/%20JCSDL_END%0A\/\/%20JCSDL_MASTER_END",
    "status": "1",
    "enabled": null,
    "objects": [
        {
            "itemid": "290",
            "source": "Magento"
        }
    ],
    "nba": null,
    "notified": null,
    "created": "2015-07-20 15:43:07",
    "updated": "2015-07-20 15:43:46"
}

Get all Triggers

Get a list of triggers.

projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Triggers/getTriggers
Call

                                $result = $api->Triggers->getTriggers(array(
projectid => :projectid
));
Response
[
    {
        "triggerid": "20150720024307743",
        "projectid": "254062",
        "name": "Nameless Trigger",
        "description": null,
        "rules": "\/\/%20JCSDL_MASTER%202566c0bcab1d53302d95317f586b0ad3%20AND%0A\/\/%20JCSDL_VERSION%202.0%0A\/\/%20JCSDL_START%2034d63b62c134c90819def9b5cfb07b39%20Items.engagement,greaterThan,20-2%201%0AItems.engagement%20%3E=%2080%0A\/\/%20JCSDL_END%0AAND%0A\/\/%20JCSDL_START%2046ba5119c0dd4ec7706d7dce08f6e506%20Items.potential,equals,19-2%202%0AItems.potential%20==%2080%0A\/\/%20JCSDL_END%0A\/\/%20JCSDL_MASTER_END",
        "status": "1",
        "enabled": null,
        "objects": [
            {
                "itemid": "290",
                "source": "Magento"
            }
        ],
        "nba": null,
        "notified": null,
        "created": "2015-07-20 15:43:07",
        "updated": "2015-07-20 15:43:46"
    }
]

Get a Trigger

Get a specific trigger.

triggerid required
integer Trigger id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Triggers/getTrigger
Call

                                $result = $api->Triggers->getTrigger(array(
triggerid => :triggerid
projectid => :projectid
));
Response
{
    "triggerid": "20150720024307743",
    "projectid": "254062",
    "name": "Nameless Trigger",
    "description": null,
    "rules": "\/\/%20JCSDL_MASTER%202566c0bcab1d53302d95317f586b0ad3%20AND%0A\/\/%20JCSDL_VERSION%202.0%0A\/\/%20JCSDL_START%2034d63b62c134c90819def9b5cfb07b39%20Items.engagement,greaterThan,20-2%201%0AItems.engagement%20%3E=%2080%0A\/\/%20JCSDL_END%0AAND%0A\/\/%20JCSDL_START%2046ba5119c0dd4ec7706d7dce08f6e506%20Items.potential,equals,19-2%202%0AItems.potential%20==%2080%0A\/\/%20JCSDL_END%0A\/\/%20JCSDL_MASTER_END",
    "status": "1",
    "enabled": null,
    "objects": [
        {
            "itemid": "290",
            "source": "Magento"
        }
    ],
    "nba": null,
    "notified": null,
    "created": "2015-07-20 15:43:07",
    "updated": "2015-07-20 15:43:46"
}

Activate a Trigger

Activate a specific Trigger from a specific project.

trigger required
integer Trigger id
projectid required
integer Project id
objects optional
array Array containing all matched objects
Endpoint
 https://api.datatrics.com/1.1/Triggers/activateTrigger
Call

                                $result = $api->Triggers->activateTrigger(array(
trigger => :trigger
projectid => :projectid
objects => :objects
));
Response
{
    "result": "success",
    "message": "ok"
}

Deactivate a Trigger

deactivate a specific trigger from a specific project.

triggerid required
integer Trigger id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Triggers/deactivateTrigger
Call

                                $result = $api->Triggers->deactivateTrigger(array(
triggerid => :triggerid
projectid => :projectid
));
Response
{
    "result": "success",
    "message": "ok"
}

Delete a Trigger

Delete a specific trigger.

triggerid required
integer Trigger id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Triggers/deleteTrigger
Call

                                $result = $api->Triggers->deleteTrigger(array(
triggerid => :triggerid
projectid => :projectid
));
Response
{
    "result": "success",
    "message": "ok"
}

Boxes

The Box Object

Box object

boxid required
integer Box id
projectid required
integer Project id
name required
string Box name
description optional
string Box description
settings optional
array
status optional
string Box status 1 or 0
created optional
datetime Date and time of creation
updated optional
datetime Date and time when last updated
Endpoint
 https://api.datatrics.com/1.1/Boxes/Box Object
Call

                                $result = $api->Boxes->Box Object(array(
boxid => :boxid
projectid => :projectid
name => :name
description => :description
settings => :settings
status => :status
created => :created
updated => :updated
));
Response
{
    "boxid": "20150832121356962",
    "projectid": "223062",
    "name": "TestBox",
    "description": "My test box :)",
    "settings": [],
    "status": null,
    "created": "2015-08-03 14:13:56",
    "updated": null
}

Get all Boxes

Get a list of boxes.

projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Boxes/getBoxes
Call

                                $result = $api->Boxes->getBoxes(array(
projectid => :projectid
));
Response
[
    {
        "boxid": "20150832121356962",
        "projectid": "223062",
        "name": "TestBox",
        "description": "My test box :)",
        "settings": [],
        "status": null,
        "created": "2015-08-03 14:13:56",
        "updated": null
    }
]

Get a Box

Get a specific box.

boxid required
integer Box id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Boxes/getBox
Call

                                $result = $api->Boxes->getBox(array(
boxid => :boxid
projectid => :projectid
));
Response
{
    "boxid": "20150832121356962",
    "projectid": "223062",
    "name": "TestBox",
    "description": "My test box :)",
    "settings": [],
    "status": null,
    "created": "2015-08-03 14:13:56",
    "updated": null
}

Get Box code

Get the html code for a specific box.

boxid required
integer Box id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Boxes/getBoxCode
Call

                                $result = $api->Boxes->getBoxCode(array(
boxid => :boxid
projectid => :projectid
));
Response
null

Show a Box

Get all the information you need to show a box.

boxid required
integer Box id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Boxes/showBox
Call

                                $result = $api->Boxes->showBox(array(
boxid => :boxid
projectid => :projectid
));
Response
{
    "boxid": "20150803121356962",
    "projectid": "255062",
    "name": "TestBox",
    "description": "My test box :)",
    "settings": [],
    "status": null,
    "created": "2015-08-03 14:13:56",
    "updated": null,
    "version": {
        "projectid": "255062",
        "boxid": "20150803121356962",
        "versionid": "20150817011409770",
        "name": "Version 1",
        "template": "Containing html template",
        "settings": [],
        "status": "1",
        "created": "2015-08-17 15:14:09",
        "updated": "2015-08-17 15:14:12"
    },
    "data": {
        "items": []
    }
}

Add a Box

Add a box to the Datatrics platform.

projectid required
integer Project id
name required
string Box name
description optional
string Box description
settings optional
array
status optional
string Box status 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Boxes/addBox
Call

                                $result = $api->Boxes->addBox(array(
projectid => :projectid
name => :name
description => :description
settings => :settings
status => :status
));
Response
{
    "result": "success",
    "message": "ok"
}

Update a Box

Update a specific box.

boxid required
integer Box id
projectid required
integer Project id
name required
string Box name
description optional
string Box description
settings optional
array
status optional
string Box status 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Boxes/updateBox
Call

                                $result = $api->Boxes->updateBox(array(
boxid => :boxid
projectid => :projectid
name => :name
description => :description
settings => :settings
status => :status
));
Response
{
    "result": "success",
    "message": "ok"
}

The Version Object

Version object

boxid required
integer Box id
projectid required
integer Project id
versionid required
integer Version id
name required
string Box name
template optional
string Box template
settings optional
array
status optional
string Box status 1 or 0
created optional
datetime Date and time of creation
updated optional
datetime Date and time when last updated
Endpoint
 https://api.datatrics.com/1.1/Boxes/Version Object
Call

                                $result = $api->Boxes->Version Object(array(
boxid => :boxid
projectid => :projectid
versionid => :versionid
name => :name
template => :template
settings => :settings
status => :status
created => :created
updated => :updated
));
Response
{
    "projectid": "255062",
    "boxid": "20150803121356962",
    "versionid": "20150817011409770",
    "name": "Version 1",
    "template": "Html template",
    "settings": [],
    "status": "1",
    "created": "2015-08-17 15:14:09",
    "updated": "2015-08-17 15:14:12"
}

Add a Version

Add a version to a specific box.

boxid required
integer Box id
projectid required
integer Project id
name required
string Box name
template optional
string Box template
settings optional
array
status optional
string Box status 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Boxes/addVersion
Call

                                $result = $api->Boxes->addVersion(array(
boxid => :boxid
projectid => :projectid
name => :name
template => :template
settings => :settings
status => :status
));
Response
{
    "result": "success",
    "message": "ok"
}

Get all Versions

Get all versions of a specific box.

boxid required
integer Box id
projectid required
integer Project id
Endpoint
 https://api.datatrics.com/1.1/Boxes/getVersions
Call

                                $result = $api->Boxes->getVersions(array(
boxid => :boxid
projectid => :projectid
));
Response
[
    {
        "projectid": "255062",
        "boxid": "20150803121356962",
        "versionid": "20150817011409770",
        "name": "Version 1",
        "template": "Html template",
        "settings": [],
        "status": "1",
        "created": "2015-08-17 15:14:09",
        "updated": "2015-08-17 15:14:12"
    }
]

Get a Version

Get a specific version of a specific box.

projectid required
integer Project id
versionid required
integer Version id
Endpoint
 https://api.datatrics.com/1.1/Boxes/getVersion
Call

                                $result = $api->Boxes->getVersion(array(
projectid => :projectid
versionid => :versionid
));
Response
{
    "projectid": "255062",
    "boxid": "20150803121356962",
    "versionid": "20150817011409770",
    "name": "Version 1",
    "template": "Html template",
    "settings": [],
    "status": "1",
    "created": "2015-08-17 15:14:09",
    "updated": "2015-08-17 15:14:12"
}

Update a Version

Update a specific version.

projectid required
integer Project id
versionid required
integer Version id
name required
string Box name
template optional
string Box template
settings optional
array
status optional
string Box status 1 or 0
Endpoint
 https://api.datatrics.com/1.1/Boxes/updateVersion
Call

                                $result = $api->Boxes->updateVersion(array(
projectid => :projectid
versionid => :versionid
name => :name
template => :template
settings => :settings
status => :status
));
Response
{
    "result": "success",
    "message": "ok"
}

Delete a Version

Delete a specific version.

projectid required
integer Project id
versionid required
integer Version id
Endpoint
 https://api.datatrics.com/1.1/Boxes/deleteVersion
Call

                                $result = $api->Boxes->deleteVersion(array(
projectid => :projectid
versionid => :versionid
));
Response
{
    "result": "success",
    "message": "ok"
}

API

Create a Key

Endpoint
 https://api.datatrics.com/1.1/API/createKey
Call

                                $result = $api->API->createKey(array(
));
Response
null

Validate a key

Endpoint
 https://api.datatrics.com/1.1/API/validateKey
Call

                                $result = $api->API->validateKey(array(
));
Response
null

Get Key Details

Endpoint
 https://api.datatrics.com/1.1/API/getKey
Call

                                $result = $api->API->getKey(array(
));
Response
null

Deactivate a key

Endpoint
 https://api.datatrics.com/1.1/API/deactivateKey
Call

                                $result = $api->API->deactivateKey(array(
));
Response
null

Search Queries

Query Operators

Comparison

Name Description
$eq Matches values that are equal to a specified value.
$gt Matches values that are greater than a specified value.
$gte Matches values that are greater than or equal to a specified value.
$lt Matches values that are less than a specified value.
$lte Matches values that are less than or equal to a specified value.
$ne Matches all values that are not equal to a specified value.
$in Matches any of the values specified in an array.
$nin Matches none of the values specified in an array.

Logical

Name Description
$or Joins query clauses with a logical OR returns all documents that match the conditions of either clause.
$and Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.
$not Inverts the effect of a query expression and returns documents that do not match the query expression.
$nor Joins query clauses with a logical NOR returns all documents that fail to match both clauses.

Element

Name Description
$exists Matches documents that have the specified field.
$type Selects documents if a field is of the specified type.

Evaluation

Name Description
$mod Performs a modulo operation on the value of a field and selects documents with a specified result.
$regex Selects documents where values match a specified regular expression.
$text Performs text search.
$where Matches documents that satisfy a JavaScript expression.

Geospatial

Name Description
$geoWithin Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin.
$geoIntersects Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects.
$near Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near.
$nearSphere Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere.

Array

Name Description
$all Matches arrays that contain all elements specified in the query.
$elemMatch Selects documents if element in the array field matches all the specified $elemMatch conditions.
$size Selects documents if the array field is a specified size.

Comments

Name Description
$comment Adds a comment to a query predicate.

Specify Equality Condition

To specify equality condition, use the query document { <field>: <value> } to select all documents that contain the <field> with the specified <value>.

The following example retrieves all documents from the bucket where the type field has the value snacks:

 { type: "snacks" }
								

Specify Conditions Using Query Operators

The following example selects all objects where the value of the type field is either 'food' or 'snacks':

{ type: { $in: [ 'food', 'snacks' ] } }
							

Although you can express this query using the $or operator, use the $in operator rather than the $or operator when performing equality checks on the same field.

Specify AND Conditions

A compound query can specify conditions for more than one field in the collection’s documents. Implicitly, a logical AND conjunction connects the clauses of a compound query so that the query selects the documents in the collection that match all the conditions.

In the following example, the query document specifies an equality match on the field type and a less than ($lt) comparison match on the field price:

 { type: 'food', price: { $lt: 9.95 } }
							

This query selects all documents where the type field has the value 'food' and the value of the price field is less than 9.95.

Specify OR Conditions

Using the $or operator, you can specify a compound query that joins each clause with a logical OR conjunction so that the query selects the documents in the collection that match at least one condition.

In the following example, the query document selects all documents in the collection where the field qty has a value greater than ($gt) 100 or the value of the price field is less than ($lt) 9.95:

							   {
							     $or: [ { qty: { $gt: 100 } }, { price: { $lt: 9.95 } } ]
							   }
							

Specify AND as well as OR Conditions

With additional clauses, you can specify precise conditions for matching documents.

In the following example, the compound query document selects all documents in the collection where the value of the type field is 'food' and either the qty has a value greater than ($gt) 100 or the value of the price field is less than ($lt) 9.95:

							   {
							     type: 'food',
							     $or: [ { qty: { $gt: 100 } }, { price: { $lt: 9.95 } } ]
							   }
							

Embedded Documents

When the field holds an embedded document, a query can either specify an exact match on the embedded document or specify a match by individual fields in the embedded document using the dot notation.

Exact Match on the Embedded Document

To specify an equality match on the whole embedded document, use the query document { <field>: <value> } where <value> is the document to match. Equality matches on an embedded document require an exact match of the specified <value>, including the field order.

In the following example, the query matches all documents where the value of the field producer is an embedded document that contains only the field company with the value 'ABC123' and the field address with the value '123 Street', in the exact order:

							    {
							      producer:
							        {
							          company: 'ABC123',
							          address: '123 Street'
							        }
							    }
							

Equality Match on Fields within an Embedded Document

Use the dot notation to match by specific fields in an embedded document. Equality matches for specific fields in an embedded document will select documents in the collection where the embedded document contains the specified fields with the specified values. The embedded document can contain additional fields.

In the following example, the query uses the dot notation to match all documents where the value of the field producer is an embedded document that contains a field company with the value 'ABC123' and may contain other fields:

 { 'producer.company': 'ABC123' }
							

Arrays

When the field holds an array, you can query for an exact array match or for specific values in the array. If the array holds embedded documents, you can query for specific fields in the embedded documents using dot notation.

If you specify multiple conditions using the $elemMatch operator, the array must contain at least one element that satisfies all the conditions. See Single Element Satisfies the Criteria.

If you specify multiple conditions without using the $elemMatch operator, then some combination of the array elements, not necessarily a single element, must satisfy all the conditions; i.e. different elements in the array can satisfy different parts of the conditions. See Combination of Elements Satisfies the Criteria.

Consider an inventory collection that contains the following documents:

{ _id: 5, type: "food", item: "aaa", ratings: [ 5, 8, 9 ] }
							{ _id: 6, type: "food", item: "bbb", ratings: [ 5, 9 ] }
							{ _id: 7, type: "food", item: "ccc", ratings: [ 9, 5, 8 ] }
							

Exact Match on an Array

To specify equality match on an array, use the query document { <field>: <value> } where <value> is the array to match. Equality matches on the array require that the array field match exactly the specified <value>, including the element order.

The following example queries for all documents where the field ratings is an array that holds exactly three elements, 5, 8, and 9, in this order:

 { ratings: [ 5, 8, 9 ] }
							

The operation returns the following document:

{ "_id" : 5, "type" : "food", "item" : "aaa", "ratings" : [ 5, 8, 9 ] }
							

Match an Array Element

Equality matches can specify a single element in the array to match. These specifications match if the array contains at least one element with the specified value.

The following example queries for all documents where ratings is an array that contains 5 as one of its elements:

 { ratings: 5 }
							

The operation returns the following documents:

{ "_id" : 5, "type" : "food", "item" : "aaa", "ratings" : [ 5, 8, 9 ] }
							{ "_id" : 6, "type" : "food", "item" : "bbb", "ratings" : [ 5, 9 ] }
							{ "_id" : 7, "type" : "food", "item" : "ccc", "ratings" : [ 9, 5, 8 ] }
							

Match a Specific Element of an Array

Equality matches can specify equality matches for an element at a particular index or position of the array using the dot notation.

In the following example, the query uses the dot notation to match all documents where the ratings array contains 5 as the first element:

 { 'ratings.0': 5 }
							

The operation returns the following documents:

{ "_id" : 5, "type" : "food", "item" : "aaa", "ratings" : [ 5, 8, 9 ] }
							{ "_id" : 6, "type" : "food", "item" : "bbb", "ratings" : [ 5, 9 ] }
							

Specify Multiple Criteria for Array Elements

Single Element Satisfies the Criteria

Use $elemMatch operator to specify multiple criteria on the elements of an array such that at least one array element satisfies all the specified criteria.

The following example queries for documents where the ratings array contains at least one element that is greater than ($gt) 5 and less than ($lt) 9:

 { ratings: { $elemMatch: { $gt: 5, $lt: 9 } } }
							

The operation returns the following documents, whose ratings array contains the element 8 which meets the criteria:

{ "_id" : 5, "type" : "food", "item" : "aaa", "ratings" : [ 5, 8, 9 ] }
							{ "_id" : 7, "type" : "food", "item" : "ccc", "ratings" : [ 9, 5, 8 ] }
							

Combination of Elements Satisfies the Criteria

The following example queries for documents where the ratings array contains elements that in some combination satisfy the query conditions; e.g., one element can satisfy the greater than 5 condition and another element can satisfy the less than 9 condition, or a single element can satisfy both:

 { ratings: { $gt: 5, $lt: 9 } }
							

The operation returns the following documents:

{ "_id" : 5, "type" : "food", "item" : "aaa", "ratings" : [ 5, 8, 9 ] }
							{ "_id" : 6, "type" : "food", "item" : "bbb", "ratings" : [ 5, 9 ] }
							{ "_id" : 7, "type" : "food", "item" : "ccc", "ratings" : [ 9, 5, 8 ] }
							

The document with the "ratings" : [ 5, 9 ] matches the query since the element 9 is greater than 5 (the first condition) and the element 5 is less than 9 (the second condition).

Array of Embedded Documents

Consider that the inventory collection includes the following documents:

{
							  _id: 100,
							  type: "food",
							  item: "xyz",
							  qty: 25,
							  price: 2.5,
							  ratings: [ 5, 8, 9 ],
							  memos: [ { memo: "on time", by: "shipping" }, { memo: "approved", by: "billing" } ]
							}
							
							{
							  _id: 101,
							  type: "fruit",
							  item: "jkl",
							  qty: 10,
							  price: 4.25,
							  ratings: [ 5, 9 ],
							  memos: [ { memo: "on time", by: "payment" }, { memo: "delayed", by: "shipping" } ]
							}
							

Match a Field in the Embedded Document Using the Array Index

If you know the array index of the embedded document, you can specify the document using the embedded document’s position using the dot notation.

The following example selects all documents where the memos contains an array whose first element (i.e. index is 0) is a document that contains the field by whose value is 'shipping':

{ 'memos.0.by': 'shipping' }
							

The operation returns the following document:

{
							   _id: 100,
							   type: "food",
							   item: "xyz",
							   qty: 25,
							   price: 2.5,
							   ratings: [ 5, 8, 9 ],
							   memos: [ { memo: "on time", by: "shipping" }, { memo: "approved", by: "billing" } ]
							}
							

Match a Field Without Specifying Array Index

If you do not know the index position of the document in the array, concatenate the name of the field that contains the array, with a dot (.) and the name of the field in the embedded document.

The following example selects all documents where the memos field contains an array that contains at least one embedded document that contains the field by with the value 'shipping':

 { 'memos.by': 'shipping' } 
							

The operation returns the following documents:

{
							  _id: 100,
							  type: "food",
							  item: "xyz",
							  qty: 25,
							  price: 2.5,
							  ratings: [ 5, 8, 9 ],
							  memos: [ { memo: "on time", by: "shipping" }, { memo: "approved", by: "billing" } ]
							}
							{
							  _id: 101,
							  type: "fruit",
							  item: "jkl",
							  qty: 10,
							  price: 4.25,
							  ratings: [ 5, 9 ],
							  memos: [ { memo: "on time", by: "payment" }, { memo: "delayed", by: "shipping" } ]
							}
							

Specify Multiple Criteria for Array of Documents

Single Element Satisfies the Criteria

Use $elemMatch operator to specify multiple criteria on an array of embedded documents such that at least one embedded document satisfies all the specified criteria.

The following example queries for documents where the memos array has at least one embedded document that contains both the field memo equal to 'on time' and the field by equal to 'shipping':

							   {
							     memos:
							       {
							          $elemMatch:
							            {
							               memo: 'on time',
							               by: 'shipping'
							            }
							       }
							    }
							

The operation returns the following document:

{
							   _id: 100,
							   type: "food",
							   item: "xyz",
							   qty: 25,
							   price: 2.5,
							   ratings: [ 5, 8, 9 ],
							   memos: [ { memo: "on time", by: "shipping" }, { memo: "approved", by: "billing" } ]
							}
							

Combination of Elements Satisfies the Criteria

The following example queries for documents where the memos array contains elements that in some combination satisfy the query conditions; e.g. one element satisfies the field memo equal to 'on time' condition and another element satisfies the field by equal to 'shipping' condition, or a single element can satisfy both criteria:

							  {
							    'memos.memo': 'on time',
							    'memos.by': 'shipping'
							  }
							

The query returns the following documents:

{
							  _id: 100,
							  type: "food",
							  item: "xyz",
							  qty: 25,
							  price: 2.5,
							  ratings: [ 5, 8, 9 ],
							  memos: [ { memo: "on time", by: "shipping" }, { memo: "approved", by: "billing" } ]
							}
							{
							  _id: 101,
							  type: "fruit",
							  item: "jkl",
							  qty: 10,
							  price: 4.25,
							  ratings: [ 5, 9 ],
							  memos: [ { memo: "on time", by: "payment" }, { memo: "delayed", by: "shipping" } ]
							
							}
							
{ $or: [ { qty: { $gt: 100 } }, { price: { $lt: 9.95 } } ] }

Errors

Datatrics uses conventional HTTP response codes to indicate success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g. a required parameter was missing, a charge failed, etc.), and codes in the 5xx range indicate an error with Datatrics's servers.

Not all errors map cleanly onto HTTP response codes, however. When a request is valid but does not complete successfully (e.g. a card is declined), we return a 402 error code.

Attributes

code:
string Code of the error
message:
string A complete message with details about the error to show users.
200 OK - Everything worked.

400 Bad Request - The request was badly built

401 Unauthorized - Some other message

402 Request Failed - The request failed

404 Not Found - Doesn't exist

500, 502, 503, 504 Server errors