Difference between revisions of "NATS4 REST API Overview"
Line 7: | Line 7: | ||
*Replace <endpoint> with the resource endpoint that you are trying to access | *Replace <endpoint> with the resource endpoint that you are trying to access | ||
*Some of the resources do not require <item> in the url and all of the urls will be specified in the documentation | *Some of the resources do not require <item> in the url and all of the urls will be specified in the documentation | ||
+ | |||
+ | *'''ALLOWED ENDPOINTS''' | ||
+ | **[[NATS4 REST API Adtool Types|GET /adtools/types]] | ||
+ | **[[NATS4 REST API Adtool Categories|GET /adtools/categories]] | ||
+ | **[[NATS4 REST API Admin Get Adtools|GET /adtools/admin]] | ||
+ | **[[NATS4 REST API Bulk Import Adtools|POST /adtools/importdump]] | ||
+ | **[[NATS4_REST_API_Get_Affiliate_Hit_Data|GET /affiliate/hitdata]] | ||
+ | **[[NATS4 REST API Affiliate Get Campaigns|GET /affiliate/campaigns]] | ||
+ | **[[NATS4_REST_API_Get_Affiliate_Payout|GET /affiliate/payout]] | ||
+ | **[[NATS4 REST API Search Affiliate Info|GET /affiliate/searchinfo]] | ||
+ | **[[NATS4 REST API Add Affiliate|POST /affiliate/addaffiliate]] | ||
+ | **[[NATS4 REST API Set Affiliate Customs|PATCH /affiliate/setcustoms]] | ||
+ | **[[NATS4 REST API Set Affiliate Information|PATCH /affiliate/setinformation]] | ||
+ | **[[NATS4 REST API Set Affiliate Admin Settings|PATCH /affiliate/setadminsettings]] | ||
+ | **[[NATS4 REST API Set Affiliate Payvia Info|PATCH /affiliate/setpayviainfo]] | ||
+ | **[[NATS4 REST API Decode Natscode|GET /decodenatscode]] | ||
+ | **[[NATS4 REST API Get Member Upsell String|GET /member/upsellstring]] | ||
+ | **[[NATS4 REST API Get Member Token Rebuy String|GET /member/tokenrebuystring]] | ||
+ | **[[NATS4 REST API Get Member Instant Upgrade String|GET /member/instantupgradestring]] | ||
+ | **[[NATS4 REST API Get Member Package Upgrade String|GET /member/packageupgradestring]] | ||
+ | **[[NATS4 REST API Get Member Details|GET /member/details]] | ||
+ | **[[NATS4 REST API Get Member Cancel String|GET /member/cancelstring]] | ||
+ | **[[NATS4 REST API Get Member SignupPlus String|GET /member/signupplusstring]] | ||
+ | **[[NATS4 REST API Get Member Search Info String|GET /member/searchinfo]] | ||
+ | **[[NATS4 REST API Add Member Note|POST /member/addnote]] | ||
+ | **[[NATS4 REST API Record Member Login|POST /member/recordlogin]] | ||
+ | **[[NATS4 REST API Expire Manual Member|PUT /member/expiremanual]] | ||
+ | **[[NATS4 REST API Set Member Details|PATCH /member/setdetails]] | ||
+ | **[[NATS4 REST API Set Member Expiration|PATCH /member/setexpiration]] | ||
+ | **[[NATS4 REST API Get Option Rule|GET /option/getrule]] | ||
+ | **[[NATS4 REST API Add Option Rule|POST /option/addrule]] | ||
+ | **[[NATS4 REST API Edit Option Text|PUT /option/edittext]] | ||
+ | **[[NATS4 REST API Edit Option Rule|PATCH /option/editrule]] | ||
+ | **[[NATS4_REST_API_Get_Payment_Data|GET /payments/getpayments]] | ||
+ | **[[NATS4_REST_API_Set_Payment_Status|PATCH /payments/setstatus]] | ||
+ | **[[NATS4 REST API Get Payvia Rule|GET /payviarule]] | ||
+ | **[[NATS4 REST API Set Payvia Rule|PATCH /payviarule]] | ||
+ | **[[NATS4 REST API Ping| GET /ping]] | ||
+ | **[[NATS4_REST_API_Get_Profit_Loss_Report|GET /profitlossreport]] | ||
+ | **[[NATS4 REST API Send Email|POST /sendemail]] | ||
+ | **[[NATS4 REST API Get Suggested Cancel Offers|GET /suggestedcanceloffers]] | ||
+ | **[[NATS4 REST API Set Affiliate Defaults|(WIP) PATCH /affiliate/setdefaults]] | ||
+ | **[[NATS4 REST API Set Affiliate Settings|(WIP) PATCH /affiliate/setsettings]] | ||
== Gaining Access to the REST API == | == Gaining Access to the REST API == |
Revision as of 19:17, 17 March 2015
Overview
The NATS Admin API is accessible at http://<domain>/api/<endpoint>/<item>
- Replace <domain> with your NATS install domain name.
- Replace <endpoint> with the resource endpoint that you are trying to access
- Some of the resources do not require <item> in the url and all of the urls will be specified in the documentation
- ALLOWED ENDPOINTS
- GET /adtools/types
- GET /adtools/categories
- GET /adtools/admin
- POST /adtools/importdump
- GET /affiliate/hitdata
- GET /affiliate/campaigns
- GET /affiliate/payout
- GET /affiliate/searchinfo
- POST /affiliate/addaffiliate
- PATCH /affiliate/setcustoms
- PATCH /affiliate/setinformation
- PATCH /affiliate/setadminsettings
- PATCH /affiliate/setpayviainfo
- GET /decodenatscode
- GET /member/upsellstring
- GET /member/tokenrebuystring
- GET /member/instantupgradestring
- GET /member/packageupgradestring
- GET /member/details
- GET /member/cancelstring
- GET /member/signupplusstring
- GET /member/searchinfo
- POST /member/addnote
- POST /member/recordlogin
- PUT /member/expiremanual
- PATCH /member/setdetails
- PATCH /member/setexpiration
- GET /option/getrule
- POST /option/addrule
- PUT /option/edittext
- PATCH /option/editrule
- GET /payments/getpayments
- PATCH /payments/setstatus
- GET /payviarule
- PATCH /payviarule
- GET /ping
- GET /profitlossreport
- POST /sendemail
- GET /suggestedcanceloffers
- (WIP) PATCH /affiliate/setdefaults
- (WIP) PATCH /affiliate/setsettings
Gaining Access to the REST API
In order to access NATS API your IP address must be in the ADMIN_API_ALLOWED_IPS list. You can add or remove IP addresses to this list via the Configurations Admin under the "Security" tab.
Allowed HTTP Request Methods
- GET
- POST
- PUT
- PATCH
- For detailed information about these HTTP Request methods, please refer to their official documentation here:
Response Format
- JSON
Responses
- The API will return either a '404' status if an invalid parameter is sent, or if an HTTP request is sent to an invalid endpoint.
- The API will return a '400' status if an invalid or unsupported HTTP request is sent.
- On Success, the API will return a '200' status and output the results of the API call. Please refer to the available API endpoints for possible responses.
Authentication
The NATS REST API uses HTTP Header Authentication. Each REST API request requires the Affiliate username and the Affiliate API key to be sent with the HTTP headers of the request. To retrieve your API key simply select it from the login table of your NATS database or put in a support ticket and we can retrieve it for you. If you do not have an API key, you can set one by going to the Affiliates Admin and clicking the icon labeled, "Change API Key". Please note that only full admin accounts are authorized to use the API and set an API key.
Required HTTP Headers
- api_key: Affiliate api key
- api_username: Affiliate user name
- NOTE** The headers keys are NOT case sensitive.
Example Authentication
Authentication can be handled in various ways using different programming languages. Below are some complete example calls to the Ping endpoint with HTTP Header authentication.
PHP
<?php $url = 'http://domain/api/ping' $curl = curl_init(); $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/ping' headers = { 'api_key': '44b5498dbcb481a0d00b404c0169af62', 'api_username': 'tmm1phrvezsbu' } params = { 'payvia_type_id': 1, 'rule_type': 'enabled' } 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/ping', method: 'GET', 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/ping' -H "api_key: 44b5498dbcb481a0d00b404c0169af62" -H "api_username: tmm1phrvezsbu"
And this is the output:
true