Skip to content

API reference

Sending interactions

A detail view of item PRODUCT_1 by user USER_1 can be send to the recommendation engin using REST call or JavaScript as shown below:

function downloadJSAtOnload() {
    m_k = 'Merchant key' // Merchant key from your https://app.oorjit.ai account
    event_type = "pageview",  // Possible values are pageview, addtocart, sale
    user_hash = "USER_1" // user id
    product = {
                id: 'PRODUCT_1', // Product id
                sku: 'PRODUCT_1_SUK', // Product SKU
                name: 'PRODUCT_1_NAME', // Product name
                price: '13065', // Product price
                quantity : 1,
                stype: "direct" // Possible values are widget, catalog, direct
              }
    var e, t = document.getElementsByTagName("script")[0]
    n = document.createElement("script")
    o = {
        k: m_k,
        t: event_type,
        u: user_hash,
        products: [product]
    }
    r = "https://ai-rec-api.oorjit.ai/track/event?d="+encodeURIComponent(JSON.stringify(o))
    n.defer = "defer", n.type = "text/javascript", n.src = r, t.parentNode.insertBefore(n, t)
}
if (window.addEventListener)
    window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
    window.attachEvent("onload", downloadJSAtOnload);
else 
    window.onload = downloadJSAtOnload;       
POST /track/event HTTP/1.0
Host: ai-rec-api.oorjit.ai
Content-type: application/json

Body:
    {
        k: "Merchant key",
        t: "pageview",
        u: "USER_1",
        products: [{
                id: 'PRODUCT_1',
                sku: 'PRODUCT_1_SUK',
                name: 'PRODUCT_1_NAME',
                price: '13065',
                quantity : 1,
                stype: "direct"
            }]
    }

Fields are,

Field Type Deatils
m_k String Merchant key from your https://app.oorjit.ai account
event_type String Possible values are pageview, addtocart, sale. Use 'pageview' for page view interaction. Use 'addtocart' for sending add to cart interaction. Use 'sale' for sending sale interaction.
user_hash String Unique identifies for the customer. It is recommended to use hash value of unique identifier so the unique identifier won't get expossed.
product Array Multiple items can be added for 'sales' integraction. 'pageview' and 'addtocar' support one item only
id String Unique id of the product
sku String SKU of the product
name String Name of the product
price Float Price of the product without currency. You can set the currency from your https://app.oorjit.ai account
quantity Intiger Set as 1 for product view. This field can be used to specify product quantity while sending 'sale' interaction
stype String Use the value 'direct' if the user reached this product not from any recommended item by Oorjit AI. If the customer clicked this product from recommendation widget, use the value 'widget'. If the customer reached this product from the sorted catalog using Oorjit AI recommendation, use the value 'catalog'

Getting recommendations

Once the tracking API get enought data (Interactions from aleast 2K customers), You can use recommendation API to get recommendation for each users.

Get recommendation for the user USER_1

POST /serve HTTP/1.0
Host: ai-rec-api.oorjit.ai
Content-type: application/json

Body:
    {
        merchant_id: 'Merchant key'
        user_id: "USER_1" 
    }

Request fields are,

Field Type Deatils
merchant_id String Merchant key from your https://app.oorjit.ai account
user_id String Unique identifies for the customer. It is recommended to use hash value of unique identifier. For a specific user, this should be same as the user_id send to tracking API

Sample Response

   {
   "status":"Success",
   "message":"",
   "results":[
        {
         "product_seq_id": 123,
         "product_id": "1234", 
         "score": .88
         },        
         {
         "product_seq_id": 456,
         "product_id": "1235", 
         "score": .85
         },        
         {
         "product_seq_id": 1000,
         "product_id": "1236", 
         "score": .75
         }
    ]
   }

Response fields are,

Field Type Deatils
status String Possible values are 'Success' & 'Error'
message String If 'status' field is 'Error', This field contain error message, Otherwise empty
results
product_seq_id Intiger No use for now. It is used by the recommendations engin to identify the product
product_id String Actual product id which you have send to tracking API
score Float A value between 0 and 1. Greater the value, the customer more likely to love the product. The product listing is already sorted based on this value in decenting order