API - Data

Overview
Get customer, payment, referral and commission data from your affiliate system. This is useful if you want to set up a tier system and adjust commission based on existing customer commission or referral data.
API Data Structure
The following data should be transmitted with your data calls (shown as standard JSON array):
{
  "apikey": "YOUR API KEY",
  "affiliate": "AFFILIATE CODE",
  "data": {
    "op": "OP NAME",
  }
}

apikey = Your api key as set in the settings. This must be included with all calls.
affiliate = Affiliate code, this would come from the cookie that is set (see below).
data = Array of instructions to get the data you require. See below. The "op" key MUST be included with any of the following values:

payments, commissions, referrals OR info

Additional data can be passed as shown below to filter information. If successful data is returned as shown in the examples below. Also see the error response for error handling.
Get Affiliate Data
To get the affiliate data from the database, send the 'info' op.
{
  "apikey": "YOUR API KEY",
  "affiliate": "AFFILIATE CODE",
  "data": {
    "op": "info"
  }
}

On success call, example of data is as follows (Note that an affiliate password is NOT included in the information for security).

{
  "status": "ok",
  "data": {
    "id": "3",
    "ts": "1536076800",
    "code": "",
    "fname": "John",
    "lname": "Smith",
    "email": "john@example.com",
    "ip": "123.456.789",
    "commtier": "17.5%",
    "payinfo": "",
    "notes": "",
    "approved": "yes",
    "en": "yes"
  }
}


For advanced users. If you add additional fields to the database, those fields will also be returned.
Get Commission Totals
To get the commissions totals from the database, send the 'commissions' op. This will return the commissions and sale totals for each product for the affiliate. Only approved commission totals are returned.
{
  "apikey": "YOUR API KEY",
  "affiliate": "AFFILIATE CODE",
  "data": {
    "op": "commissions"
  }
}

On success call, example of data is as follows.

{
  "status": "ok",
  "data": {
    "4": {
      "commissions": "3",
      "sale_total": "123.78",
      "commission_total": "34.13",
      "last_commission": "1536163200"
    },
    "5": {
      "commissions": "5",
      "sale_total": "347.61",
      "commission_total": "121.14",
      "last_commission": "1536163200"
    }
  }
}


In this example the affiliate had 3 commissions for product 4 & 5 commissions for product 5. If no commissions are available, the 'data' array will be empty and you should check for this occurrence. Last commission value is the timestamp of the last commission logged.

To filter by single product, include the 'product' call.
{
  "apikey": "YOUR API KEY",
  "affiliate": "AFFILIATE CODE",
  "data": {
    "op": "commissions",
    "product": "4"
  }
}


Product value must be a valid product ID as seen in your affiliate control panel. Value is same as returned above but only for the product set.
Get Payment Totals
To get the payments totals from the database, send the 'payments' op. This will return the payment totals for each payment method for the affiliate.
{
  "apikey": "YOUR API KEY",
  "affiliate": "AFFILIATE CODE",
  "data": {
    "op": "payments"
  }
}

On success call, example of data is as follows.

{
  "status": "ok",
  "data": {
    "2Checkout": {
      "payments": "1",
      "payment_total": "24.66",
      "last_payment": "1536336000"
    },
    "Stripe": {
      "payments": "1",
      "payment_total": "3.90",
      "last_payment": "1536336000"
    }
  }
}


In this example the affiliate had 1 payment via "2Checkout" & 1 payment via "Stripe". If no payments are available, the 'data' array will be empty and you should check for this occurrence. Last payment value is the timestamp of the last payment logged.
Get Referral Stats
To get the referral stats from the database, send the 'referrals' op. This will return referrals for each product for the affiliate.
{
  "apikey": "YOUR API KEY",
  "affiliate": "AFFILIATE CODE",
  "data": {
    "op": "referrals"
  }
}

On success call, example of data is as follows.

{
  "status": "ok",
  "data": {
    "1": {
      "referrers": [
        {
          "count": "2987",
          "link": "https://www.example.com"
        }
      ]
    },
    "4": {
      "referrers": [
        {
          "count": "134",
          "link": "https://www.example1.com"
        },
        {
          "count": "23",
          "link": "https://www.example2.com"
        },
        {
          "count": "121",
          "link": "https://www.example3.com"
        }
      ]
    }
  }
}


In this example the affiliate had 1 referral for product 1 & 3 referrals for product 4. If no referrals are available, the 'data' array will be empty and you should check for this occurrence.

To filter by single product, include the 'product' call.
{
  "apikey": "YOUR API KEY",
  "affiliate": "AFFILIATE CODE",
  "data": {
    "op": "referrals",
    "product": "4"
  }
}


Product value must be a valid product ID as seen in your affiliate control panel. Value is same as returned above but only for the product set.
API Error Response
You should handle the responses accordingly if required.

An error response will be as follows:
{
  "status": "error",
  "message": "ERROR MESSAGE"
}
Feature Missing?
If there is a specific call you need, please let us know.
Debugging
If you enable the API log data will be logged in the "logs" folder each time there is a call from the API. Refer to this for help. You should disable the log when you are ready to go live. Note that general errors, referral errors and commissions errors are all logged separately.
Back to API