NATS4 REST API Get Profit Loss Report

From TMMwiki
Jump to: navigation, search
NATS 4
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/getrule
PATCH /option/editrule
PATCH/option/edittext
POST /option/addrule
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 set to 8
    • type: string
    • optional
  • end - Freeform end date for the stats. Used when period is 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
  • filter_groupid - Only see stats for the specific Affiliate Group ID passed in.
    • type: string
    • optional
  • filter_process_type - Only see stats for the specific process type passed in. See below for more information regarding the periods within NATS
    • 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)

Process Types

! # Name
0 cc
1 check
2 dialer
3 elv
4 asian
5 ob
6 sms
7 900
8 inv
9 trans
10 combo
11 pre
12 phone
13 gphone
14 dp
15 instant
16 idl
17 snp
18 cnd
19 knd
20 eay
21 pys
22 bpy
23 eao
24 prz
25 voucher
26 idv
27 pound
28 dtm
29 bcoin
30 bd
31 poa
32 sof
33 paypal
34 psc
35 cbuy
36 gpay
37 eps
38 mpass
39 pin
40 atm
41 cash
42 ewallet
43 va
44 dc
45 astro
46 sepa
47 tgreso
48 telepay
49 poliau
50 polinz
51 ypay
52 apc
53 gc
54 wap
55 mobile
56 maestro
57 bccard
58 mistercash
59 enets
60 abaqoos
61 poli
62 neosurf
63 epaybg
64 safetpapy
65 toditocash
66 banklink
67 ekonto
68 sporopay
69 unet
70 ticketp
71 postepay
72 euteller
73 qiwi
74 boletoo
75 ymoney
76 switch
77 bz
78 io

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"