NATS For Networks REST API Export Customer

From TMMwiki
Jump to: navigation, search
NATS For Networks
REST API
General
API Overview
GET /service/ping
Advertiser
POST /advertiser/add_advertiser
PATCH /advertiser/edit_advertiser
Affiliate
GET /affiliate/get_links
GET /affiliate/get_single_link
GET /affiliate/search
GET /affiliate/decode_trackingcode
PATCH /affiliate/edit_affiliate
POST /affiliate/add_affiliate
POST /affiliate/affiliate_login_ips
Creative
GET /creative/get_creatives
GET /creative/get_creative_fields
GET /creative/get_creative_rules
PATCH /creative/delete_creative
PATCH /creative/edit_creative
PATCH /creative/edit_creative_rules
PATCH /creative/undelete_creative
POST /creative/add_creative
POST /creative/add_creative_rule
POST /creative/delete_creative_rules
Offer
GET /offer/check_orderid_exists
GET /offer/get_commission_changes
PATCH /offer/activate_offer
PATCH /offer/edit_landing_page
PATCH /offer/edit_offer
PATCH /offer/pause_offer
PATCH /offer/set_commission_change_payouts
PATCH /offer/set_enabled_affiliates
PATCH /offer/set_offer_categories
PATCH /offer/set_offer_countries
PATCH /offer/set_offer_goals
PATCH /offer/set_offer_groups
PATCH /offer/set_offer_marketing_types
PATCH /offer/store_offer_ips
POST /offer/add_commission_change
POST /offer/add_landing_page
POST /offer/add_offer
POST /offer/add_tracking_domain
Reporting
GET /report/profitloss
GET /report/transaction
Customer
PATCH /customer/lock
PATCH /customer/unlock
GET /customer/export
PATCH /customer/forget
Transaction
GET /transaction/transaction_payout_preview
PATCH /transaction/transaction_update_revenue_by_orderid
PATCH /transaction/transaction_update_revenue_by_transaction_hash
POST /transaction/process_void
POST /transaction/process_chargeback
POST /transaction/process_reversal
GET /transaction/click_details

GET /customer/export

Description

  • The api/customer/export action is a feature in NATS for Networks that allows you to export customer information

Resource URL

  • http://domain/api/customer/export
  • Replace domain with the NATS for Networks domain

Request Method

  • GET

Response Format

  • JSON

Authentication

  • HTTP headers

Parameters

Paremeters must be sent with the request body. The examples below show the parameters sent as x-www-form-urlencoded


You need to pass either customer_id or subscription_id or orderid for customer lookup otherwise the call will fail

  • customer_id is used to pass in the customer_id of the customer to return
    • type: string
    • optional
  • subscription_id is used to pass in the subscription of the customer to return
    • type: string
    • optional
  • orderid is used to pass in the event id of one of the transactions associated with the customer to return
    • type: string
    • optional

Example Request

GET

http://domain/api/customer/export

  • Response:
true

Example Code

PHP

<?php
$curl = curl_init();

$data = array(
    'customer_id' => 191,
);

$url = 'http://domain/api/customer/export';

$headers = array(
    'api-key: 44b5498dbcb481a0d00b404c0169af62',
    'api-username: n4n_admin'
);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
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
import json

url = 'http://domain/api/customer/export'

payload = {
    'customer_id': 191,
}


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

res = requests.GET(url, data=payload, 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');

data = {
    'customer_id': 191,
}

var options = {
    url: 'http://domain/api/customer/export',
    method: 'GET',
    form: data,
    json: true,
    headers: {
        'api-key': '44b5498dbcb481a0d00b404c0169af62',
        'api-username': 'n4n_admin'
    }
};

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/customer/export' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: n4n_admin" -H "Content-Type: application/x-www-form-urlencoded" -d 'customer_id=191'