NAV
cURL

Getting Started

Alright! Let’s get started on the APIs provided by EpocH.

All API’s are RESTful. You will need an API key and an API secret for every API call you make. You will get a unique key and secret after registering with us.

Now that you have the API key and API secret let us see how to push and retrieve the data in EpocH with a small example.

EpocH has three major tables where most of the information is stored:

Let us take a scenario where you have a store which has products and customer information is stored during a transaction.

In EpocH the Customer information is stored in the member table.

Member Definition

First we have to define the Member template. Let’s assume that the Name and the Mobile number are the primary identifiers. Email address and the Physical address are the supporting fields.

curl "https://developer.mafoianalytics.com/epoch/process/definemember"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<YOUR API_KEY>",
        "api_secret": "<YOUR API_SECRET>",
        "data": {
            "member_identifiers": [
                {
                    "label": "Mobile",
                    "data_type": "number",
                    "required": true
                },
                {
                    "label": "Name",
                    "data_type": "string",
                    "required": true
                }
            ],
            "member_supports": [
                {
                    "label": "Sex",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "Age",
                    "data_type": "number",
                    "required": true
                },
                {
                    "label": "Address",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "Email",
                    "data_type": "string",
                    "required": false
                }
            ]
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "MEMBER DEFINITION SUCCESS",
    "status_code": "200"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/definemember

Product Master

The product master will have the master list of products sold in the stores. Now let’s add a T-shirt in the product master along with its attributes.

curl "https://developer.mafoianalytics.com/epoch/process/defineobject"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<YOUR API_KEY>",
        "api_secret": "<YOUR API_SECRET>",
        "data": {
             "object_name": "tshirt",
             "object_state": "PUBLISHED",
             "object_desc": "description",
             "object_fields": [
                {
                    "label": "sku number",
                    "data_type": "number",
                    "required": true
                },
                {
                    "label": "size",
                    "data_type": "number",
                    "required": true
                },
                {
                    "label": "color",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "material",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "pattern",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "gender",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "brand",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "price",
                    "data_type": "number",
                    "required": true
                }
            ]
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "OBJECT CREATION SUCCESS",
    "status_code": "200"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/defineobject

Adding a Product

Now that the Product master for a T-shirt has been defined let us see how to add a Cotton T-shirt to the product list. This will be the line item in the bill generated in the store and contain information on the brand, color, price etc

curl "https://developer.mafoianalytics.com/epoch/process/addobject"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<YOUR API_KEY>",
        "api_secret": "<YOUR API_SECRET>",
        "data": {
            "object_name": "tshirt",
            "sku number": 2501,
            "size": 40,
            "color": "blue",
            "material": "cotton",
            "pattern": "solid",
            "gender": "male",
            "brand": "arrow",
            "price": 1500
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ADD OBJECT SUCCESS",
    "status_code": "200"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/addobject

Add Member

Now a customer comes and buys the t-shirt. This is an interaction between the customer and product.This is stored in the activity table in EpocH

To record this interaction, first we have to add the customer. This can be done by using the add member API

curl "https://developer.mafoianalytics.com/epoch/process/addmember"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<YOUR API_KEY>",
        "api_secret": "<YOUR API_SECRET>",
           "data": {
            "Name": "Vijay",
            "Mobile": 9841000000,
            "Sex": "Male",
            "Age": 29,
            "Address": "M.G. Road",
            "Email": "example@example.com"
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ADD MEMBER SUCCESS",
    "status_code": "200"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getmembers

Retrieving member information

Now that we have added the member, you might want to retrieve information like Name, Mobile, Age etc about the user. This is possible using the Get Members API.

curl "https://developer.mafoianalytics.com/epoch/process/getmembers"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<YOUR API_KEY>",
        "api_secret": "<YOUR API_SECRET>",
           "data": {
            "query": {
                "Email": "example@example.com"
            },
            "project": [
                "First Name",
                "Last Name",
                "Email"
            ],
            "limit": 1
        }
    }'

The above command returns JSON structured like this:

{
  "status_code": "200",
  "data": [
    {
      "_id": {
        "$oid": "57aa2b3bac1eb0b44ff78a73"
      },
      "Mobile": 9876543210,
      "Age": 29,
      "Name": "Vijay"
    }
  ],
  "status_txt": "GETTING MEMBERS SUCCESS"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getmembers

Defining an Activity

Before we can capture the interaction into EpocH we have to define the activity in EpocH.This activity is the record of the transaction in the database. Lets see how to define this activity.

curl "https://developer.mafoianalytics.com/epoch/process/defineactivity"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "activity_name": "customer_order",
            "activity_desc": "Purchase made by a customer",
            "activity_state": "PUBLISHED",
            "member_template": true,
            "activity_fields": [
                {
                    "label": "order_number",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "items_purchased",
                    "data_type": "array",
                    "required": true
                },
                {
                    "label": "total_order_price",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "total_tax",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "added_by",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "payment_method",
                    "data_type": "string",
                    "required": true
                }
            ],
            "member_fields": [
                "Name",
                "Mobile"
            ]
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ACTIVITY CREATION SUCCESS",
    "status_code": "200"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/defineactivity

Recording an Interaction

The purchase made by the customer (interaction) is captured as follows:

curl "https://developer.mafoianalytics.com/epoch/process/addactivity"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<YOUR API_KEY>",
        "api_secret": "<YOUR API_SECRET>",
         "data": {
            "activity_name": "customer_order",
            "order_number": "A01001",
            "items_purchased": [
                "tshirt"
            ],
            "total_order_price": "1500",
            "total_tax": "0",
            "added_by": "sales_1",
            "payment_method": "cash",
            "Name": "Vijay",
            "Mobile": 9876543210
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ADD ACTIVITY SUCCESS",
    "status_code": "200"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/addactivity

Retrieving the interactions

Now that the interaction has been captured in the database you might want to retrieve the interactions from the database. You can do that by using the Getacivities API.

curl "https://developer.mafoianalytics.com/epoch/process/getactivities"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<YOUR API_KEY>",
        "api_secret": "<YOUR API_SECRET>",
         "data": {
            "query":{
                "activity_name": "customer_order"
            },
            "project":[],
            "sort":{},
            "limit":0
       }
    }'

The above command returns JSON structured like this:

{
  "status_code": "200",
  "data": [
    {
      "member_id": "57aa2b3bac1eb0b44ff78a73",
      "activity_name": "customer_order",
      "items_purchased": [
        "tshirt"
      ],
      "_posted_date": 1470770435131,
      "added_by": "sales_1",
      "order_number": "A01001",
      "_id": {
        "$oid": "57aa2d03e4b0cef65b774ef0"
      },
      "total_tax": "0",
      "Mobile": 9876543210,
      "payment_method": "cash",
      "total_order_price": "1500",
      "Name": "Vijay"
    }
  ],
  "status_txt": "GETTING ACTIVITIES SUCCESS"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getactivities

Click hereto directly go to Concepts.

What’s New?

November 16th 2016 v2.3

EpocH Release v 2.3

Our First Intelligence API, Vison API has been added today. This is used to do image analysis. Send your image file to our API and get the analysis result. One or more of the following features of the image can be requested:

We currently use the Google Vision API to perform the image analysis. Integrations with other providers are planned for the future releases.

October 17th 2016 v2.2

EpocH Release v 2.2

New APIs for Click Stream data and Real time Messaging have been launched.

Click Stream APIs:

Three new APIs have been created to store, process and retrieve click stream data.

Real Time Messaging APIs:

July 18th 2016 v 2.1

EpocH Release v 2.1

Changes/Features and Improvements.

June 22nd 2016 v 2.0.1

The features and bug fixes of this release are detailed below:

Features:

Get Accounts API

  1. Simplified Definition Structure:

Example: [

{ “label”: “Name”, “data_type”: “string”, “required”: true },

{ “label”: “Age”, “data_type”: “number”, “required”: false },

{ “label”: “Date Of Birth”, “data_type”: “date”, “format”: “yyyy-MM-dd”, “required”: true },

{ “label”: “status”, “data_type”: “boolean”, “required”: true },

{ “label”: “Hobbies”, “data_type”: “array”, “required”: false },

{ “label”: “Other Information”, “data_type”: “object”, “required”: true },

{ “label”: “Location”, “data_type”: “geo”, “required”: false }

]

More information can be added to each field in the activity definition by providing custom key values, but they will not be validated.

For example, [

{ “label”: “Name”, “data_type”: “string”, “required”: true, “id”: 0, “description: "Name field” },

{ “label”: “Age”, “data_type”: “number”, “required”: false, “id”: 1, “description”: “Age of the Customer” }

]

In the above example, the keys id and description are custom keys.

2.Introducing Data Types and validation:

We are introducing data types in EpocH. The valid data types are : * string * number * boolean * date * array * object * geo * string fields accepts only string values. * number fields accepts whole numbers and decimals (both signed and unsigned). * boolean fields accepts only boolean values true and false. * date fields accepts only string which match the format mentioned for that field. This date string will be converted into a date object. * array fields accepts only JSON Arrays. * object fields accepts only JSON Objects. * geo fields accepts only geo JSONs for locations.

All these fields are validated with their respective data types while using Add APIs and Update APIs.

3.Ability to Update Definitions:

4.Get Accounts API:

A new management API called GetAccounts is introduced which will fetch all the accounts in EpocH. The response of this API will not have the api_key and api_secret of the accounts. Note: This API is getting modified for the next release which will have a concept called Application. In the next release, this API will need an application_key and application_secret for authenticating and it will fetch only the accounts which come under this application.

Bug Fixes:

Concepts

The following sections explain the core concepts and the data model of EpocH. We will start with the Authentication method used in EpocH.

Authentication

To authorize your API calls, use the “api_key” and “api_secret” which you will receive when you signup.

EpocH uses API_KEY and API_SECRET key to authorize the API calls. You can register for a new developer account to get your personal API key and API_SECRET key at our developer portal.

EpocH expects for the API_key and API_SECRET key to be included in all API requests to the server.

In order to scale your application and ease design, EpocH suggests a 5-Construct Schema Rule.

5-Construct Schema Rule

Member Construct

Member Construct defines the schema for all types of end customers of your application. Member construct like CAccount contains identifier and support elements.

Identifier element are defined to store member details that uniquely identifies a member. Support element are defined to store other details of the member.

List of API’s of Member with description:

API Description
Define Member to define a Member with identifier and support elements.
Update Member Definition to add more identifier and support elements to Member Definition.
Add Member to add a new Member with identifier and support elements defined in the CAccount Definition.
Update Member to update identifier and support elements of a existing Member.
Get Member to get Members of your application.
Get Member Definition to get the identifier and support elements of the Member defined for your application.

Activity Construct

Activity Construct defines the schema for all types of activities/events that occur/recorded in/by your application. Activities can be linked to a Member by including member at the definition level. Once the member is included, the member will be identified using identifier elements that are associated with the activity definition.

List of API’s of Activity with description:

API Description
Define Activity to define the activity elements and the member fields to be included in the activity for your application.
Update Activity Definition to add more activity elements, change the activity state and change the member elements that are linked to the activity for your application.
Add Activity to add activity to your application.
Update Activity to update existing activity for your application.
Get Activity to get activities for your application.
Get Activity Definition to get the definition elements of the activity for your application.

Object Construct

Object Construct defines the schema for all types of inventory/catalogue/objects used by your application. Objects are defined to give a schema for the object entities and information that will be used by your application.

Consider object as a way to store useful information which can be used by the application whenever it requires. Define Object API can used to define the schema for storing this useful information and Add Object API can be used to store the objects.

List of API’s of User with description:

API Description
Define Object to define the object elements in the object for your application.
Update Object Definition to add more object elements and change the object state of the object for your application.
Add Object to add object to your application.
Update Object to update existing object for your application.
Get Object to get objects for your application.
Get Object Definition to get the definition elements of the object for your application.

User Construct

User Construct defines the schema for the controlling stakeholders(or the back end users) of your application.

Definition Elements Usage
username to hold the user name or first name for the user.
lastname to hold the last name for the user.
user_status to denote whether the user is active or inactive(check constants for active and inactive values).
email to hold the email for the user.
password to hold the EpocH encrypted password.
role to hold the role assigned for the user.

Before using the API’s, find out about the basic structure of JSON that is used with our API’s here.

List of API’s of User with description:

API Description
Define User to add custom elements to the user schema.
Update User Definition to add more custom elements to the user schema.
Add User to add new user to your application.
Update User to update details of existing user of your application.
Get User to get users of your application.
Get User Definition to get the custom user elements defined for the application.
User Login to authenticate the user while logging into your application.
Reset User Password to reset user password and send the new password for your application.

CAccount Construct

CAccount Construct defines the schema for Client Account of your application. Client Account is level of definition provided to create accounts for your clients within your application. CAccount definition contains identifier and support elements.

Identifier element are defined to store CAccount details that uniquely identifies a CAccount. Support element are defined to store other details of the CAccount.

This construct can be used to refer and link up members, activities and objects of a client.

List of API’s of CAccount with description:

API Description
Define CAccount to define a CAccount with identifier and support elements.
Update CAccount Definition to add more identifier and support elements to CAccount Definition.
Add CAccount to add a new CAccount with identifier and support elements defined in the CAccount Definition.
Update CAccount to update identifier and support elements of a existing CAccount.
Get CAccount to get CAccounts of your application.
Get CAccount Definition to get the identifier and support elements of the CAccount defined for your application.

Core APIs

EpocH has a micro services based architecture. The Core API micro service has the set of core APIs useful for creating and managing your applications

Management APIs

Management APIs helps you create, update and view EpocH accounts, user accounts and also manage the user accounts

Create Account

curl "https://developer.mafoianalytics.com/epoch/process/createaccount"
-X POST
-H "Content-Type: application/json"
-d '{
    "application_key": "<APPLICATION_KEY>",
    "application_secret": "<APPLICATION_SECRET>",
    "data": {
        "acct_name": "Example-account",
        "support_email_id": "example@example.com",
        "password": "test_password",
        "username": "username",
        "lastname": "lastname",
        "acct_status": "1",
        "acct_mode": "dev",
        "acct_info": {
            "account_status": "Active"
        }
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "ACCOUNT CREATION SUCCESS.",
  "status_code": "200"
}

This endpoint is used to create a new account for your application. It will create a new account schema. An email with the username, password , API Key & API Secret will be triggered directly from EpocH.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/createaccount

Mandatory Variables

Optional Variables

Possible Values

Deactivate Account

curl "https://developer.mafoianalytics.com/epoch/process/deactivateaccount"
-X POST
-H "Content-Type: application/json"
-d '{
    "application_key": "<APPLICATION_KEY>",
    "application_secret": "<APPLICATION_SECRET>",
    "data": {
        "email": "example@example.com"
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "DEACTIVATING ACCOUNT SUCCESS",
  "status_code": "200"
}

Suppose you want to deactivate a live account, you can do that by using the Deactivate account API. This endpoint will deactivate the account.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/deactivateaccount

Mandatory Variables

Get Account

curl "https://developer.mafoianalytics.com/epoch/process/getaccounts"
-X POST
-H "Content-Type: application/json"
-d '{
    "application_key": "<APPLICATION_KEY>",
    "application_secret": "<APPLICATION_SECRET>",
    "data": {
        "query": {
            "support_email_id": "example@example.com"
        },
        "project": [
            "acct_name",
            "support_email_id"
        ],
        "sort": {
            "acct_name": 1
        },
        "limit": 1
    }
}'

The above command returns JSON structured like this:

{
  "status_code": "200",
  "data": [
    {
      "_id": {
        "$oid": "57dfc7b10fe60f4533ccfeaf"
      },
      "acct_name": "<ACCOUNT_NAME>",
      "support_email_id": "example@example.com"
    }
  ],
  "status_txt": "GETTING ACCOUNTS SUCCESS"
}

This endpoint will retrieve the account details schema. This is useful if you want to retrieve all the accounts present inside your application.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getaccounts

Mandatory Variables

Optional Variables

Update Account

curl "https://developer.mafoianalytics.com/epoch/process/updateaccount"
-X POST
-H "Content-Type: application/json"
-d '{
    "application_key": "<APPLICATION_KEY>",
    "application_secret": "<APPLICATION_SECRET>",
    "data": {
        "query": {
            "email": "example@example.com"
        },
        "set": {
            "branch": "Adyar",
            "region": "CHENNAI",
            "acct_status": "1",
            "acct_info": {
                "account_status": "Inactive"
            }
        },
        "multi": false
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "UPDATE ACCOUNT SUCCESS. 1 RECORD(S) UPDATED",
  "status_code": "200"
}

This endpoint will update the account details schema. This is useful if you want to update the details for the account. In the example the branch and region are being updated for the user.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/updateaccount

Mandatory Variables

Optional Variables

Possible Values

Set Object

Define User

curl "https://developer.mafoianalytics.com/epoch/process/defineuser"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "user_custom_fields": [
            {
                "label": "address",
                "data_type": "string",
                "required": true
            },
            {
                "label": "pincode",
                "data_type": "number",
                "required": true
            },
            {
                "label": "employed",
                "data_type": "boolean",
                "required": true
            },
            {
                "label": "Date of Birth",
                "data_type": "date",
                "required": true,
                "format": "dd/MM/yyyy"
            }
        ]
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "USER CUSTOM FIELD DEFINITION SUCCESS",
  "status_code": "200"
}

This endpoint will define the custom fields for the user schema. This endpoint is useful if you have an application which has multiple user types that have different access and you need some custom fields to be defined for the same. For example: Your application might have a super admin, admin, backend admin etc. You can use this endpoint to define these user types to add custom labels like address, date of birth etc.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/defineuser

Mandatory Variables

Possible Values

Get User Definition

curl "https://developer.mafoianalytics.com/epoch/process/getuserdef"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "query": {
            "account_id": "<ACCOUNT_ID>"
        },
        "project": [
            "user_custom_fields",
            "account_id"
        ],
        "sort": {
            "acct_name": 1
        },
        "limit": 1
    }
}'

The above command returns JSON structured like this:

{
    "status_code": "200",
    "data": [
        {
            "account_id": "<YOUR_ACCOUNT_ID",
            "_id": {
                "$oid": "57e28cf40fe664083d9614a6"
            },
            "user_custom_fields": [
                {
                    "data_type": "string",
                    "label": "address",
                    "required": true
                },
                {
                    "data_type": "number",
                    "label": "pincode",
                    "required": true
                },
                {
                    "data_type": "boolean",
                    "label": "employed",
                    "required": true
                },
                {
                    "data_type": "date",
                    "format": "dd/MM/yyyy",
                    "label": "Date of Birth",
                    "required": true
                },
                {
                    "data_type": "string",
                    "label": "empid",
                    "required": true
                }
            ]
        }
    ],
    "status_txt": "GETTING USER DEFINITION SUCCESS"
}

This endpoint will retrieve the user definition schema. This is useful to view the schema for custom fileds defined for the user using the previous define user endpoint.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getuserdef

Mandatory Variables

Possible Values

Add User

curl "https://developer.mafoianalytics.com/epoch/process/adduser"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "username": "username",
        "email": "example@example.com",
        "lastname": "lastname",
        "role": "agent",
        "address": "xyz",
        "pincode": 123456,
        "employed": true,
        "Date of Birth": "01/01/1990"
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "USER CREATION SUCCESS",
  "status_code": "200"
}

This endpoint will add new user. Now that you have defined the user, you can start creating new users using this endpoint. Note that the custom fields which we defined earlier are being used in this end point.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/adduser

Mandatory Variables

Optional Variables

Deactivate User

curl "https://developer.mafoianalytics.com/epoch/process/deactivateuser"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "email": "example@example.com"
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "DEACTIVATING USER SUCCESS",
  "status_code": "200"
}

