API Documentation

Overview

This document describes how to use the EATLAB API to retrieve data from EATLAB, to add information into the system and to instruct EATLAB to execute actions. This overview section presents a list of all available function calls.

General Functions

Subscribe
Creates a corresponding user in EATLAB database

GetBranchInformation
Returns the most recent available information of the branch or outlet location

GetMealTimeInformation

Returns the most recent details on the available mealtime of the branch or outlet location

GetSaleChannelInformation
Returns all available sales channels of the branch or outlet location

AddTransactions

Updates database with transactions data to keep model outputs up to date

Campaign Production

GetDiscountedSet
Returns an output array containing details of the volume-driven promotional campaign

GetDiscountedSetByBranchId
Returns an output array containing details of the volume-driven promotional campaign by outlet's ID

GetDiscountedSetBySaleChannel
Returns an output array containing details of the volume-driven promotional campaign by sales channel

GetDiscountedSetByMealTime

Returns an output array containing details of the volume-driven promotional campaign by meal time

GetNonDiscountedSet
Returns an output array containing details of the value-based, no-discount promotional campaign

GetNonDiscountedSetByBranchID
Returns an output array containing details of the value-based, no-discount promotional campaign by outlet's ID

GetNonDiscountedSetBySaleChannel
Returns an output array containing details of the value-based, no-discount promotional campaign by sales channel

GetNonDiscountedSetByMealTime
Returns an output array containing details of the value-based, no-discount promotional campaign by meal time

GetBundleSet
Returns an output array containing details of the margin-based promotional campaign

GetBundleSetByBranchID
Returns an output array containing details of the margin-based promotional campaign by outlet's ID

GetBundleSetBySaleChannel
Returns an output array containing details of the margin-based promotional campaign by sales channel

GetBundleSetByMealTime
Returns an output array containing details of the margin-based promotional campaign by meal time

GetBuyXGetYSet
Returns an output array containing details of the conditional promotional campaign

GetBuyXGetYSetByBranchID
Returns an output array containing details of the conditional promotional campaign by outlet's ID

GetBuyXGetYSetBySaleChannel
Returns an output array containing details of the conditional promotional campaign by sales channel

GetBuyXGetYSetByMealTime
Returns an output array containing details of the conditional promotional campaign by meal time

GetOptimizedSet
Returns an output array containing details of the most optimized promotional campaign

GetOptimizedSetByBranchID
Returns an output array containing details of the most optimized promotional campaign by outlet's ID

GetOptimizedSetBySaleChannel
Returns an output array containing details of the most optimized promotional campaign by sales channel

GetOptimizedSetByMealTime
Returns an output array containing details of the most optimized promotional campaign by meal time

GetSortingMenu
Returns an output array containing details of the sequence of menu items that should be displayed to maximize conversion rate

GetSortingMenuByBranchID
Returns an output array containing details of the sequence of menu items that should be displayed to maximize conversion rate by outlet's ID

GetSortingMenuBySaleChannel
Returns an output array containing details of the sequence of menu items that should be displayed to maximize conversion rate by sales channel

GetSortingMenuByMealTime
Returns an output array containing details of the sequence of menu items that should be displayed to maximize conversion rate by meal time

Campaign Optimization

GetSearchableListByDiscount
Returns an array of available discount ranges to be used as an input to
the GetDiscountedSetByDiscount function

GetDiscountedSetByDiscount
Returns the volume-driven promotion suggestions by the specified discount range

GetSearchableListByMenuName

Returns an array of available menu names to be used as an input to the GetDiscountedSetByMenuName function

GetDiscountedSetByMenuName
Returns the volume-driven promotion suggestions that contain the specified menu name

Getting Started

Authentication


In order to access an API you must create a JWT token by composing a API key and secret by use following step:

Header
JWT must have a header which is algo is HS256 which we use to produce and check correction of the token. other algorithm may produce unexpected result from our API

typ is JWT
{  
   "alg": "HS256",  
   "typ": "JWT"
}

Payload
The payload must contains two claims. which is holding the information of user identity and expiration time. iss, the issuer of the token which is API key exp, is the expiration timestamp of the token in seconds in Epoch format
{  
     "iss": "API_KEY",  
     "exp": 1661829197


Signature
The algorithm of signature must use HMACSHA256 by contains the Payload and Header and using you API Secret to encrypt the JWT token.

HMACSHA256(
    base64UrlEncode(header) + "." +
    base64UrlEncode(payload),
    API_SECRET)
Ref: https://jwt.io/

Note
You can use any JWT libs to sign the token. Please make sure you're setting the header and payload correctly according to the above instruction.

Data Types

All data values passed to/from the API are of one of the following data types:

  • date : Eight numerals delimited by dashes in the format YYYY-MM-DD
  • null : No data
  • BranchID : A string indicating a Branch ID. When a transaction data is added, it must be associated with a particular branch with BranchID.
  • CompanyName : A string indicating the registered account name
  • integer : A whole number greater than or equal to 0
  • double : A signed floating-point number
  • string : A string of non-case-sensitive alphanumeric characters of any length, using any encoding
  • StringArray : A JSON-formatted array of string values
  • boolean : A string equal to either "true" or "false"
Empty Response

An empty response from any function indicates that the inputs were valid, but no data exists.

Error Response Codes

A successful API call will return a response code of 200 (success). However, any  unsuccessful call shall return one of the following codes:

  • 400 : If any of the inputs to a function are unrecognized or invalid, HTTP response code 400 (Bad Request) will be returned.
  • 401 : If the  authentication token is invalid, HTTP response code 401 (Unauthorized) will be returned.
  • 403 : For an expired authentication OR some of the attributes used within in a call are not authorized for the user
  • 405 : If an unrecognized function is called, HTTP response code 405 (Method Not Allowed) will be returned.
  • 429 : If the Login function is called too many times while a valid exists, HTTP response code 429 (Too Many Requests or User Already Logged In) wreturned.
  • 500 : If the credentials specified in the Login function are invalid, HTTP response code 500 (Internal Server Error) will be returned.