NATS5 REST API Service GET countries
From TMM Wiki
Revision as of 15:20, 9 August 2019 by TMMJoe (talk | contribs) (TMMJoe moved page NATS4 REST API Service GET countries to NATS5 REST API Service GET countries: Renaming NATS5 API pages)
GET /service/countries
Description
- Get a list of NATS supported countries
Resource URL
- http://domain/api/service/countries
- Replace domain with the nats domain
- GET
Response Format
- JSON
- HTTP headers
Parameters
None
Example Request
Method: GET
URL: http://domain/api/service/countries
Response:
[ { "country_code": "AF", "countryid": "004", "name": "Afghanistan" }, { "country_code": "AX", "countryid": "248", "name": "Aland Islands" }, { "country_code": "AL", "countryid": "008", "name": "Albania" }, { "country_code": "DZ", "countryid": "012", "name": "Algeria" }, { "country_code": "AS", "countryid": "016", "name": "American Samoa" }, { "country_code": "AD", "countryid": "020", "name": "Andorra" }, { "country_code": "AO", "countryid": "024", "name": "Angola" }, { "country_code": "AI", "countryid": "660", "name": "Anguilla" }, { "country_code": "AQ", "countryid": "010", "name": "Antarctica" }, { "country_code": "AG", "countryid": "028", "name": "Antigua And Barbuda" }, { "country_code": "AR", "countryid": "032", "name": "Argentina" }, { "country_code": "AM", "countryid": "051", "name": "Armenia" }, { "country_code": "AW", "countryid": "533", "name": "Aruba" }, { "country_code": "AU", "countryid": "036", "name": "Australia" }, { "country_code": "AT", "countryid": "040", "name": "Austria" }, { "country_code": "AZ", "countryid": "031", "name": "Azerbaijan" }, { "country_code": "BS", "countryid": "044", "name": "Bahamas" }, { "country_code": "BH", "countryid": "048", "name": "Bahrain" }, { "country_code": "BD", "countryid": "050", "name": "Bangladesh" }, { "country_code": "BB", "countryid": "052", "name": "Barbados" }, { "country_code": "BY", "countryid": "112", "name": "Belarus" }, { "country_code": "BE", "countryid": "056", "name": "Belgium" }, { "country_code": "BZ", "countryid": "084", "name": "Belize" }, { "country_code": "BJ", "countryid": "204", "name": "Benin" }, { "country_code": "BM", "countryid": "060", "name": "Bermuda" }, { "country_code": "BT", "countryid": "064", "name": "Bhutan" }, { "country_code": "BO", "countryid": "068", "name": "Bolivia" }, { "country_code": "BQ", "countryid": "535", "name": "Bonaire, Saint Eustatius and Saba" }, { "country_code": "BA", "countryid": "070", "name": "Bosnia And Herzegowina" }, { "country_code": "BW", "countryid": "072", "name": "Botswana" }, { "country_code": "BV", "countryid": "074", "name": "Bouvet Island" }, { "country_code": "BR", "countryid": "076", "name": "Brazil" }, { "country_code": "IO", "countryid": "086", "name": "British Indian Ocean" }, { "country_code": "BN", "countryid": "096", "name": "Brunei Darussalam" }, { "country_code": "BG", "countryid": "100", "name": "Bulgaria" }, { "country_code": "BF", "countryid": "854", "name": "Burkina Faso" }, { "country_code": "BI", "countryid": "108", "name": "Burundi" }, { "country_code": "KH", "countryid": "116", "name": "Cambodia" }, { "country_code": "CM", "countryid": "120", "name": "Cameroon" }, { "country_code": "CA", "countryid": "124", "name": "Canada" }, { "country_code": "CV", "countryid": "132", "name": "Cape Verde" }, { "country_code": "KY", "countryid": "136", "name": "Cayman Islands" }, { "country_code": "CF", "countryid": "140", "name": "Central African Republic" }, { "country_code": "TD", "countryid": "148", "name": "Chad" }, { "country_code": "CL", "countryid": "152", "name": "Chile" }, { "country_code": "CN", "countryid": "156", "name": "China" }, { "country_code": "CX", "countryid": "162", "name": "Christmas Island" }, { "country_code": "CC", "countryid": "166", "name": "Cocos (Keeling) Islands" }, { "country_code": "CO", "countryid": "170", "name": "Colombia" }, { "country_code": "KM", "countryid": "174", "name": "Comoros" }, { "country_code": "CG", "countryid": "178", "name": "Congo, Republic of the" }, { "country_code": "CD", "countryid": "180", "name": "Congo, Democratic Republic of the" }, { "country_code": "CK", "countryid": "184", "name": "Cook Islands" }, { "country_code": "CR", "countryid": "188", "name": "Costa Rica" }, { "country_code": "CI", "countryid": "384", "name": "Cote D'ivoire" }, { "country_code": "HR", "countryid": "191", "name": "Croatia" }, { "country_code": "CU", "countryid": "192", "name": "Cuba" }, { "country_code": "CW", "countryid": "531", "name": "Curacao" }, { "country_code": "CY", "countryid": "196", "name": "Cyprus" }, { "country_code": "CZ", "countryid": "203", "name": "Czech Republic" }, { "country_code": "DK", "countryid": "208", "name": "Denmark" }, { "country_code": "DJ", "countryid": "262", "name": "Djibouti" }, { "country_code": "DM", "countryid": "212", "name": "Dominica" }, { "country_code": "DO", "countryid": "214", "name": "Dominican Republic" }, { "country_code": "EC", "countryid": "218", "name": "Ecuador" }, { "country_code": "EG", "countryid": "818", "name": "Egypt" }, { "country_code": "SV", "countryid": "222", "name": "El Salvador" }, { "country_code": "GQ", "countryid": "226", "name": "Equatorial Guinea" }, { "country_code": "ER", "countryid": "232", "name": "Eritrea" }, { "country_code": "EE", "countryid": "233", "name": "Estonia" }, { "country_code": "ET", "countryid": "231", "name": "Ethiopia" }, { "country_code": "FK", "countryid": "238", "name": "Falkland Islands (Malvinas)" }, { "country_code": "FO", "countryid": "234", "name": "Faroe Islands" }, { "country_code": "FJ", "countryid": "242", "name": "Fiji" }, { "country_code": "FI", "countryid": "246", "name": "Finland" }, { "country_code": "FR", "countryid": "250", "name": "France" }, { "country_code": "GF", "countryid": "254", "name": "French Guiana" }, { "country_code": "PF", "countryid": "258", "name": "French Polynesia" }, { "country_code": "TF", "countryid": "260", "name": "French Southern Territories" }, { "country_code": "GA", "countryid": "266", "name": "Gabon" }, { "country_code": "GM", "countryid": "270", "name": "Gambia" }, { "country_code": "GE", "countryid": "268", "name": "Georgia" }, { "country_code": "DE", "countryid": "276", "name": "Germany" }, { "country_code": "GH", "countryid": "288", "name": "Ghana" }, { "country_code": "GI", "countryid": "292", "name": "Gibraltar" }, { "country_code": "GR", "countryid": "300", "name": "Greece" }, { "country_code": "GL", "countryid": "304", "name": "Greenland" }, { "country_code": "GD", "countryid": "308", "name": "Grenada" }, { "country_code": "GP", "countryid": "312", "name": "Guadeloupe" }, { "country_code": "GU", "countryid": "316", "name": "Guam" }, { "country_code": "GT", "countryid": "320", "name": "Guatemala" }, { "country_code": "GG", "countryid": "831", "name": "Guernsey" }, { "country_code": "GN", "countryid": "324", "name": "Guinea" }, { "country_code": "GW", "countryid": "624", "name": "Guinea-bissau" }, { "country_code": "GY", "countryid": "328", "name": "Guyana" }, { "country_code": "HT", "countryid": "332", "name": "Haiti" }, { "country_code": "HM", "countryid": "334", "name": "Heard Island and McDonald Islands" }, { "country_code": "VA", "countryid": "336", "name": "Holy See (Vatican City State)" }, { "country_code": "HN", "countryid": "340", "name": "Honduras" }, { "country_code": "HK", "countryid": "344", "name": "Hong Kong" }, { "country_code": "HU", "countryid": "348", "name": "Hungary" }, { "country_code": "IS", "countryid": "352", "name": "Iceland" }, { "country_code": "IN", "countryid": "356", "name": "India" }, { "country_code": "ID", "countryid": "360", "name": "Indonesia" }, { "country_code": "IR", "countryid": "364", "name": "Iran, Islamic Republic of" }, { "country_code": "IQ", "countryid": "368", "name": "Iraq" }, { "country_code": "IE", "countryid": "372", "name": "Ireland" }, { "country_code": "IM", "countryid": "833", "name": "Isle of Man" }, { "country_code": "IL", "countryid": "376", "name": "Israel" }, { "country_code": "IT", "countryid": "380", "name": "Italy" }, { "country_code": "JM", "countryid": "388", "name": "Jamaica" }, { "country_code": "JP", "countryid": "392", "name": "Japan" }, { "country_code": "JE", "countryid": "832", "name": "Jersey" }, { "country_code": "JO", "countryid": "400", "name": "Jordan" }, { "country_code": "KZ", "countryid": "398", "name": "Kazakhstan" }, { "country_code": "KE", "countryid": "404", "name": "Kenya" }, { "country_code": "KI", "countryid": "296", "name": "Kiribati" }, { "country_code": "KP", "countryid": "408", "name": "Korea, Democratic People's Republic of" }, { "country_code": "KR", "countryid": "410", "name": "Korea, Republic of" }, { "country_code": "KW", "countryid": "414", "name": "Kuwait" }, { "country_code": "KG", "countryid": "417", "name": "Kyrgyzstan" }, { "country_code": "LA", "countryid": "418", "name": "Lao People's Democratic Republic" }, { "country_code": "LV", "countryid": "428", "name": "Latvia" }, { "country_code": "LB", "countryid": "422", "name": "Lebanon" }, { "country_code": "LS", "countryid": "426", "name": "Lesotho" }, { "country_code": "LR", "countryid": "430", "name": "Liberia" }, { "country_code": "LY", "countryid": "434", "name": "Libya" }, { "country_code": "LI", "countryid": "438", "name": "Liechtenstein" }, { "country_code": "LT", "countryid": "440", "name": "Lithuania" }, { "country_code": "LU", "countryid": "442", "name": "Luxembourg" }, { "country_code": "MO", "countryid": "446", "name": "Macao" }, { "country_code": "MK", "countryid": "807", "name": "Macedonia, Republic of" }, { "country_code": "MG", "countryid": "450", "name": "Madagascar" }, { "country_code": "MW", "countryid": "454", "name": "Malawi" }, { "country_code": "MY", "countryid": "458", "name": "Malaysia" }, { "country_code": "MV", "countryid": "462", "name": "Maldives" }, { "country_code": "ML", "countryid": "466", "name": "Mali" }, { "country_code": "MT", "countryid": "470", "name": "Malta" }, { "country_code": "MH", "countryid": "584", "name": "Marshall Islands" }, { "country_code": "MQ", "countryid": "474", "name": "Martinique" }, { "country_code": "MR", "countryid": "478", "name": "Mauritania" }, { "country_code": "MU", "countryid": "480", "name": "Mauritius" }, { "country_code": "YT", "countryid": "175", "name": "Mayotte" }, { "country_code": "MX", "countryid": "484", "name": "Mexico" }, { "country_code": "FM", "countryid": "583", "name": "Micronesia, Federated States of" }, { "country_code": "MD", "countryid": "498", "name": "Moldova, Republic Of" }, { "country_code": "MC", "countryid": "492", "name": "Monaco" }, { "country_code": "MN", "countryid": "496", "name": "Mongolia" }, { "country_code": "ME", "countryid": "499", "name": "Montenegro" }, { "country_code": "MS", "countryid": "500", "name": "Montserrat" }, { "country_code": "MA", "countryid": "504", "name": "Morocco" }, { "country_code": "MZ", "countryid": "508", "name": "Mozambique" }, { "country_code": "MM", "countryid": "104", "name": "Myanmar" }, { "country_code": "NA", "countryid": "516", "name": "Namibia" }, { "country_code": "NR", "countryid": "520", "name": "Nauru" }, { "country_code": "NP", "countryid": "524", "name": "Nepal" }, { "country_code": "NL", "countryid": "528", "name": "Netherlands" }, { "country_code": "AN", "countryid": "530", "name": "Netherlands Antilles" }, { "country_code": "NC", "countryid": "540", "name": "New Caledonia" }, { "country_code": "NZ", "countryid": "554", "name": "New Zealand" }, { "country_code": "NI", "countryid": "558", "name": "Nicaragua" }, { "country_code": "NE", "countryid": "562", "name": "Niger" }, { "country_code": "NG", "countryid": "566", "name": "Nigeria" }, { "country_code": "NU", "countryid": "570", "name": "Niue" }, { "country_code": "NF", "countryid": "574", "name": "Norfolk Island" }, { "country_code": "MP", "countryid": "580", "name": "Northern Mariana Islands" }, { "country_code": "NO", "countryid": "578", "name": "Norway" }, { "country_code": "OM", "countryid": "512", "name": "Oman" }, { "country_code": "PK", "countryid": "586", "name": "Pakistan" }, { "country_code": "PW", "countryid": "585", "name": "Palau" }, { "country_code": "PS", "countryid": "275", "name": "Palestine, State of" }, { "country_code": "PA", "countryid": "591", "name": "Panama" }, { "country_code": "PG", "countryid": "598", "name": "Papua New Guinea" }, { "country_code": "PY", "countryid": "600", "name": "Paraguay" }, { "country_code": "PE", "countryid": "604", "name": "Peru" }, { "country_code": "PH", "countryid": "608", "name": "Philippines" }, { "country_code": "PN", "countryid": "612", "name": "Pitcairn" }, { "country_code": "PL", "countryid": "616", "name": "Poland" }, { "country_code": "PT", "countryid": "620", "name": "Portugal" }, { "country_code": "PR", "countryid": "630", "name": "Puerto Rico" }, { "country_code": "QA", "countryid": "634", "name": "Qatar" }, { "country_code": "RE", "countryid": "638", "name": "Reunion" }, { "country_code": "RO", "countryid": "642", "name": "Romania" }, { "country_code": "RU", "countryid": "643", "name": "Russian Federation" }, { "country_code": "RW", "countryid": "646", "name": "Rwanda" }, { "country_code": "BL", "countryid": "652", "name": "Saint Bartelemey" }, { "country_code": "SH", "countryid": "654", "name": "Saint Helena" }, { "country_code": "KN", "countryid": "659", "name": "Saint Kitts And Nevis" }, { "country_code": "LC", "countryid": "662", "name": "Saint Lucia" }, { "country_code": "PM", "countryid": "666", "name": "Saint Pierre And Miquelon" }, { "country_code": "VC", "countryid": "670", "name": "Saint Vincent and the Grenadines" }, { "country_code": "MF", "countryid": "663", "name": "Saint-Martin (French part)" }, { "country_code": "WS", "countryid": "882", "name": "Samoa" }, { "country_code": "SM", "countryid": "674", "name": "San Marino" }, { "country_code": "ST", "countryid": "678", "name": "Sao Tome and Principe" }, { "country_code": "SA", "countryid": "682", "name": "Saudi Arabia" }, { "country_code": "SN", "countryid": "686", "name": "Senegal" }, { "country_code": "RS", "countryid": "688", "name": "Serbia" }, { "country_code": "SC", "countryid": "690", "name": "Seychelles" }, { "country_code": "SL", "countryid": "694", "name": "Sierra Leone" }, { "country_code": "SG", "countryid": "702", "name": "Singapore" }, { "country_code": "SX", "countryid": "534", "name": "Sint Maarten (Dutch part)" }, { "country_code": "SK", "countryid": "703", "name": "Slovakia" }, { "country_code": "SI", "countryid": "705", "name": "Slovenia" }, { "country_code": "SB", "countryid": "090", "name": "Solomon Islands" }, { "country_code": "SO", "countryid": "706", "name": "Somalia" }, { "country_code": "ZA", "countryid": "710", "name": "South Africa" }, { "country_code": "GS", "countryid": "239", "name": "South Georgia and the South Sandwich Islands" }, { "country_code": "SS", "countryid": "728", "name": "South Sudan" }, { "country_code": "ES", "countryid": "724", "name": "Spain" }, { "country_code": "LK", "countryid": "144", "name": "Sri Lanka" }, { "country_code": "SD", "countryid": "736", "name": "Sudan" }, { "country_code": "SR", "countryid": "740", "name": "Suriname" }, { "country_code": "SJ", "countryid": "744", "name": "Svalbard and Jan Mayen Islands" }, { "country_code": "SZ", "countryid": "748", "name": "Swaziland" }, { "country_code": "SE", "countryid": "752", "name": "Sweden" }, { "country_code": "CH", "countryid": "756", "name": "Switzerland" }, { "country_code": "SY", "countryid": "760", "name": "Syrian Arab Republic" }, { "country_code": "TW", "countryid": "158", "name": "Taiwan" }, { "country_code": "TJ", "countryid": "762", "name": "Tajikistan" }, { "country_code": "TZ", "countryid": "834", "name": "Tanzania, United Republic Of" }, { "country_code": "TH", "countryid": "764", "name": "Thailand" }, { "country_code": "TL", "countryid": "626", "name": "Timor-Leste" }, { "country_code": "TG", "countryid": "768", "name": "Togo" }, { "country_code": "TK", "countryid": "772", "name": "Tokelau" }, { "country_code": "TO", "countryid": "776", "name": "Tonga" }, { "country_code": "TT", "countryid": "780", "name": "Trinidad And Tobago" }, { "country_code": "TN", "countryid": "788", "name": "Tunisia" }, { "country_code": "TR", "countryid": "792", "name": "Turkey" }, { "country_code": "TM", "countryid": "795", "name": "Turkmenistan" }, { "country_code": "TC", "countryid": "796", "name": "Turks and Caicos Islands" }, { "country_code": "TV", "countryid": "798", "name": "Tuvalu" }, { "country_code": "UG", "countryid": "800", "name": "Uganda" }, { "country_code": "UA", "countryid": "804", "name": "Ukraine" }, { "country_code": "AE", "countryid": "784", "name": "United Arab Emirates" }, { "country_code": "GB", "countryid": "826", "name": "United Kingdom" }, { "country_code": "US", "countryid": "840", "name": "United States" }, { "country_code": "UM", "countryid": "581", "name": "United States Minor Outlying Islands" }, { "country_code": "UY", "countryid": "858", "name": "Uruguay" }, { "country_code": "UZ", "countryid": "860", "name": "Uzbekistan" }, { "country_code": "VU", "countryid": "548", "name": "Vanuatu" }, { "country_code": "VE", "countryid": "862", "name": "Venezuela" }, { "country_code": "VN", "countryid": "704", "name": "Vietnam" }, { "country_code": "VG", "countryid": "092", "name": "Virgin Islands (British)" }, { "country_code": "VI", "countryid": "850", "name": "Virgin Islands (US)" }, { "country_code": "WF", "countryid": "876", "name": "Wallis and Futuna Islands" }, { "country_code": "EH", "countryid": "732", "name": "Western Sahara" }, { "country_code": "YE", "countryid": "887", "name": "Yemen" }, { "country_code": "ZM", "countryid": "894", "name": "Zambia" }, { "country_code": "ZW", "countryid": "716", "name": "Zimbabwe" }, { "country_code": "A1", "countryid": "10001", "name": "Anonymous Proxy *" }, { "country_code": "A2", "countryid": "10002", "name": "Satellite Provider *" }, { "country_code": "O1", "countryid": "10003", "name": "Other Country *" }, { "country_code": "AP", "countryid": "10004", "name": "Asia\/Pacific Region *" }, { "country_code": "EU", "countryid": "10005", "name": "Europe *" } ]
Example Code
PHP
<?php $headers = array( //set your username and API key here 'api-key: 44b5498dbcb481a0d00b404c0169af62', 'api-username: tmm1phrvezsbu' ); $url = 'http://yourdomain.com'; //set your NATS URL here $data = array(); $request = Array( 'method' => 'GET', 'path' => 'v1/service/countries', 'data' => $data ); /*code below is the same for (almost) every API call */ $curl = curl_init(); $url = $url.'/api/'.$request['path']; $query = http_build_query($request['data']); if($request['method'] == 'GET'){ //add query string parameters to the end of the url $url = $url.'?'.$query; }else{ //send parameters as POST fields curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $query); if($request['method'] != 'POST'){ $headers[] ='X-HTTP-Method: '.$request['method']; //send custom request method } } curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $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); ?>