This endpoint will deactivate the user. Suppose you want to deactivate a particular user you can use this endpoint to do so.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/deactivateuser

Mandatory Variables

Get User

curl "https://developer.mafoianalytics.com/epoch/process/getusers"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "query": {
            "user_status": "1"
        },
        "project": [
            "email",
            "username",
            "lastname",
            "user_status"
        ],
        "sort": {
            "email": -1
        },
        "limit": 10
    }
}'

The above command returns JSON structured like this:

{
    "status_txt": "GETTING USERS SUCCESS",
    "status_code": "200",
    "data": [
        {
            "user_status": "1",
            "_id": {
                "$oid": "57dba08df48540f2c640908e"
            },
            "email": "xxx@abc.com",
            "username": "epoch",
            "lastname": "test"
        },
        {
            "user_status": "1",
            "_id": {
                "$oid": "57eb5b4d56de5d696d2aa838"
            },
            "email": "123@abc.com",
            "username": "User1",
            "lastname": "S"
        },
        {
            "user_status": "1",
            "_id": {
                "$oid": "57eb5b4556de5d696d2aa837"
            },
            "email": "abc@dbe.com",
            "username": "AB",
            "lastname": "S"
        }
    ]
}

This endpoint will retrieve the user details. This helps you to view all the details of all the users present in the application. You can sort the result by a particular key and also limit the no of entries you want to retrieve.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getusers

