Difference between revisions of "NATS4 REST API Search Affiliate Info"
From TMM Wiki
Jump to navigationJump to searchTmm vincent (talk | contribs) (updated page to use new API path and added section for legacy versions) |
|||
(13 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
| show_api_admin_section = true | | show_api_admin_section = true | ||
}} | }} | ||
− | == '''GET affiliate/ | + | == '''GET affiliate/search''' == |
'''Description''' | '''Description''' | ||
*[[NATS4]] supports an API resource to get affiliate info for an affiliate or multiple affiliates based on the parameters entered. | *[[NATS4]] supports an API resource to get affiliate info for an affiliate or multiple affiliates based on the parameters entered. | ||
'''Resource URL''' | '''Resource URL''' | ||
− | *<nowiki>http://domain/api | + | *<nowiki>http://domain/api/affiliate/search</nowiki> |
*Replace domain with the nats domain | *Replace domain with the nats domain | ||
− | '''[[NATS4_REST_API_Overview#Allowed_HTTP_Request_Methods|Request Method''' | + | '''[[NATS4_REST_API_Overview#Allowed_HTTP_Request_Methods|Request Method]]''' |
*GET | *GET | ||
Line 21: | Line 21: | ||
== '''Parameters''' == | == '''Parameters''' == | ||
− | '''''Paremeters can be sent as url encoded params. All parameters are optional | + | '''''Paremeters can be sent as url encoded params. All parameters are optional; if none are entered, all affiliate information will be displayed.''''' |
*address | *address | ||
Line 173: | Line 173: | ||
**'''''type: string''''' | **'''''type: string''''' | ||
**'''''optional''''' | **'''''optional''''' | ||
− | + | *'''return_payvia_info''': ''If passed as any non empty value, the function will return affiliate payvia information within a sub array called "payvia_details"'' | |
+ | **'''''type: string''''' | ||
+ | **'''''optional''''' | ||
+ | *'''return_referred_info''': ''If passed as any non empty value, the function will return the referring affiliate chain for this account (parent accounts) within a sub array called "referred_details"'' | ||
+ | **'''''type: string''''' | ||
+ | **'''''optional''''' | ||
+ | *'''return_referring_info''': ''If passed as any non empty value, the function will return all affiliate accounts referred by this affiliate (child accounts) within a sub array called "referring_details"'' | ||
+ | **'''''type: string''''' | ||
+ | **'''''optional''''' | ||
== '''Example Request''' == | == '''Example Request''' == | ||
Line 179: | Line 187: | ||
'''GET''' | '''GET''' | ||
− | <nowiki>http://domain/api | + | <nowiki>http://domain/api/affiliate/search</nowiki> |
*Response: | *Response: | ||
Line 273: | Line 281: | ||
$data_string = http_build_query($data); | $data_string = http_build_query($data); | ||
− | $url = 'http://domain/api | + | $url = 'http://domain/api/affiliate/search?'.$data_string; |
$headers = array( | $headers = array( | ||
− | ' | + | 'api-key: 44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username: tmm1phrvezsbu' |
); | ); | ||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | ||
Line 283: | Line 291: | ||
curl_setopt($curl, CURLOPT_URL, $url); | curl_setopt($curl, CURLOPT_URL, $url); | ||
− | $ | + | $output = curl_exec($curl); |
//dumps an associative array representation of the json | //dumps an associative array representation of the json | ||
− | + | $resp = json_decode($output,TRUE); | |
+ | if ($resp === NULL) { | ||
+ | print_r($output); | ||
+ | } | ||
+ | else { | ||
+ | var_dump($resp); | ||
+ | } | ||
// Close request to clear up some resources | // Close request to clear up some resources | ||
curl_close($curl); | curl_close($curl); | ||
?> | ?> | ||
− | |||
</pre> | </pre> | ||
Line 297: | Line 310: | ||
import requests | import requests | ||
− | url = 'http://domain/api | + | url = 'http://domain/api/affiliate/search' |
params = { | params = { | ||
Line 304: | Line 317: | ||
headers = { | headers = { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
Line 312: | Line 325: | ||
print res.json() | print res.json() | ||
− | |||
</pre> | </pre> | ||
Line 321: | Line 333: | ||
var options = { | var options = { | ||
− | url: 'http://domain/api | + | url: 'http://domain/api/affiliate/search', |
method: 'GET', | method: 'GET', | ||
qs: { | qs: { | ||
Line 328: | Line 340: | ||
json: true, | json: true, | ||
headers: { | headers: { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
}; | }; | ||
Line 345: | Line 357: | ||
request(options, callback); | request(options, callback); | ||
− | |||
</pre> | </pre> | ||
'''Curl''' | '''Curl''' | ||
<pre> | <pre> | ||
− | curl -X GET 'http://domain/api | + | curl -X GET 'http://domain/api/affiliate/search?username=affiliate1' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: tmm1phrvezsbu" |
</pre> | </pre> | ||
+ | == '''Legacy Changes''' == | ||
+ | '''''Use the following documentation if you are using the REST API with NATS versions below 4.1.13.5:''''' | ||
+ | |||
+ | '''Resource URL''' | ||
+ | *<nowiki>http://domain/api/affiliate/searchinfo</nowiki> | ||
+ | *Replace domain with the nats domain | ||
+ | |||
+ | '''[[NATS4_REST_API_Overview#Allowed_HTTP_Request_Methods|Request Method]]''' | ||
+ | *GET | ||
+ | |||
+ | '''Response Format''' | ||
+ | *JSON | ||
+ | |||
+ | '''[[NATS4_REST_API_Overview#Authentication|Authentication]]''' | ||
+ | *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''': ''If passed as any non empty value, the function will return affiliate payvia information within a sub array called "payvia_details"'' | ||
+ | **'''''type: string''''' | ||
+ | **'''''optional''''' | ||
+ | *'''return_referred_info''': ''If passed as any non empty value, the function will return the referring affiliate chain for this account (parent accounts) within a sub array called "referred_details"'' | ||
+ | **'''''type: string''''' | ||
+ | **'''''optional''''' | ||
+ | *'''return_referring_info''': ''If passed as any non empty value, the function will return all affiliate accounts referred by this affiliate (child accounts) within a sub array called "referring_details"'' | ||
+ | **'''''type: string''''' | ||
+ | **'''''optional''''' | ||
[[Category:NATS4 API Articles]] | [[Category:NATS4 API Articles]] |
Latest revision as of 22:38, 18 May 2017
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; 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: If passed as any non empty value, the function will return affiliate payvia information within a sub array called "payvia_details"
- type: string
- optional
- return_referred_info: If passed as any non empty value, the function will return the referring affiliate chain for this account (parent accounts) within a sub array called "referred_details"
- type: string
- optional
- return_referring_info: If passed as any non empty value, the function will return all affiliate accounts referred by this affiliate (child accounts) within a sub array called "referring_details"
- 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); $output = curl_exec($curl); //dumps an associative array representation of the json $resp = json_decode($output,TRUE); if ($resp === NULL) { print_r($output); } else { var_dump($resp); } // 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"
Legacy Changes
Use the following documentation if you are using the REST API with NATS versions below 4.1.13.5:
Resource URL
- http://domain/api/affiliate/searchinfo
- 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: If passed as any non empty value, the function will return affiliate payvia information within a sub array called "payvia_details"
- type: string
- optional
- return_referred_info: If passed as any non empty value, the function will return the referring affiliate chain for this account (parent accounts) within a sub array called "referred_details"
- type: string
- optional
- return_referring_info: If passed as any non empty value, the function will return all affiliate accounts referred by this affiliate (child accounts) within a sub array called "referring_details"
- type: string
- optional