Connect and Test API Login
Testing API Access
In the previous step, you created an API account in the Eenos WAPreseller Portal.
Now we will test the API connection using those credentials.
Example API Credentials
For demonstration purposes, we will use the following sample credentials:
In your actual setup, replace these with the API user and password you created.
Request Header
Every API request must include the following authentication headers:
API Endpoint URL
Use the base API URL to send requests:
API URL = https://your-host-name:5555/4444/api/
Example API Test Request
You can test the API connection using a simple cURL command:
curl -X POST \
-H "X-RESELLER: alphareseller" \
-H "X-API-USER: eenos_api" \
-H "X-API-PASSWORD: eenos123" \
https://your-host-name:5555/4444/api/
Expected Response
If the authentication is successful, you will receive a JSON response similar to:
{
"reseller": "alphareseller",
"username": "eenos_api",
"auth": "API"None"
}
If you can see a similar result like above, your API logins are ok and working. If you got any other error message, then you are using the wrong api logins or there is an error in connecting from your IP.
Python Code
import requests
from pprint import pprint
# API URL
api_url = "https://your-host-name:5555/4444/api/"
# API authentication headers
headers = {
"X-RESELLER": "alphareseller",
"X-API-USER": "eenos_api",
"X-API-PASSWORD": "eenos123",
}
try:
response = requests.post(api_url, headers=headers)
response.raise_for_status()
pprint(response.json())
except Exception as e:
pprint(str(e))
PHP Code
<?php
// API URL
$url = 'https://your-host-name:5555/4444/api/load-average/';
// Initialize cURL
$ch = curl_init($url);
// Set request options
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-RESELLER: alphareseller",
'X-API-USER: eenos_api',
'X-API-PASSWORD: eenos123'
]);
// Execute request
$result = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'cURL Error: ' . curl_error($ch);
} else {
echo $result;
}
// Close cURL
curl_close($ch);
?>
Summary
If the request is successful:
- Your API credentials are valid
- The server accepts the authentication headers
- You are ready to use the Eenos WAP API for further operations