Mandatory Variables

Possible Values

Update User

curl "https://developer.mafoianalytics.com/epoch/process/updateuser"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "query": {
            "email": "example@example.com"
        },
        "set": {
            "region": "CHENNAI"
        },
        "multi": false
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "UPDATE USER SUCCESS. 1 RECORD(S) UPDATED",
  "status_code": "200"
}

This endpoint will update the user details. This is useful if you want to update the details of an exisitng user in the application.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/updateuser

Mandatory Variables

Set Json

Possible Values

Update User Definition

curl "https://developer.mafoianalytics.com/epoch/process/updateuserdef"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "user_custom_fields": [
            {
                "label": "empid",
                "data_type": "string",
                "required": true
            }
        ]
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "UPDATE USER CUSTOM FIELD DEFINITION SUCCESS",
  "status_code": "200"
}

This endpoint will update the user definition schema. Suppose you want to update a field and set it as mandatory you will have to use this endpoint to update the exisitng user definition.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/updateuserdef

Mandatory Variables

Possible Values

User Login

curl "https://developer.mafoianalytics.com/epoch/process/userlogin"
-X POST
-H "Content-Type: application/json"
-d '{
    "account_id": "<ACCOUNT_ID>",
    "data": {
        "email": "example@example.com",
        "password": "test_password"
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "USER LOGIN SUCCESS",
  "status_code": "200",
  "username": "epoch",
  "lastname": "lastname",
  "user_status": "1",
  "role": "admin",
  "email": "example@example.com",
  "api_key": "<API_KEY>",
  "api_secret": "<API_SECRET>"
}

