Difference between revisions of "NATS4 REST API Overview"

From TMM Wiki
Jump to navigationJump to search
Line 256: Line 256:
 
**[[NATS4 REST API Include DELETE step|DELETE /include/step]]
 
**[[NATS4 REST API Include DELETE step|DELETE /include/step]]
  
 +
 +
----
 +
 +
'''Mailing'''
 +
*'''''GET''''':
 +
**[[NATS4 REST API Mailing GET mailing|GET /mailing/mailing]]
 +
**[[NATS4 REST API Mailing GET mailings|GET /mailing/mailings]]
 +
**[[NATS4 REST API Mailing GET mailing-rules|GET /mailing/mailing-rules]]
 +
**[[NATS4 REST API Mailing GET mailing-rule|GET /mailing/mailing-rule]]
 +
**[[NATS4 REST API Mailing GET queue|GET /mailing/queue]]
 +
**[[NATS4 REST API Mailing GET removelist|GET /mailing/removelist]]
 +
*'''''POST''''':
 +
**[[NATS4 REST API Mailing POST mailing|POST /mailing/mailing]]
 +
**[[NATS4 REST API Mailing POST mailing-rule|POST /mailing/mailing-rule]]
 +
**[[NATS4 REST API Mailing POST removelist|POST /mailing/removelist]]
 +
*'''''PATCH''''':
 +
**[[NATS4 REST API Mailing PATCH mailing|PATCH /mailing/mailing]]
 +
**[[NATS4 REST API Mailing PATCH mailing-rule|PATCH /mailing/mailing-rule]]
 +
**[[NATS4 REST API Mailing PATCH removelist|PATCH /mailing/removelist]]
 +
**[[NATS4 REST API Mailing PATCH removelist-queue|PATCH /mailing/removelist-queue]]
 +
**[[NATS4 REST API Mailing PATCH resend-queue|PATCH /mailing/resend-queue]]
 +
**[[NATS4 REST API Mailing PATCH restore-queue|PATCH /mailing/restore-queue]]
 +
**[[NATS4 REST API Mailing PATCH send-mailing|PATCH /mailing/send-mailing]]
 +
**[[NATS4 REST API Mailing PATCH send-test-mailing|PATCH /mailing/send-test-mailing]]
 +
*'''''DELETE''''':
 +
**[[NATS4 REST API Mailing DELETE mailing|DELETE /mailing/mailing]]
 +
**[[NATS4 REST API Mailing DELETE mailing-rule|DELETE /mailing/mailing-rule]]
 +
**[[NATS4 REST API Mailing DELETE queue|DELETE /mailing/queue]]
 +
 +
 +
----
 +
 +
'''Maintenance'''
 +
*'''''GET''''':
 +
**[[NATS4 REST API Maintenance GET admin-actions|GET /maintenance/admin-actions]]
 +
**[[NATS4 REST API Maintenance GET log|GET /maintenance/log]]
 +
**[[NATS4 REST API Maintenance GET logs|GET /maintenance/logs]]
 +
**[[NATS4 REST API Maintenance GET nats|GET /maintenance/nats]]
 +
**[[NATS4 REST API Maintenance GET report|GET /maintenance/report]]
 +
**[[NATS4 REST API Maintenance GET report-progress|GET /maintenance/report-progress]]
 +
**[[NATS4 REST API Maintenance GET reports|GET /maintenance/reports]]
 +
**[[NATS4 REST API Maintenance GET server|GET /maintenance/server]]
 +
**[[NATS4 REST API Maintenance GET table|GET /maintenance/table]]
 +
**[[NATS4 REST API Maintenance GET tables|GET /maintenance/tables]]
 +
**[[NATS4 REST API Maintenance GET table-clean-count|GET /maintenance/table-clean-count]]
 +
**[[NATS4 REST API Maintenance GET table-clean-progress|GET /maintenance/table-clean-progress]]
 +
*'''''PATCH''''':
 +
**[[NATS4 REST API Maintenance PATCH log|PATCH /maintenance/log]]
 +
**[[NATS4 REST API Maintenance PATCH report|PATCH /maintenance/report]]
 +
**[[NATS4 REST API Maintenance PATCH table|PATCH /maintenance/table]]
 +
*'''''DELETE''''':
 +
**[[NATS4 REST API Maintenance DELETE log|DELETE /maintenance/log]]
 +
**[[NATS4 REST API Maintenance DELETE cache|DELETE /maintenance/cache]]
 +
 +
 +
 +
----
 +
'''Member'''
 +
*'''''GET''''':
 +
**[[NATS4 REST API Member GET available flags|GET /member/available_flags]]
 +
**[[NATS4 REST API Member GET encryptusername|GET /member/encryptusername]]
 +
**[[NATS4 REST API Get Member Auth String|GET /member/authstring]]
 +
**[[NATS4 REST API Get Member Details|GET /member/details]]
 +
**[[NATS4 REST API Member GET flags|GET /member/flags]]
 +
**[[NATS4 REST API Member GET loginlog|GET /member/loginlog]]
 +
