NATS4 REST API Get Options
From TMM Wiki
Jump to navigationJump to searchGET /option/options
Description
- NATS4 supports an API resource to get option rules and their associatied info
Resource URL
- http://domain/api/option/options
- Replace domain with the nats domain
- GET
Response Format
- JSON
- HTTP headers
Parameters
Paremeters can be sent as url encoded params.
- natscode: NATS Code of the surfer
- type: string
- required
- billerid: NATS Biller Id - In case there are biller specific options
- type: integer
- optional
- country: Surfer Country (2 or 3 digit alpha or numeric ISO) - In case there are country specific options
- type: string
- optional
Example Request
GET
http://domain/api/option/options
- Response:
{ "join_options":{ "1":"Auth w\/Delayed Settlement", "2":"Sale","3":"$2.99 1-day Trial Recurring $9.99 Monthl", "4":"Dynamic Rebill","15":"One Time month access" }, "full_options":{ "1":{ "optionid":"1", "siteid":"1", "networkid":"0", "deleted":"0", "enabled":"1", "orderid":"1", "option_type_id":"0", "billerid":"0", "programid":"0", "legacy":"0", "details":{ "initial":"1.95", "initial_days":"1", "rebill":"39.95", "rebill_days":"30", "name":"Auth w\/Delayed Settlement", "packageid":"1", "no_old_members":"", "package_upgrade_allowed":"1", "enable_global_package_upgrade":"", "package_use_initial":"", "hidden":"", "initial_free":"", "token_rebuy_allowed":"", "ncr_email":"", "no_active_members":"1", "no_never_members":"", "no_never_joined_members":"1", "no_never_submitted_members":"1", "yes_never_submitted_members":"1", "yes_never_joined_members":"1", "yes_expired_members":"1", "yes_active_members":"", "reactivate_only":"", "only_once":"1"} }, "18":{ "optionid":"18", "siteid":"1", "networkid":"0", "deleted":"0", "enabled":"0", "orderid":"1", "option_type_id":"5", "billerid":"15", "programid":"0", "legacy":"0", "details":{ "name":"Join w\/ BitPay", "rebill":"", "rebill_days":"", "yes_never_joined_members":"1", "yes_never_submitted_members":"1", "yes_active_members":"1", "yes_expired_members":"1" } }, "2":{ "optionid":"2", "siteid":"1", "networkid":"0", "deleted":"0", "enabled":"1", "orderid":"2", "option_type_id":"0", "billerid":"0", "programid":"0", "legacy":"0", "details":{ "initial":"5.00", "initial_days":"30", "rebill":"39.95", "rebill_days":"30", "name":"Sale", "packageid":"1", "no_old_members":"", "package_upgrade_allowed":"1", "enable_global_package_upgrade":"", "package_use_initial":"", "hidden":"", "initial_free":"", "token_rebuy_allowed":"", "ncr_email":"", "no_active_members":"1", "no_never_members":"", "yes_never_submitted_members":"1", "yes_never_joined_members":"1", "yes_expired_members":"1", "yes_active_members":"1", "reactivate_only":"", "only_once":"1" } }, }, "default_option":"1", "special_options":{ "18":"Join w\/ BitPay" } }
Example Code
PHP
<?php $curl = curl_init(); $data = array( 'natscode' => 'MC4wLjEuMS4wLjAuMC4wLjA' ); $data_string = http_build_query($data); $url = 'http://domain/api/option/options?'.$data_string; $headers = array( 'api-key: 93cdc66d3aa665c1a3723dd46c79559b', 'api-username: productsupport' ); 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/option/options' params = { 'natscode' => 'MC4wLjEuMS4wLjAuMC4wLjA' } headers = { 'api-key': '93cdc66d3aa665c1a3723dd46c79559b', 'api-username': 'productsupport' } 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/option/options', method: 'GET', qs: { ''natscode' => 'MC4wLjEuMS4wLjAuMC4wLjA' }, json: true, headers: { 'api-key': '93cdc66d3aa665c1a3723dd46c79559b', 'api-username': 'productsupport' } }; 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://http://domain/api/option/options?natscode=MC4wLjEuMS4wLjAuMC4wLjA' -H "api-key: 93cdc66d3aa665c1a3723dd46c79559b" -H "api-username: productsupport"