This endpoint will retrieve the user login status. This endpoint helps you in logging in the user to your application. This returns the user role, user status, first and last name of the user.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/userlogin

Mandatory Variables

Reset User Password

curl "https://developer.mafoianalytics.com/epoch/process/resetuserpassword"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "account_id": "<ACCOUNT_ID>",
    "data": {
        "email": "example@example.com"
    }
}'

The above command returns JSON structured like this:

{
  "status_txt": "RESET PASSWORD SUCCESS",
  "status_code": "200"
}

This endpoint will reset the user password. This can be used as your typical forgot password functionality. EpocH will trigger an email to the user with the new password.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/resetuserpassword

Mandatory Variables

Store APIs

These APIs help you in collecting and managing the data into your application. They also help in creating the data schema of your application.

Define CAccount

curl "https://developer.mafoianalytics.com/epoch/process/definecaccount"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "caccount_identifiers": [
                {
                    "label": "Email",
                    "data_type": "string",
                    "required": true
                }
            ],
            "caccount_supports": [
                {
                    "data_type": "string",
                    "label": "First Name",
                    "required": true
                },
                {
                    "data_type": "string",
                    "label": "Last Name",
                    "required": true
                },
                {
                    "data_type": "string",
                    "label": "Contact",
                    "required": true
                }
            ]
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "CACCOUNT DEFINITION SUCCESS",
    "status_code": "200"
}

This endpoint will define the caccount schema. You can set the labels and the their data types and specify fields that are mandatory for creating the caccount using this endpoint.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/definecaccount

Add CAccount

curl "https://developer.mafoianalytics.com/epoch/process/addcaccount"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "Email": "example@example.com",
            "First Name": "Example",
            "Last Name": "Example",
            "Contact": "9999999999"
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ADD CACCOUNT SUCCESS",
    "status_code": "200"
}

Once you have set up the caccount schema you can start creating the caccounts using this endpoint.This endpoint will add caccounts based on the caccount schema defined.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/addcaccount

Update CAccount

curl "https://developer.mafoianalytics.com/epoch/process/updatecaccount"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {
                "First Name": "Example"
            },
            "set": {
                "First Name": "Example First Name"
            },
            "multi": false
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "UPDATE CACCOUNT SUCCESS. 1 RECORD(S) UPDATED",
    "status_code": "200"
}

This endpoint will update the caccount based on the query and set filters. This is useful if you want to update any existing account with new information.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/updatecaccount

Define Member

curl "https://developer.mafoianalytics.com/epoch/process/definemember"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "member_identifiers": [
                {
                    "label": "Email",
                    "data_type": "string",
                    "required": true
                }
            ],
            "member_supports": [
                {
                    "data_type": "string",
                    "label": "First Name",
                    "required": true
                },
                {
                    "data_type": "string",
                    "label": "Last Name",
                    "required": true
                },
                {
                    "data_type": "string",
                    "label": "Phone",
                    "required": true
                }
            ]
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "MEMBER DEFINITION SUCCESS",
    "status_code": "200"
}

Members are the end users of your application. This endpoint will define the schema for the member. Member identifier sets the field which is the unique identifier for members.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/definemember

Add Member

curl "https://developer.mafoianalytics.com/epoch/process/addmember"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "Email": "example@example.com",
            "First Name": "Example",
            "Last Name": "Example",
            "Phone": "9999999999"
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ADD MEMBER SUCCESS",
    "status_code": "200"
}

This endpoint will add member based on the member definition.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/addmember

Import Members

curl
"https://developer.mafoianalytics.com/epoch/store/member?api_key=<API_KEY>&api_secret=<API_SECRET>"
-X PUT
--data-binary @members.csv
-H "Content-type: text/xml"

This endpoint will import all members from the csv file based on the member schema defined.

HTTP Request

PUT https://developer.mafoianalytics.com/epoch/store/member

Update Member

curl "https://developer.mafoianalytics.com/epoch/process/updatemember"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {
                "Email": "example@example.com"
            },
            "set": {
                "First Name": "Example First name"
            },
            "multi": false
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "UPDATE MEMBER SUCCESS. 1 RECORD(S) UPDATED",
    "status_code": "200"
}

This endpoint will update the member record based on the query and set conditions.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/updatemember

Define Activity

curl "https://developer.mafoianalytics.com/epoch/process/defineactivity"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "activity_name": "testactivity1"
            "activity_desc": "Feedback Form Desc",
            "activity_state": "PUBLISHED",
            "member_template": true,
            "activity_fields": [
                {
                    "label": "Activity 1 Field 1",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "Activity 1 Field 2",
                    "data_type": "string",
                    "required": true
                }
            ],
            "member_fields": [
                "First Name",
                "Phone",
                "Email"
            ]
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ACTIVITY CREATION SUCCESS",
    "status_code": "200"
}

This endpoint will define the schema for an activity.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/defineactivity

Add Activity

curl "https://developer.mafoianalytics.com/epoch/process/addactivity"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "activity_name": "testactivity1",
            "Activity 1 Field 1": "Value 1",
            "Activity 1 Field 2": "Value 2",
            "First Name": "Test Name",
            "Phone": "9876543210",
            "Email": "test@test.com"
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ADD ACTIVITY SUCCESS",
    "status_code": "200"
}

This endpoint will add an activity based on the activity name specified and it’s definition.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/addactivity

Update Activity

curl "https://developer.mafoianalytics.com/epoch/process/updateactivity"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {
                "activity_name": "testactivity1",
                "Activity 1 Field 1": "Value 1"
            },
            "set": {
                "Activity 1 Field 2": "Value 22"
            },
            "multi": false
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "UPDATE ACTIVITY SUCCESS. 1 RECORD(S) UPDATED",
    "status_code": "200"
}

This endpoint will update an activity based on the query and set conditions.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/updateactivity

Define Object

curl "https://developer.mafoianalytics.com/epoch/process/defineobject"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "object_name": "object1",
            "object_state": "PUBLISHED",
            "object_desc": "description",
            "object_fields": [
                {
                    "label": "Object 1 Field 1",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "Object 1 Field 2",
                    "data_type": "string",
                    "required": true
                },
                {
                    "label": "Object 1 Field 3",
                    "data_type": "string",
                    "required": true
                }
            ]
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "OBJECT CREATION SUCCESS",
    "status_code": "200"
}

This endpoint will define the object definition (schema).

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/defineobject

Add Object

curl "https://developer.mafoianalytics.com/epoch/process/addobject"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "object_name": "object1",
            "Object 1 Field 1": "Field 1 value",
            "Object 1 Field 2": "Field 2 value",
            "Object 1 Field 3": "Field 3 value"
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ADD OBJECT SUCCESS",
    "status_code": "200"
}

This endpoint will add an object based on the object name specified and it’s definition.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/addobject

Update Object

curl "https://developer.mafoianalytics.com/epoch/process/updateobject"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {
                "object_name": "object1",
                "Object 1 Field 1": "Field 1 value"
            },
            "set": {
                "Object 1 Field 2": "Field 1 value 22"
            },
            "multi": false
        }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "UPDATE OBJECT SUCCESS. 1 RECORD(S) UPDATED",
    "status_code": "200"
}

This endpoint will update an object or multiple objects based on the query and set conditions.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/updateobject

Retrieve APIs

