NATS4 REST API Get Profit Loss Report

From TMM Wiki
Revision as of 13:21, 22 November 2017 by TMMJeff (talk | contribs)
Jump to navigationJump to search
NATS 4
Members Admin
The Members Admin
View Member Details
Add Member
MySQL Auth
Mod Authn DB
Multisite Access
Member Logging
Member Password Retrieval
OpenID Connect
Mod Auth OpenIDC
ID Numbers
SOAP API
API
API Best Practices
WSDL Cache
Add Affiliate
Add Member Note
Admin Get Adtools
Adtool Categories
Adtool Types
Affiliate Get Campaigns
Bulk Import Adtools
Caching
Decode Natscode
Expire Manual Member
Get Affiliate Campaigns
Get Affiliate Hit Data
Get Affiliate Loginids
Get Affiliate Nats Codes
Get Affiliate Payout
Get Affiliate Program Campaign List
Get_Affiliate_Program_Campaign_List
Get Member Details
Get Member Instant Upgrade String
Get Member Package Upgrade String
Get Member Token Rebuy String
Get Member Upsell String
Get Payment Data
Get Payvia Rule
Get Profit Loss Report
Ping
Record Member Login
Search Affiliate Info
Search Member Info
Send Email API Function
Set Affiliate Admin Settings
Set Affiliate Customs
Set Affiliate Defaults
Set Affiliate Information
Set Affiliate Settings
Set Member Details
Set Payment Status
Set Payvia Rule
REST API
API Overview
API Best Practices
REST API PATH UPDATES
Adtools
GET /adtools/admin
GET /adtools/categories
GET /adtools/types
POST /adtools/importdump
Affiliate
GET /affiliate/campaigns
GET /affiliate/hitdata
GET /affiliate/payout
GET /affiliate/searchinfo
POST /affiliate/addaffiliate
POST /affiliate/invoice
PATCH /affiliate/setadminsettings
PATCH /affiliate/setcustoms
PATCH /affiliate/setdefaults
PATCH /affiliate/setinformation
PATCH /affiliate/setpayviainfo
PATCH /affiliate/setsettings
PATCH /affiliate/status
Member
GET /member/authstring
GET /member/details
GET /member/searchinfo
GET /suggestedcanceloffers
PATCH /member/setdetails
PATCH /member/setexpiration
POST /member/addnote
POST /member/recordlogin
PUT /member/expiremanual
PATCH /member/forget
Option
GET /option/options
GET /option/rule
PATCH /option/rule
PATCH/option/text
POST /option/rule
Payments
GET /payments/getpayments
GET /payviarule
PATCH /payments/setstatus
PATCH /payviarule
Report
GET /profitlossreport
Get /transactionpayouts
GET /report/transaction
Service
GET /service/decodenatscode
GET /service/ping
POST /service/sendemail

GET /profitlossreport

Description

  • NATS4 supports an API resource to grab all the stats used within the NATS profit and loss report. This is available on NATS version 4.1.7.1 and above.

Resource URL

  • http://domain/api/report/profitloss
  • Replace domain with the nats domain

Request Method

  • GET

Response Format

  • JSON

Authentication

  • HTTP headers

Parameters

Paremeters can be sent as url encoded params.

  • view
    • type: string
    • optional

- The breakdown of the report to display. Possible options for view are - :

    • period
    • month
    • year
    • site_group
    • option
    • tour
    • site
    • subid1
    • subid2
    • program
    • login
    • adtool
    • promotional
    • biller
    • demographic
    • refurl