**[[NATS4 REST API Member GET matching|GET /member/matching]]
 +
**[[NATS4 REST API Member GET notes|GET /member/notes]]
 +
**[[NATS4 REST API Member GET notices|GET /member/notices]]
 +
**[[NATS4 REST API Member GET restricted-values|GET /member/restricted-values]]
 +
**[[NATS4 REST API Get Member Search Info String|GET /member/search]]
 +
**[[NATS4 REST API Get Suggested Cancel Offers|GET /member/suggestedcanceloffers]]
 +
**[[NATS4 REST API Member GET surfer-actions|GET /member/surfer-actions]]
 +
*'''''POST''''':
 +
**[[NATS4 REST API Member POST flag|POST /member/flag]]
 +
**[[NATS4 REST API Record Member Login|POST /member/login]]
 +
**[[NATS4 REST API Add Member Note|POST /member/note]]
 +
**[[NATS4 REST API Member POST restricted-value|POST /member/restricted-value]]
 +
*'''''PATCH''''':
 +
**[[NATS4 REST API Set Member Details|PATCH /member/details]]
 +
**[[NATS4 REST API Set Member Expiration|PATCH /member/expiration]]
 +
**[[NATS4 REST API Expire Manual Member|PATCH /member/expiremanual]]
 +
**[[NATS4 REST API Member PATCH resend-transaction-email|PATCH /member/resend-transaction-email]]
 +
**[[NATS4 REST API Member PATCH resend-transaction-postback|PATCH /member/resend-transaction-postback]]
 +
**[[NATS4 REST API Member PATCH restricted-value|PATCH /member/restricted-value]]
 +
**[[NATS4 REST API Forget Member|PATCH /member/forget]]
 +
**[[NATS4 REST API Member PATCH lock|PATCH /member/lock]]
 +
**[[NATS4 REST API Member PATCH unlock|PATCH /member/unlock]]
 +
*'''''DELETE''''':
 +
**[[NATS4 REST API Member DELETE flag|DELETE /member/flag]]
 +
**[[NATS4 REST API Member DELETE restricted-value|DELETE /member/restricted-value]]
  
  
 
----
 
----
 +
'''Message'''
 +
*'''''GET''''':
 +
**[[NATS4 REST API Message GET count|GET /message/count]]
 +
**[[NATS4 REST API Message GET messages|GET /message/messages]]
 +
**[[NATS4 REST API Message GET view|GET /message/view]]
 +
*'''''POST''''':
 +
**[[NATS4 REST API Message POST message|POST /message/message]]
 +
*'''''PATCH''''':
 +
**[[NATS4 REST API Message PATCH read|PATCH /message/read]]
 +
**[[NATS4 REST API Message PATCH unread|PATCH /message/unread]]
 +
**[[NATS4 REST API Message PATCH undelete|PATCH /message/undelete]]
 +
*'''''DELETE''''':
 +
**[[NATS4 REST API Message DELETE message|DELETE /message/message]]
 +
**[[NATS4 REST API Message DELETE permanent|DELETE /message/permanent]]
  
  

Revision as of 15:54, 2 August 2019

NATS 4
Members Admin
The Members Admin
View Member Details
Add Member
MySQL Auth
Mod Authn DB
Multisite Access
Member Logging
Member Password Retrieval
OpenID Connect
Mod Auth OpenIDC
ID Numbers
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/rule
PATCH /option/rule
PATCH/option/text
POST /option/rule
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

NOTE

Currently the NATS REST API is in the process of being updated which includes changes to how data is being passed to and from the API itself. We will update this Article when this update is complete to let you know which version to upgrade to. If you would like to use the current NATS REST API, please submit a support ticket and a tech will add the additional feature to your install. Please understand that the system itself will change during the course of this update

Overview

The NATS REST API is accessible at http://<domain>/api/<endpoint>/<action>

  • The API is accessible to admins. /api/<endpoint>/<action> is available only to admins.
  • Replace <domain> with your NATS install domain name.
  • Replace <endpoint> with the endpoint that you are trying to access
  • Some of the endpoints do not require <action> in the url and all of the urls will be specified in the documentation

Allowed Endpoints

Adtool



Affiliate



Biller



Codes



Config



Include



Mailing



Maintenance



Member



Message




decodenatscode

member

option

payments

payviarule

ping

profitlossreport

sendemail

suggestedcanceloffers

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 (if PUT requests are not honored, please add 'x-http-method: PUT' in the headers array passed)
  • PATCH (if PATCH requests are not honored, please add 'x-http-method: PATCH' in the headers array passed)

Response Format

Response Status Codes

200

  • 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.
  • NOTE: As long as the endpoint and HTTP request method are valid and there are no invalid parameters, a '200' response is returned.

400

  • The API will return a '400' status if an invalid or unsupported HTTP request is sent.

404

  • 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.

405

  • The API will return a '405' status if an invalid HTTP request method is used.

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/service/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/service/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/service/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/service/ping' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: tmm1phrvezsbu"

And this is the output:

true