Retrieve APIs help in retrieving the account related data, user data, objects and activities.

Get CAccount Definition

curl "https://developer.mafoianalytics.com/epoch/process/getcaccountdef"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {}
        }
    }'

The above command returns JSON structured like this:

{
    "status_code": "200",
    "status_txt": "GETTING CACCOUNT DEFINITION SUCCESS",
    "data": [
        {
            "caccount_create_time": 1459837097177,
            "caccount_supports": [
                {
                    "data_type": "string",
                    "label": "First Name",
                    "required": true
                },
                {
                    "data_type": "string",
                    "label": "Last Name",
                    "required": true
                },
                {
                    "data_type": "string",
                    "label": "Contact",
                    "required": true
                }
            ],
            "account_id": "56dd7e6369dadfd3f93a84b7",
            "_id": {
                "$oid": "5703580869da20736bdf82e4"
            },
            "posted_date": {
                "$date": "2016-04-05T06:18:17.177Z"
            },
            "caccount_identifiers": [
                {
                    "data_type": "string",
                    "label": "Email",
                    "required": true
                }
            ]
        }
    ]
}

This endpoint will retrive the caccount definition. It will return all the information like the identifier fields, the labels and their data type.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getcaccountdef

Get CAccounts

curl "https://developer.mafoianalytics.com/epoch/process/getcaccounts"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {
                "Email": "example@example.com"
            },
            "project": [
                "First Name"
            ],
            "sort": {
                "First Name": 1
            },
            "limit": 1
        }
    }'

The above command returns JSON structured like this:

{
  "status_code": "200",
  "status_txt": "GETTING CACCOUNTS SUCCESS",
  "data": [
    {
      "_id": {
        "$oid": "57035aee69da696739e62a3b"
      },
      "First Name": "Example"
    }
  ]
}

Caccounts are the client accounts which are created in your application. This endpoint will return all the caccounts associated with your account based on the query filters.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getcaccounts

Get Member Definition

curl "https://developer.mafoianalytics.com/epoch/process/getmemberdef"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {}
        }
    }'

The above command returns JSON structured like this:

{
  "member_create_time": 1459438922757,
  "account_id": "56dd7e6369dadfd3f93a84b7",
  "_id": {
    "$oid": "56fd454a69da86fe40a67544"
  },
  "member_supports": [
    {
      "data_type": "string",
      "label": "First Name",
      "required": true
    },
    {
      "data_type": "string",
      "label": "Last Name",
      "required": true
    },
    {
      "data_type": "string",
      "label": "Phone",
      "required": true
    }
  ],
  "posted_date": {
    "$date": "2016-03-31T15:42:02.757Z"
  },
  "member_identifiers": [
    {
      "data_type": "string",
      "label": "Email",
      "required": true
    }
  ]
}

This endpoint will get the definition of the member schema.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getmemberdef

Get Members

curl "https://developer.mafoianalytics.com/epoch/process/getmembers"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {
                "Email": "example@example.com"
            },
            "project": [
                "First Name",
                "Last Name",
                "Email"
            ],
            "limit": 1
        }
    }'

The above command returns JSON structured like this:

{
  "status_code": "200",
  "status_txt": "GETTING MEMBERS SUCCESS",
  "data": [
    {
      "Email": "example@example.com",
      "_id": {
        "$oid": "56fd480f69da86fe40a67546"
      },
      "Last Name": "Example",
      "First Name": "Example"
    }
  ]
}

Memebers are the end users of the application.This endpoint will return all the members in the application based on the query filters. This is useful to see the details of the members in the application.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getmembers

Export Members

curl -X GET
"https://developer.mafoianalytics.com/epoch/store/member?api_key=<API_KEY>&api_secret=<API_SECRET>"

If you are looking to export all the member names and their details on to a CSV file then you have to use the Export Members API. This endpoint will export all the members in to a CSV file.

Get Activity Definition

curl "https://developer.mafoianalytics.com/epoch/process/getactivitydef"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {
                "activity_name": "testactivity1"
            }
        }
    }'

The above command returns JSON structured like this:

{
    "status_code": "200",
    "status_txt": "GETTING ACTIVITY DEFINITION SUCCESS",
    "data": [
        {
            "activity_create_time": 1461577806069,
            "member_template": false,
            "activity_fields": {
                "data_type": "string",
                "label": "Activity 1 Field 1",
                "required": true
            },
            "activity_state": "PUBLISHED",
            "account_id": "56dd7e6369dadfd3f93a84b7",
            "_id": {
                "$oid": "571de84e68c2a0a3d5bf2d33"
            },
            "posted_date": {
                "$date": "2016-04-25T09:50:06.069Z"
            },
            "activity_desc": "Feedback Form Desc",
           "activity_name": "testactivity1"
        },
        {
            "activity_create_time": 1461577806070,
            "member_template": false,
            "activity_fields": {
                "data_type": "string",
                "label": "Activity 1 Field 2",
                "required": true
            },
            "activity_state": "PUBLISHED",
            "account_id": "56dd7e6369dadfd3f93a84b7",
            "_id": {
                "$oid": "571de84e68c2a0a3d5bf2d34"
            },
            "posted_date": {
                "$date": "2016-04-25T09:50:06.070Z"
            },
            "activity_desc": "Feedback Form Desc",
            "activity_name": "testactivity1"
        },
        {
            "activity_create_time": 1461577806070,
            "member_template": true,
            "activity_state": "PUBLISHED",
            "account_id": "56dd7e6369dadfd3f93a84b7",
            "_id": {
                "$oid": "571de84e68c2a0a3d5bf2d35"
            },
            "posted_date": {
                "$date": "2016-04-25T09:50:06.070Z"
            },
            "activity_desc": "Feedback Form Desc",
            "activity_name": "testactivity1",
            "member_fields": [
                "First Name",
                "Phone",
                "Email"
            ]
        }
    ]
}

This endpoint will retrive the activity definitions based on the query conditions.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getactivitydef

Get Activities

curl "https://developer.mafoianalytics.com/epoch/process/getactivities"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query":{
                    "activity_name": "testactivity1"
            },
            "project":[],
            "sort":{},
            "limit":0
        }
    }'

The above command returns JSON structured like this:

{
  "status_code": "200",
  "data": [
    {
      "member_id": "57dbd7690a69b50f2fa7e020",
      "activity_name": "testactivity1",
      "Email": "test@test.com",
      "_posted_date": 1474025321804,
      "_modified_date": 1474026250983,
      "Phone": "9876543210",
      "First Name": "Test Name",
      "Activity 1 Field 1": "Value 1",
      "_id": {
        "$oid": "57dbd769f48540f2c64090a7"
      },
      "Activity 1 Field 2": "Value 22"
    },
    {
      "member_id": "57dbd7690a69b50f2fa7e020",
      "activity_name": "testactivity1",
      "Email": "test@test.com",
      "_posted_date": 1474025652661,
      "Phone": "9876543210",
      "First Name": "Test Name",
      "Activity 1 Field 1": "Value 1",
      "_id": {
        "$oid": "57dbd8b4f48540f2c64090a8"
      },
      "Activity 1 Field 2": "Value 2"
    },
    {
      "member_id": "57dbd7690a69b50f2fa7e020",
      "activity_name": "testactivity1",
      "Email": "test@test.com",
      "_posted_date": 1474025929508,
      "Phone": "9876543210",
      "First Name": "Test Name",
      "Activity 1 Field 1": "Value 1",
      "_id": {
        "$oid": "57dbd9c9f48578fc1d12642a"
      },
      "Activity 1 Field 2": "Value 2"
    }
  ],
  "status_txt": "GETTING ACTIVITIES SUCCESS"
}