And the other parameters this API call can take

    • period - Which period of time to select data for. See below for more information regarding the periods within NATS.
    • type: string
    • optional
    • start - Freeform start date for the stats. Used when period is not sent or set to 8
    • type: string
    • optional
    • end - Freeform end date for the stats. Used when period is not sent or set to 8
    • type: string
    • optional
    • acct_rep - View the profit and loss report as an account rep. Will only see stats for affiliates assigned to the account rep
    • type: string
    • optional
    • filter_loginid - Only see stats for the specifc login ID passed in.
    • type: string
    • optional
    • filter_campaignid - Only see stats for the specific campaign ID for the affiliate. (Can only be used if filter_loginid is passed in)
    • type: string
    • optional
    • filter_siteid - Only see stats for the specific site ID passed in.
    • type: string
    • optional
    • filter_tourid - Only see stats for the specific tour ID passed in.
    • type: string
    • optional
    • filter_optionid - Only see stats for the specific option ID passed in.
    • type: string
    • optional
    • filter_adtoolid - Only see stats for the specific adtool ID passed in.
    • type: string
    • optional
    • filter_billerid - Only see stats for the specific biller ID passed in.
    • type: string
    • optional
    • filter_programid - Only see stats for the specific program ID passed in.
    • type: string
    • optional
    • filter_countryid - Only see stats for the specific Country ID passed in.
    • type: string
    • optional
    • natscode - Breakdown the NATS code and only view stats associated with the NATS code.
    • type: string
    • optional
    • no_inhouse - Remove in-house traffic from the returned report.
    • type: string
    • optional
    • no_typein - Remove type-in traffic from the returned report.
    • type: string
    • optional

Periods

# Name Argument Description
0 current Current Period
1 last Last Period
2 today Today
3 yesterday Yesterday
4 week This Week
5 month This Month
6 year This Year
7 all All Time
8 free Freeform (See also the start and end parameters above)

Example Request

GET

http://domain/api/report/profitloss

  • Response:
{
    "total": {
        "breakdown": "year",
        "row": []
    },
    "rows": [
        {
            "break": 1420088400,
            "stats": {
                "name": 1420088400,
                "wm_joins": 0,
                "initial": 0,
                "initial_amount": 0,
                "initial_affiliate_payout": 0,
                "trial": 0,
                "trial_amount": 0,
                "trial_affiliate_payout": 0,
                "other_join": 0,
                "other_join_amount": 0,
                "other_join_affiliate_payout": 0,
                "wm_join": 0,
                "wm_join_affiliate_payout": 0,
                "rebill": 0,
                "rebill_amount": 0,
                "rebill_affiliate_payout": 0,
                "conversion": 0,
                "conversion_amount": 0,
                "conversion_affiliate_payout": 0,
                "other_recurring": 0,
                "other_recurring_amount": 0,
                "other_recurring_affiliate_payout": 0,
                "void": 0,
                "void_amount": 0,
                "void_affiliate_payout": 0,
                "credit": 0,
                "credit_amount": 0,
                "credit_affiliate_payout": 0,
                "chargeback": 0,
                "chargeback_amount": 0,
                "chargeback_affiliate_payout": 0,
                "insufficient_funds": 0,
                "insufficient_funds_amount": 0,
                "insufficient_funds_affiliate_payout": 0,
                "other_refund": 0,
                "other_refund_amount": 0,
                "other_refund_affiliate_payout": 0,
                "void_reversal": 0,
                "void_reversal_amount": 0,
                "void_reversal_affiliate_payout": 0,
                "credit_reversal": 0,
                "credit_reversal_amount": 0,
                "credit_reversal_affiliate_payout": 0,
                "chargeback_reversal": 0,
                "chargeback_reversal_amount": 0,
                "chargeback_reversal_affiliate_payout": 0,
                "other_reversal": 0,
                "other_reversal_amount": 0,
                "other_reversal_affiliate_payout": 0,
                "seconds_amount": 0,
                "seconds_affiliate_payout": 0,
                "wm_join_referral_payout": 0,
                "affiliate_payout": 0,
                "referral_payout": 0,
                "account_rep_payout": 0,
                "partner_payout": 0,
                "byoa_payout": 0,
                "promotional_payout": 0,
                "charges": 0,
                "no_cost_registration": 0,
                "no_cost_registration_amount": 0,
                "no_cost_registration_affiliate_payout": 0,
                "ccbill_chargeback": 0,
                "ccbill_chargeback_amount": 0,
                "ccbill_chargeback_reversal": 0,
                "ccbill_chargeback_reversal_amount": 0,
                "ccbill_conversion": 0,
                "ccbill_conversion_amount": 0,
                "ccbill_credit": 0,
                "ccbill_credit_amount": 0,
                "ccbill_credit_reversal": 0,
                "ccbill_credit_reversal_amount": 0,
                "ccbill_initial": 0,
                "ccbill_initial_amount": 0,
                "ccbill_insufficient_funds": 0,
                "ccbill_insufficient_funds_amount": 0,
                "ccbill_rebill": 0,
                "ccbill_rebill_amount": 0,
                "ccbill_trial": 0,
                "ccbill_trial_amount": 0,
                "ccbill_void": 0,
                "ccbill_void_amount": 0,
                "ccbill_void_reversal": 0,
                "ccbill_void_reversal_amount": 0,
                "impression_trans_affiliate_payout": 0,
                "qualified_trans_affiliate_payout": 0,
                "visitor_trans_affiliate_payout": 0,
                "datebreak": 0,
                "cachebreak": 0,
                "ccbill_joins": 0,
                "ccbill_join_profit": 0,
                "ccbill_recurring": 0,
                "ccbill_recurring_profit": 0,
                "ccbill_reversals": 0,
                "ccbill_reversal_profit": 0,
                "ccbill_refunds": 0,
                "ccbill_refund_loss": 0,
                "free": 0,
                "joins": 0,
                "total_joins": 0,
                "join_profit": 0,
                "join_affiliate_payout": 0,
                "recurring": 0,
                "total_recurring": 0,
                "recurring_profit": 0,
                "recurring_affiliate_payout": 0,
                "payout": 0,
                "reversals": 0,
                "total_reversals": 0,
                "reversal_profit": 0,
                "reversal_affiliate_payout": 0,
                "refunds": 0,
                "total_refunds": 0,
                "refund_loss": 0,
                "refund_affiliate_payout": 0,
                "rebill_biller_charges": 0,
                "rebill_referral_payout": 0,
                "rebill_account_rep_payout": 0,
                "rebill_partner_payout": 0,
                "rebill_byoa_payout": 0,
                "rebill_promotional_payout": 0,
                "recurring_biller_charges": 0,
                "recurring_referral_payout": 0,
                "recurring_account_rep_payout": 0,
                "recurring_partner_payout": 0,
                "recurring_byoa_payout": 0,
                "recurring_promotional_payout": 0,
                "impression": 0,
                "visitor": 0,
                "qualified": 0,
                "join_hits": 0,
                "join_submits": 0,
                "expire": 0
            }
        }
    ]
}

