Skip to main content

Connect and Test API Login

Now  Test TheTesting API LoginsAccess

FromIn the previous page,step, you created an apiAPI account onin yourthe Eenos WAP controlPortal.

panel.

Now we Wewill are not testingtest the API connection using that api userthose credentials.

Example API Credentials

For Let'sdemonstration purposes, we will use the following examplesample apicredentials:

    API User: eenos_api API Password: eenos123

    In your actual setup, replace these with the API user credentialsand topassword demonstrateyou thecreated.

    api login.

    Request Header 

    Every API request must include the following authentication headers:

      X-API-USERUSER, t=eenos_api,he youAPI shouldusername usecreated in the createdWAP apiportal. username 

      X-API-PASSWORD=eenos123,, youThe shouldpassword useassociated with the passwordAPI ofuser.

      API Endpoint URL

      Use the apibase userAPI URL to send requests:

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

      SampleExample CurlAPI CommandTest Request

      You can test the API connection using a simple cURL command:

      curl -X POST \
        -H "X-API-USER: eenos_api" \
        -H "X-API-PASSWORD: eenos123" \
         https://your-host-name:5555/api/
      Expected Response

      Output:If the authentication is successful, you will receive a JSON response similar to:

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

       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/api/"
      
      # API authentication headers
      headers = {
          "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/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-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