This endpoint retrieves the activities which match the query filters passed.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getactivities

Get Object Definition

curl "https://developer.mafoianalytics.com/epoch/process/getobjectdef"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "query": {
                "object_name": "object1"
            }
        }
    }'

The above command returns JSON structured like this:

{
    "status_code": "200",
    "status_txt": "GETTING OBJECT DEFINITION SUCCESS",
    "data": [
        {
            "object_desc": "description",
            "member_template": false,
            "object_fields": {
                "label": "Object 1 Field 1",
                "data_type": "string",
                "required": true
            },
            "object_posted_time": 1461578180743,
            "account_id": "56dd7e6369dadfd3f93a84b7",
            "_id": {
                "$oid": "571de9c468c2a0a3d5bf2d37"
            },
            "object_name": "object1",
            "posted_date": {
                "$date": "2016-04-25T09:56:20.743Z"
            },
            "object_state": "PUBLISHED"
        },
        {
            "object_desc": "description",
            "member_template": false,
            "object_fields": {
                "label": "Object 1 Field 2",
                "data_type": "string",
                "required": true
            },
            "object_posted_time": 1461578180743,
            "account_id": "56dd7e6369dadfd3f93a84b7",
            "_id": {
                "$oid": "571de9c468c2a0a3d5bf2d38"
            },
            "object_name": "object1",
            "posted_date": {
                "$date": "2016-04-25T09:56:20.743Z"
            },
            "object_state": "PUBLISHED"
        },
        {
            "object_desc": "description",
            "member_template": false,
            "object_fields": {
                "label": "Object 1 Field 3",
                "data_type": "string",
                "required": true
            },
            "object_posted_time": 1461578180744,
            "account_id": "56dd7e6369dadfd3f93a84b7",
            "_id": {
                "$oid": "571de9c468c2a0a3d5bf2d39"
            },
            "object_name": "object1",
            "posted_date": {
                "$date": "2016-04-25T09:56:20.744Z"
            },
            "object_state": "PUBLISHED"
        }
    ]
}

This endpoint will give you the object definition.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getobjectdef

Get Objects

curl "https://developer.mafoianalytics.com/epoch/process/getobjects"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "{{api_key}}",
        "api_secret": "{{api_secret}}",
        "data": {
            "query":{
                    "object_name": "object1"
            },
            "project":[],
            "sort":{},
            "limit":1
        }
    }'

The above command returns JSON structured like this:

{
  "status_code": "200",
  "data": [
    {
      "Object 1 Field 3": "Field 3 value",
      "Object 1 Field 2": "Field 1 value 22",
      "_posted_date": 1474027754128,
      "_modified_date": 1474027865272,
      "Object 1 Field 1": "Field 1 value",
      "object_name": "object1",
      "_id": {
        "$oid": "57dbe0eaf48578fc1d12642e"
      }
    }
  ],
  "status_txt": "GETTING OBJECTS SUCCESS"
}

This endpoint will get the objects which satisfy the given query filters.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/getobjects

Rule Engine

EpocH has three types of rule logic definitons that can be triggered in two ways.

The three types of rule logic definitions available are:

Today-7 means EpocH checks for data any day before a week (7days)

Define Rule

curl "https://developer.mafoianalytics.com/epoch/process/definerule"
-X POST
-H "Content-Type: application/json"
-d '
{
    "api_key": "<YOUR API_KEY>",
    "api_secret": "<YOUR API_SECRET>",
    "data": {
    "rule_name": "testrule",
    "rule_desc": "Stores the details of the rules",
    "rule_state": "PUBLISHED",
    "inputvars": [
        {
            "label": "mobileexists",
            "data_type": "boolean",
            "required": true
        },
        {
            "label": "dob",
            "data_type": "date",
            "required": false,
            "format": "yyyy/mm/dd"
        },
        {
            "label": "anniv",
            "data_type": "date",
            "required": false,
            "format": "yyyy/mm/dd"
        },
        {
            "label": "lastvisit",
            "data_type": "date",
            "required": false,
            "format": "yyyy/mm/dd"
        }
    ],
    "rules": {
        "trigger_all": [
            {
                "rule_id": "1",
                "rule_type": "datecheck",
                "label": "lastvisit",
                "before": "today-7",
                "action_type": "message",
                "return": "Happy to have you back so soon"
            },
            {
                "rule_id": "2",
                "rule_type": "datecheck",
                "label": "dob",
                "before": "today+7",
                "action_type": "message",
                "return": "Advance Happy Bday"
            },
            {
                "rule_id": "3",
                "rule_type": "daterangecheck",
                "label": "anniv",
                "start": "today-7",
                "end": "today+7",
                "action_type": "message",
                "return": "Happy Anniversary"
            },
            {
                "rule_id": "4",
                "rule_type": "daterangecheck",
                "label": "dob",
                "start": "today",
                "end": "today",
                "action_type": "message",
                "return": "Happy Birthday"
            },
            {
                "rule_id": "5",
                "rule_type": "booleancheck",
                "label": "mobileexists",
                "value": true,
                "action_type": "message",
                "return": "Welcome back!"
            }
        ]
    }
}
}'

The above command returns JSON structured like this:

{
  "status_txt": "RULE CREATION SUCCESS",
  "status_code": "200"
}

This endpoint is used to define rules in EpocH. Multiple rules can be defined in a array. Each rule has to have input variable, rule id, Priority of the rule and an action type. Rule trigger all means all the rules will be executed. If rule trigger is one then once a condition matches and a rule is triggered the rule execution stops.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/definerule

Evaluate Rule

curl "https://developer.mafoianalytics.com/epoch/process/evaluaterule"
-X POST
-H "Content-Type: application/json"
-d '
{
    "api_key": "<YOUR API_KEY>",
    "api_secret": "<YOUR API_SECRET>",
    "data": {
        "rule_name": "testrule",
        "inputvars": {
            "mobileexists": true,
            "dob": "2016/07/18",
            "anniv": "2016/07/10",
            "lastvisit": "2016/07/07"
        }
    }
}'

The above command returns JSON structured like this:

{
    "status_txt": "RULE ENGINE EVALUATON SUCCESS",
    "status_code": "200",
    "data": {
        "trigger_all": [
            {
                "rule_id": "1",
                "rule_status": "Success",
                "return": "Happy to have you back so soon"
            },
            {
                "rule_id": "2",
                "rule_status": "Success",
                "return": "Advance Happy Bday"
            },
            {
                "rule_id": "3",
                "rule_status": "Success",
                "return": "Happy Anniversary"
            },
            {
                "rule_id": "4",
                "rule_status": "Failure",
                "return": ""
            },
            {
                "rule_id": "5",
                "rule_status": "Success",
                "return": "Welcome back!"
            }
        ]
    }
}

This endpoint is used to evaluate the rule on a set of data. It returns the success status when a rule is satisfied or a Failure status when the rule if not satisfied.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/evaluaterule

Update Rule

