Skip to main content

test_connection

Test API Connection

This function is to test the API connection to the server via api request itself.

Required Headers

Field Description Example
X-RESELLER The reseller account user name alphareseller X-API-USER The API username eenos_api X-API-PASSWORD The API  user password eenos123

Request URL

Post  URL = /test_connection/

Full URL = https://your-host-name:5555/4444/api/test_connection/

Example Curl Command 

#!/bin/bash

REQUEST_URL="/test_connection/"
BASE_URL="https://your-host-name:5555/4444/api/v1"
# Default base url
# BASE_URL="https://your-host-name:5555/4444/api"

# Version specific base url
# BASE_URL="https://your-host-name:5555/4444/api/v1"

API_URL="$BASE_URL$REQUEST_URL"

/usr/bin/curl -X POST "$API_URL" \
  -H "X-RESELLER: alphareseller" \
  -H "X-API-USER: eenos_api" \
  -H "X-API-PASSWORD: eenos123"

Output:

{"data":{"test":"Connection Success"},"info":"API Connection Success","status":200}

 If you can see a similar result like below, 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

 

#!/usr/bin/python3
import requests
from pprint import pprint

# ---------------------------------------------------------------------
# API VERSION RULES
# ---------------------------------------------------------------------
# Default API (stable):
#   https://your-host-name:5555/4444/api/
#
# Versioned API (recommended for production / future compatibility):
#   https://your-host-name:5555/4444/api/v1/
#
# Endpoint example:
#   test_connection/
#   Full versioned URL:
#   https://your-host-name:5555/4444/api/v1/test_connection/
# ---------------------------------------------------------------------

# REQUEST URL
request_url = "/test_connection/"

# BASE URL
base_url = "https://your-host-name:5555/4444/api/v1"

# Default base url
# base_url = "https://your-host-name:5555/4444/api"

# Version specific base url
# base_url = "https://your-host-name:5555/4444/api/v1"

# FINAL API URL
api_url = base_url + request_url

# Authentication headers (new API format)
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 VERSION RULES
|--------------------------------------------------------------------------
| Default API (stable):
|   https://your-host-name:5555/4444/api/
|
| Versioned API (recommended for production / future compatibility):
|   https://your-host-name:5555/4444/api/v1/
|
| Endpoint example:
|   test_connection/
|   Full versioned URL:
|   https://your-host-name:5555/4444/api/v1/test_connection/
|--------------------------------------------------------------------------
*/

// REQUEST URL
$request_url = "/test_connection/";

// BASE URL
$base_url = "https://your-host-name:5555/4444/api/v1";

// Default base url
// $base_url = "https://your-host-name:5555/4444/api"

// Version specific base url
// $base_url = "https://your-host-name:5555/4444/api/v1"

// FINAL API URL
$api_url = $base_url . $request_url;

// Initialize cURL
$ch = curl_init($api_url);

// No POST payload required
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Authentication headers (new API format)
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "X-RESELLER: alphareseller",
    "X-API-USER: eenos_api",
    "X-API-PASSWORD: eenos123"
]);

// Execute request
$result = curl_exec($ch);

// Error handling
if (curl_errno($ch)) {
    echo "cURL Error: " . curl_error($ch);
} else {
    echo json_encode(json_decode($result), JSON_PRETTY_PRINT);
}

// Close connection
curl_close($ch);

?>