Example Code

PHP

<?php
$curl = curl_init();

$data = array(
    'view' => 'year',
    'start' => '2006-06-06',
    'end' => 2015-03-14
);

$data_string = http_build_query($data);
$url = 'http://domain/api/report/profitloss?'.$data_string;

$headers = array(
    'api-key: 44b5498dbcb481a0d00b404c0169af62',
    'api-username: tmm1phrvezsbu'
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url);

$resp = curl_exec($curl);
//dumps an associative array representation of the json
var_dump(json_decode($resp, true));
// Close request to clear up some resources
curl_close($curl);
?>

Python

  • This example requires pip and the request library which can be installed via pip by: 'pip install requests'
import requests

url = 'http://domain/api/profitlossreport'

params = {
        'view': 'year',
        'start': '2006-06-06',
        'end': '2015-03-14'
}

headers = {
     'api-key': '44b5498dbcb481a0d00b404c0169af62',
     'api-username': 'tmm1phrvezsbu'
}


res = requests.get(url, params=params, headers=headers)

print res.json()

node.js

  • This example requires npm and the request module which can be installed via npm by: 'npm install request'
var request = require('request');

var options = {
    url: 'http://domain/api/report/profitloss',
    method: 'GET',
    qs: {
        'view': 'year',
        'start': '2006-06-06',
        'end': '2015-03-14'
    },
    json: true,
    headers: {
        'api-key': '44b5498dbcb481a0d00b404c0169af62',
        'api-username': 'tmm1phrvezsbu'
    }
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
    else{
        console.log(body);
    }

}

request(options, callback);

Curl

curl -X GET 'http://domain/api/report/profitloss?view=year&start=2006-06-06&end=2015-03-14' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: tmm1phrvezsbu"