curl "https://developer.mafoianalytics.com/epoch/process/definerule"
-X POST
-H "Content-Type: application/json"
-d '
{
    "api_key": "<YOUR API_KEY>",
    "api_secret": "<YOUR API_SECRET>",
    "data": {
    "rule_name": "testrule",
    "rule_desc": "Stores the details of the rules",
    "rule_state": "PUBLISHED",
    "inputvars": [
        {
            "label": "mobileexists",
            "data_type": "boolean",
            "required": true
        },
        {
            "label": "dob",
            "data_type": "date",
            "required": false,
            "format": "yyyy/mm/dd"
        },
        {
            "label": "anniv",
            "data_type": "date",
            "required": false,
            "format": "yyyy/mm/dd"
        },
        {
            "label": "lastvisit",
            "data_type": "date",
            "required": false,
            "format": "yyyy/mm/dd"
        }
    ],
    "rules": {
        "trigger_all": [
            {
                "rule_id": "5",
                "rule_type": "datecheck",
                "label": "lastvisit",
                "before": "today-7",
                "action_type": "message",
                "return": "Happy to have you back so soon"
            },
            {
                "rule_id": "2",
                "rule_type": "datecheck",
                "label": "dob",
                "before": "today+7",
                "action_type": "message",
                "return": "Advance Happy Bday"
            },
            {
                "rule_id": "3",
                "rule_type": "daterangecheck",
                "label": "anniv",
                "start": "today-7",
                "end": "today+7",
                "action_type": "message",
                "return": "Happy Anniversary"
            },
            {
                "rule_id": "4",
                "rule_type": "daterangecheck",
                "label": "dob",
                "start": "today",
                "end": "today",
                "action_type": "message",
                "return": "Happy Birthday"
            },
            {
                "rule_id": "1",
                "rule_type": "booleancheck",
                "label": "mobileexists",
                "value": true,
                "action_type": "message",
                "return": "Welcome back!"
            }
        ]
    }
}
}'

The above command returns JSON structured like this:

{
 "status_txt": "RULE DEFINITION UPDATE SUCCESS",
 "status_code": "200"
}

This endpoint is used to make changes to the existing rule definition. You can update the labels, order of the rule, rule type etc.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/process/updaterule

Intelligence APIs

Intelligence APIs enable access to and analysis of information to improve and optimize decisions and performance.

Vision API

This API endpoint helps in image analysis.

The input is the file url and an input json as shown in the shell script.

The type inside the data in input_json represents the different features to detect for each image.You can either request for one feature or multiple features.

curl
-X POST
-F "file=@your_image_file"
"https://developer.mafoianalytics.com/epoch/intelligence/vision?
input_json={"api_key":"<API_KEY>","api_secret":"<API_SECRET>","data":{"type":["faces", "landmarks", "logos", "labels", "text", "safeSearch", "imageProperties"]}}" 

The above command returns JSON structured like this:

{
    "status_code": 200,
    "data": {
        "logoAnnotations": [
            {
                "mid": "1tcwrfq3",
                "description": " Motocicleta",
                "score": 0.78437775,
                "boundingPoly": {
                    " vertices": [
                        {
                            "x": 75,
                            "y": 107
                        },
                        {
                            " x": 1805,
                            "y": 107
                        },
                        {
                            "x": 1805,
                            "y": 968
                        },
                        {
                            "x": 75,
                            "y": 968
                        }
                    ]
                }
            }
        ],
        "labelAnnotations": [
            {
                "mid": "/ m/0k4j",
                "description": "car",
                " score": 0.97801197
            },
            {
                "mid": "/ m/07yv9",
                "description": " vehicle",
                "score": 0.93962145
            },
            {
                "mid": "/m/01prls",
                " description": "land vehicle",
                "score": 0.91292679
            },
            {
                "mid": "/m/068mqj",
                " description": "automotive design",
                "score": 0.77788007
            },
            {
                " mid": "/m/025sn53",
                " description": "motorcycling",
                " score": 0.77373064
            }
        ],
        "textAnnotations": [
            {
                "locale": " en",
                "description": "YAMAHA\n",
                " boundingPoly": {
                    "vertices": [
                        {
                            " x": 979,
                            "y": 849
                        },
                        {
                            "x": 1202,
                            "y": 849
                        },
                        {
                            "x": 1202,
                            "y": 904
                        },
                        {
                            "x": 979,
                            "y": 904
                        }
                    ]
                }
            },
            {
                "description": "YAMAHA",
                "boundingPoly": {
                    " vertices": [
                        {
                            "x": 981,
                            "y": 849
                        },
                        {
                            "x": 1202,
                            "y": 859
                        },
                        {
                            "x": 1200,
                            " y": 904
                        },
                        {
                            "x": 979,
                            "y": 894
                        }
                    ]
                }
            }
        ],
        "safeSearchAnnotation": {
            " adult": "VERY_UNLIKELY",
            "spoof": "VERY_UNLIKELY",
            "medical": " VERY_UNLIKELY",
            "violence": " VERY_UNLIKELY"
        },
        "imagePropertiesAnnotation": {
            " dominantColors": {
                "colors": [
                    {
                        " color": {
                            "red": 25,
                            "green": 24,
                            " blue": 27
                        },
                        "score": 0.15948296,
                        " pixelFraction": 0.17571428
                    },
                    {
                        " color": {
                            "red": 162,
                            "green": 35,
                            " blue": 36
                        },
                        "score": 0.0701718,
                        " pixelFraction": 0.0049206349
                    },
                    {
                        "color": {
                            "red": 200,
                            "green": 200,
                            "blue": 199
                        },
                        "score": 0.058445729,
                        "pixelFraction": 0.0681746
                    },
                    {
                        "color": {
                            "red": 220,
                            " green": 57,
                            "blue": 38
                        },
                        "score": 0.052854374,
                        "pixelFraction": 0.0018253968
                    },
                    {
                        "color": {
                            "red": 108,
                            "green": 27,
                            "blue": 30
                        },
                        " score": 0.042245727,
                        "pixelFraction": 0.0046825395
                    },
                    {
                        "color": {
                            "red": 49,
                            "green": 48,
                            "blue": 50
                        },
                        " score": 0.13062853,
                        " pixelFraction": 0.13880952
                    },
                    {
                        " color": {
                            "red": 201,
                            "green": 65,
                            " blue": 56
                        },
                        "score": 0.052853107,
                        "pixelFraction": 0.003095238
                    },
                    {
                        "color": {
                            "red": 208,
                            "green": 59,
                            "blue": 39
                        },
                        "score": 0.051564045,
                        "pixelFraction": 0.0018253968
                    },
                    {
                        "color": {
                            "red": 234,
                            "green": 233,
                            "blue": 233
                        },
                        " score": 0.033319179,
                        " pixelFraction": 0.42095238
                    },
                    {
                        " color": {
                            "red": 138,
                            "green": 53,
                            " blue": 54
                        },
                        "score": 0.028558223,
                        "pixelFraction": 0.0032539682
                    }
                ]
            }
        }
    },
    "status_txt": "IMAGE ANALYSIS SUCCESS"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/intelligence/vision

EQL APIs

EpocH has its own Query Language known as EQL and the following APIs are all part of the EQL set.

Script Upload

This API endpoint helps in uploading R-program or Python scripts into EpocH.

curl
-X POST
-H "Content-Type: multipart/form-data;boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
-F "file=@file_name.R"
"https://developer.mafoianalytics.com/epoch/intelligence/scriptupload?
input_json={%22api_key%22%3A%22%3CAPI_KEY%3E%22%2C%22api_secret%22%3A%22%3CAPI_SECRET%3E%22%2C%22data%22:{%22type%22%3A%22rcode%22}}"

The above command returns JSON structured like this:

{
    "status_code": 200,
    "status_txt": "SCRIPT UPLOAD SUCCESS"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/intelligence/scriptupload

Processor API(without action)

There are two types of EQL processor APIs:

curl "https://developer.mafoianalytics.com/epoch/intelligence/eqlprocessor"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "eql": {
            "limit": 10,
            "dimension": {
                "category_type": {
                    "label": "Category Type",
                    "operator": "count",
                    "order": "desc"
                },
                "product_category_id": {
                    "label": "Product Category",
                    "operator": "count",
                    "order": "asc"
                }
            },
            "measure": {
                "final_txn_amount": {
                    "order": "desc",
                    "label": "Net Sales",
                    "operator": "sum"
                },
                "product_price": {
                    "order": "desc",
                    "label": "MRP",
                    "operator": "avg"
                }
            },
            "db_name": "transactional",
            "db_type": "activity",
            "query_type": "aggregation",
            "group": [
                "product_category_desc",
                "commission_type",
                "category_type",
                "product_category_id"
            ]
        }
    }
}'

