Difference between revisions of "NATS4 REST API Overview"
(48 intermediate revisions by 6 users not shown) | |||
Line 2: | Line 2: | ||
| show_api_admin_section = true | | show_api_admin_section = true | ||
}} | }} | ||
+ | = NOTE = | ||
+ | <!-- '''The NATS REST API is available as an additional feature on NATS <font style="color: red;font-weight: bold;">4.1.10.1</font> If you would like to use the NATS REST API on an earlier version, please submit a support ticket and a tech will add the additional feature to your install.''' --> | ||
+ | |||
+ | ''' <font style="color: red;font-weight: bold;"> 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 </font> ''' | ||
+ | |||
== Overview == | == Overview == | ||
− | The NATS | + | The NATS REST API is accessible at <nowiki>http://<domain>/api/<endpoint>/<action></nowiki> |
+ | *The API is accessible to admins. '''/api/<endpoint>/<action> is available only to admins.''' | ||
*Replace <domain> with your NATS install domain name. | *Replace <domain> with your NATS install domain name. | ||
− | *Replace <endpoint> with the | + | *Replace <endpoint> with the endpoint that you are trying to access |
− | *Some of the | + | *Some of the endpoints do not require <action> in the url and all of the urls will be specified in the documentation |
+ | |||
+ | == Allowed Endpoints == | ||
+ | |||
+ | '''Adtools''' | ||
+ | *'''''GET''''': | ||
+ | **[[NATS4 REST API Admin Get Adtools|GET /adtools/admin]] | ||
+ | **[[NATS4 REST API Adtool Categories|GET /adtools/categories]] | ||
+ | **[[NATS4 REST API Adtool Types|GET /adtools/types]] | ||
+ | *'''''POST''''': | ||
+ | **[[NATS4 REST API Bulk Import Adtools|POST /adtools/importdump]] | ||
+ | |||
+ | ---- | ||
+ | |||
+ | '''Affiliate''' | ||
+ | *'''''GET''''': | ||
+ | **[[NATS4 REST API Affiliate Get Campaigns|GET /affiliate/campaigns]] | ||
+ | **[[NATS4 REST API Get Affiliate Hit Data|GET /affiliate/hits]] | ||
+ | **[[NATS4 REST API Get Affiliate Payout|GET /affiliate/payout]] | ||
+ | **[[NATS4 REST API Search Affiliate Info|GET /affiliate/searchinfo]] | ||
+ | *'''''POST''''': | ||
+ | **[[NATS4 REST API Add Affiliate|POST /affiliate/add]] | ||
+ | **[[NATS4 REST API Add Affiliate Manual Invoice|POST /affiliate/invoice]] | ||
+ | *'''''PATCH''''': | ||
+ | **[[NATS4 REST API Set Affiliate Admin Settings|PATCH /affiliate/setadminsettings]] | ||
+ | **[[NATS4 REST API Set Affiliate Customs|PATCH /affiliate/setcustoms]] | ||
+ | **[[NATS4 REST API Set Affiliate Defaults|PATCH /affiliate/setdefaults]] | ||
+ | **[[NATS4 REST API Set Affiliate Information|PATCH /affiliate/details]] | ||
+ | **[[NATS4 REST API Set Affiliate Payvia Info|PATCH /affiliate/setpayviainfo]] | ||
+ | **[[NATS4 REST API Set Affiliate Settings|PATCH /affiliate/setsettings]] | ||
+ | **[[NATS4 REST API Set Affiliate Status|PATCH /affiliate/status]] | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | '''Member''' | ||
+ | *'''''GET''''': | ||
+ | **[[NATS4 REST API Get Member Auth String|GET /member/authstring]] | ||
+ | **[[NATS4 REST API Get Member Details|GET /member/details]] | ||
+ | **[[NATS4 REST API Get Member Search Info String|GET /member/search]] | ||
+ | **[[NATS4 REST API Get Suggested Cancel Offers|GET /member/suggestedcanceloffers]] | ||
+ | *'''''POST''''': | ||
+ | **[[NATS4 REST API Record Member Login|POST /member/login]] | ||
+ | **[[NATS4 REST API Add Member Note|POST /member/note]] | ||
+ | *'''''PATCH''''': | ||
+ | **[[NATS4 REST API Set Member Details|PATCH /member/details]] | ||
+ | **[[NATS4 REST API Set Member Expiration|PATCH /member/expiration]] | ||
+ | **[[NATS4 REST API Forget Member|PATCH /member/forget]] | ||
+ | *'''''PUT''''': | ||
+ | **[[NATS4 REST API Expire Manual Member|PUT /member/expiremanual]] | ||
+ | |||
+ | |||
+ | ---- | ||
+ | '''Option''' | ||
+ | *'''''GET''''': | ||
+ | **[[NATS4 REST API Get Options|GET /option/options]] | ||
+ | **[[NATS4 REST API Get Option Rule|GET /option/rule]] | ||
+ | *'''''PATCH''''': | ||
+ | **[[NATS4 REST API Edit Option Rule|PATCH /option/rule]] | ||
+ | **[[NATS4 REST API Edit Option Text|PATCH /option/text]] | ||
+ | *'''''POST''''': | ||
+ | **[[NATS4 REST API Add Option Rule|POST /option/rule]] | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | '''Payments''' | ||
+ | *'''''GET''''': | ||
+ | **[[NATS4 REST API Get Payment Data|GET /payments/getpayments]] | ||
+ | **[[NATS4 REST API Get Payvia Rule|GET /payments/payviarule]] | ||
+ | *'''''PATCH''''': | ||
+ | **[[NATS4 REST API Set Payment Status|PATCH /payments/setstatus]] | ||
+ | **[[NATS4 REST API Set Payvia Rule|PATCH /payments/payviarule]] | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | '''Report''' | ||
+ | *'''''GET''''': | ||
+ | **[[NATS4 REST API Get Profit Loss Report|GET /report/profitlossreport]] | ||
+ | **[[NATS4 REST API Get Transaction Payout Report|GET /report/transactionpayouts]] | ||
+ | **[[NATS4 REST API Get Transaction Report|GET /report/transactions]] | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | '''Service''' | ||
+ | *'''''GET''''': | ||
+ | **[[NATS4 REST API Decode Natscode|GET /service/decodenatscode]] | ||
+ | **[[NATS4 REST API Ping|GET /service/ping]] | ||
+ | |||
+ | *'''''POST''''': | ||
+ | **[[NATS4 REST API Send Email|POST /service/sendemail]] | ||
== Gaining Access to the REST API == | == Gaining Access to the REST API == | ||
Line 14: | Line 112: | ||
*'''GET''' | *'''GET''' | ||
*'''POST''' | *'''POST''' | ||
− | *'''PUT''' | + | *'''PUT''' (if PUT requests are not honored, please add 'x-http-method: PUT' in the headers array passed) |
− | *'''PATCH''' | + | *'''PATCH''' (if PATCH requests are not honored, please add 'x-http-method: PATCH' in the headers array passed) |
*For detailed information about these HTTP Request methods, please refer to their official documentation here: | *For detailed information about these HTTP Request methods, please refer to their official documentation here: | ||
Line 21: | Line 119: | ||
== Response Format == | == Response Format == | ||
− | *'''JSON''' | + | *[http://json.org/ '''JSON'''] |
− | == | + | == 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. | *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 '''' | + | '''405''' |
− | + | *The API will return a ''''405'''' status if an invalid HTTP request method is used. | |
== Authentication == | == 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.'' | + | *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 == | == Required HTTP Headers == | ||
− | *''' | + | *'''api-key''': ''Affiliate api key'' |
− | *''' | + | *'''api-username''': ''Affiliate user name'' |
**NOTE** The headers keys are NOT case sensitive. | **NOTE** The headers keys are NOT case sensitive. | ||
Line 43: | Line 151: | ||
<pre> | <pre> | ||
<?php | <?php | ||
− | $url = 'http://domain/api/ping' | + | $url = 'http://domain/api/service/ping'; |
$curl = curl_init(); | $curl = curl_init(); | ||
$headers = array( | $headers = array( | ||
− | ' | + | 'api-key: 44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username: tmm1phrvezsbu' |
); | ); | ||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | ||
Line 67: | Line 175: | ||
import requests | import requests | ||
− | url = 'http://domain/api/ping' | + | url = 'http://domain/api/service/ping' |
headers = { | headers = { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
params = { | params = { | ||
Line 87: | Line 195: | ||
var options = { | var options = { | ||
− | url: 'http://domain/api/ping', | + | url: 'http://domain/api/service/ping', |
method: 'GET', | method: 'GET', | ||
json: true, | json: true, | ||
headers: { | headers: { | ||
− | ' | + | 'api-key': '44b5498dbcb481a0d00b404c0169af62', |
− | ' | + | 'api-username': 'tmm1phrvezsbu' |
} | } | ||
}; | }; | ||
Line 111: | Line 219: | ||
'''Curl''' | '''Curl''' | ||
<pre> | <pre> | ||
− | curl -X GET 'http://domain/api/ping' -H " | + | curl -X GET 'http://domain/api/service/ping' -H "api-key: 44b5498dbcb481a0d00b404c0169af62" -H "api-username: tmm1phrvezsbu" |
</pre> | </pre> | ||
Latest revision as of 09:26, 16 October 2019
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
Adtools
Affiliate
- GET:
- POST:
- PATCH:
Member
- GET:
- POST:
- PATCH:
- PUT:
Option
- GET:
- PATCH:
- POST:
Payments
- GET:
- PATCH:
Report
Service
- POST:
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)
- For detailed information about these HTTP Request methods, please refer to their official documentation here:
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