Skip to main content

Connect and Test API Login

Now  Test The API Logins

From previous page you created  and api account on your WAP control panel.  We are not testing the API connection using that api user credentials.

 Let us use the following example api user credentials to  demonstrate the api login

Example Data 

apiuser=eenos_api    , you should use the created api user name 

apiauth=eenos123, you should use the password of the api user

API USR  = https://your-host-name:5555/api/

Sample Curl Command 

url  -X POST -d "apiuser=eenos_api&apiauth=eenos123" https://your-host-name:5555/api/

Output:

{"username":"eenos_api","auth":"API"}

 If you see  a similar result like below, your API logins are ok and working. If you see any other error message , then you are using the wrong api logins or there is an error connecting from your IP

Sample Python Code

import requests
from pprint import pprint
# The api url 
api_ulr=' https://u.eenos.com:your-host-name:5555/api/'
# The data in dictionary format
data={
    'apiuser': 'eenos_api',
    'apiauth':'eenos123'
}

try:   
    result=requests.post(api_ulr, data = data)
    pprint(result.json())
except Exception as e:
    pprint(str(e))
    pass

Sample PHP Code 

<?php
// The API URL
$url=' https://your-host-name:5555/api/';
//The data you want to send via POST
$fields= [
    'apiuser'      => 'eenos_api',
    'apiauth'      => 'eenos123'
];
//url-ify the data for the POST
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); 
//execute post
$result = curl_exec($ch);
echo $result;
?>