NATS4 REST API Search Affiliate Info
From TMM Wiki
GET affiliate/search
Description
- NATS4 supports an API resource to get affiliate info for an affiliate or multiple affiliates based on the parameters entered.
Resource URL
- http://domain/api/affiliate/search
- Replace domain with the nats domain
- GET
Response Format
- JSON
- HTTP headers
Parameters
Paremeters can be sent as url encoded params. All parameters are optional so if none are entered, all affiliate information will be displayed..
- address
- type: string
- optional
- aim
- type: string
- optional
- city
- type: string
- optional
- company
- type: string
- optional
- country
- type: string
- optional
- deleted
- type: string
- optional
- email
- type: string
- optional
- end
- type: string
- optional
- firstname
- type: string
- optional
- icq
- type: string
- optional
- inhouse
- type: string
- optional
- join_count
- type: integer
- optional
- join_date
- type: string
- optional
- join_hits
- type: string
- optional
- join_ip
- type: string
- optional
- join_range
- type: string
- optional
- join_submits
- type: integer
- optional
- lastname
- type: string
- optional
- login_date
- type: string
- optional
- loginid
- type: integer
- optional
- login_ip
- type: string
- optional
- login_range
- type: string
- optional
- min_pay
- type: string
- optional
- name
- type: string
- optional
- natscode
- type: string
- optional
- orderby
- type: string
- optional
- pay_range
- type: string
- optional
- payvia_details
- type: string
- optional
- payvia_type_id
- type: integer
- optional
- ratio
- type: string
- optional
- raw_hits
- type: integer
- optional
- rebill_count
- type: string
- optional
- refid
- type: string
- optional
- ref
- type: string
- optional
- refund_count
- type: string
- optional
- sales_rep
- type: string
- optional
- search_ref
- type: string
- optional
- start
- type: string
- optional
- state
- type: string
- optional
- stats_end
- type: string
- optional
- stats_period
- type: string
- optional
- stats_start
- type: string
- optional
- status
- type: string
- optional
- total_earned
- type: string
- optional
- total
- type: string
- optional
- type
- type: string
- optional
- unq_hits
- type: string
- optional
- url
- type: string
- optional
- username
- type: string
- optional
- zip_code
- type: string
- optional
- return_payvia_info
- type: string
- optional
- return_referred_info
- type: string
- optional
- return_referring_info
- type: string
- optional
Example Request
GET
http://domain/api/affiliate/search
- Response:
{ "3": { "loginid": "3", "username": "affiliate1", "password": "$6$4Arjzx0l$KexJXqDqIWBtasD54qQh5Tknnj2mm.m3D9ULyAef.GvYdxMO3w3ERStyTzy.VXXPRNsykYLfjQNt8APX0x4Wq.", "deleted": "0", "type": "100", "skinid": "102", "payvia_type_id": "1", "status": "0", "pass_hash": "55718788453dfec428c9fb3.27539735", "join_date": "1402587397", "inhouse": "0", "api_key": "", "tmmid": "0", "origin": "0", "language": "en", "rss_pass_code": "145b3ce7614671d0a9ebe81f87ac275d", "payout_period_id": "0", "firstname": "Test", "lastname": "Testakovsky", "email": "hello@toomuchmedia.com", "date_posted": "1402587397", "join_ip": "168430159", "last_login": "1407183950", "last_login_ip": "168430236", "reviewed": "1", "minimum_payout": "50", "bonus": "0", "bonus_used": "0", "verify": "", "reason": "", "unencoded": "0", "startpage": "internal.php", "rep_baseline": "0", "company": "Test Company", "url": "http:\/\/this.is\/test", "tel": "", "icq": "", "aim": "", "msn": "", "address1": "666 Lemmy St", "address2": null, "city": "Heck", "state": "NJ", "country": "US", "zip_code": "66666", "tax_id_or_ssn": "", "invoicer": "0", "req_docs": "1", "w9": "1", "mailok": "1", "trust_level": "0", "new_notification": "0", "latest_news": "1403790938", "default_campaign": "0", "default_program": "1", "default_site": "0", "pv_instant": "0", "payout_approval": "0", "access_preset": "0", "custom1": "0", "custom2": "0", "custom3": "0", "custom4": "0", "custom5": "0", "avatar_ext": "", "remote_access": "0", "remote_payment": "0", "remote_adtool": "0", "allow_subscription_passthrough": "0", "allow_option_force": "0", "status_nice": null, "payvia_details": [ ] } }
Example Code
PHP
<?php $curl = curl_init(); $data = array( 'username' => 'affiliate1', ); $data_string = http_build_query($data); $url = 'http://domain/api/affiliate/search?'.$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/affiliate/search' params = { 'username': 'affiliate1' } 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/affiliate/search', method: 'GET', qs: { 'username': 'affiliate1' }, 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/affiliate/search?username=affiliate1' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: tmm1phrvezsbu"