The above command returns JSON structured like this:

{
    "status_code": 200,
    "status_txt": "SEARCH SUCCESS",
    "data": {
        "output": [
            {
                "commission_type": "PERCENTAGE",
                "product_price": 237.38610418084,
                "final_txn_amount": 3336109,
                "category_type.count": 13227,
                "category_type": "PP",
                "product_category_id": 48,
                "product_category_desc": "Skin Care & Eye Care",
                "product_category_id.count": 13227
            },
            {
                "commission_type": "-",
                "product_price": 311.37456886641,
                "final_txn_amount": 1243839,
                "category_type.count": 4349,
                "category_type": "PP",
                "product_category_id": 2510,
                "product_category_desc": "Deals in FMCG",
                "product_category_id.count": 4349
            }
        ]
    }
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/intelligence/eqlprocessor

Processor API(with action)

curl "https://developer.mafoianalytics.com/epoch/intelligence/eqlprocessor"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "eql": {
            "limit": 10,
            "dimension": {
                "category_type": {
                    "label": "Category Type",
                    "operator": "count",
                    "order": "desc"
                },
                "product_category_id": {
                    "label": "Product Category",
                    "operator": "count",
                    "order": "asc"
                }
            },
            "measure": {
                "final_txn_amount": {
                    "order": "desc",
                    "label": "Net Sales",
                    "operator": "sum"
                },
                "product_price": {
                    "order": "desc",
                    "label": "MRP",
                    "operator": "avg"
                }
            },
            "action": {
                "type": "rcode",
                "file": "filename.R"
            },
            "db_name": "transactional",
            "db_type": "activity",
            "query_type": "aggregation",
            "group": [
                "product_category_desc",
                "commission_type",
                "category_type",
                "product_category_id"
            ]
        }
    }
}'

The above command returns JSON structured like this:

{

    "status_code": 200,
    "status_txt": "SCRIPT SUCCESS",
    "data": {
        "event_id": "585d241583929bf32e8d71d6"
    }
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/intelligence/eqlprocessor

Processor Event Status

This API endpoint is used to check the status of the request from the previous processor API and return the result of the query in the processor API when the status is outputjson. If the status is inputjson or processing the previous query has still not executed and the summary results will not be available yet.

curl "https://developer.mafoianalytics.com/epoch/intelligence/processoreventstatus"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",

"data": {
        "event_id": "585d241583929bf32e8d71d6"
    }
}'

The above command returns JSON structured like this:

{
    "status_code": 200,
    "status_txt": "SEARCH SUCCESS",
    "data": {
        "status": "outputjson",
        "output": [
            {
                "commission_type": "PERCENTAGE",
                "product_price": 237.39,
                "final_txn_amount": 3336100,
                "category_type.count": 13227,
                "category_type": "PP",
                "product_category_id": 48,
                "product_category_desc": "Skin Care & Eye Care",
                "product_category_id.count": 13227
            },
            {
                "commission_type": "-",
                "product_price": 311.37,
                "final_txn_amount": 1243800,
                "category_type.count": 4349,
                "category_type": "PP",
                "product_category_id": 2510,
                "product_category_desc": "Deals in FMCG",
                "product_category_id.count": 4349
            }
        ]
    }
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/intelligence/processoreventstatus

Click Stream APIs

Click stream is a Sequence or ‘flow’ of mouse clicks or keystrokes which a user makes in navigating through webpages or websites.As the user clicks anywhere in the webpage or application, the action is logged on as an event and pushed into EpocH.

Event is a software message indicating that something has happened, such as a keystroke or mouse click.

CLick Stream APIs are useful where large amount of data has to be

This micro service has a set of APIs which help in storing and retrieving click stream data.Using this service is simple with just 3 APIs.

Define Event

curl "https://developer.mafoianalytics.com/epoch/cs/defineevent"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "event_name": "event1",
        "event_state": "PUBLISHED",
        "event_desc": "description",
        "event_fields": [
            {
                "label": "Object 1 Field 1",
                "data_type": "string",
                "required": true
            },
            {
                "label": "Object 1 Field 2",
                "data_type": "string",
                "required": true
            }
        ]
    }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "EVENT CREATION SUCCESS",
    "status_code": "200"
}

This endpoint will define the events that have to be pushed into EpocH.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/cs/defineevent

Add Event


curl "https://developer.mafoianalytics.com/epoch/cs/addevent"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "event_name": "event1",
        "Object 1 Field 1": "Field 1 value",
        "Object 1 Field 2": "Field 2 value"
    }
    }'

The above command returns JSON structured like this:

{
    "status_txt": "ADD EVENT SUCCESS",
    "status_code": "200"
}

This endpoint will store the events into EpocH. The event was defined in the previous API. This endpoint lets you push the event data into EpocH

HTTP Request

POST https://developer.mafoianalytics.com/epoch/cs/addevent


curl "https://developer.mafoianalytics.com/epoch/cs/search"
-X POST
-H "Content-Type: application/json"
-d '{
    "api_key": "<API_KEY>",
    "api_secret": "<API_SECRET>",
    "data": {
        "type": "event",
        "name": "event1",
        "query": {
            "size": "20"
        }
    }
    }'

The above command returns JSON structured like this:

{
    "data": {
        "_shards": {
            "total": 5,
            "failed": 0,
            "successful": 5
        },
        "hits": {
            "hits": [
                {
                    "_index": "epoch.xxxxxxxx.event.event1",
                    "_type": "logs",
                    "_source": {
                        "_posted_date": 1475046150715,
                        "@timestamp": "2016-09-28T07:02:30.758Z",
                        "user_id": 1473,
                        "@version": "1",
                        "event_name": "event1",
                        "field1": "value1"
                    },
                    "_id": "AVdvmhOvSN0MFK-kYdtT",
                    "_score": 1
                }
            ],
            "total": 2640,
            "max_score": 1
        },
        "took": 17,
        "timed_out": false
    },
    "status_txt": "SEARCH SUCCESS",
    "status_code": "200"
}

This endpoint will retrieve the events based on the query parameters. The no of the results returned can be specified using the 'size’ parameter.

HTTP Request

POST https://developer.mafoianalytics.com/epoch/cs/search

Real Time Messaging API

EpocH supports real time messaging through this micro service. This API lets you push messages in real time.This endpoint will send the message to the matching user id and username.


curl "https://developer.mafoianalytics.com/epoch/rtm/sendmessage"
-X POST
-H "Content-Type: application/json"
-d '{
        "api_key": "<API_KEY>",
        "api_secret": "<API_SECRET>",
        "data": {
            "event": "event1",
            "message": {
                "user_id":1234,
                "username":"user1",
                "message":"message for the user"
            },
            "room":"room1"
        }
    }'

The above command returns JSON structured like this:


{
    "status_txt": "SENDING MESSAGE TO SOCKET SUCCESS",
    "status_code": "200"
}

HTTP Request

POST https://developer.mafoianalytics.com/epoch/rtm/sendmessage