To the Top

Ping a Host/Domain via Ajax Javascript API

Buy Me A Coffee

This page calls the API to ping a host/domain from one of the API servers.

Ping is a simple method to tell whether a domain/website is accessible. On success, the server will return some data packages to acknowledge the receipt of messages. The ping tool is available on Windows, MAC OS, and Linux. It also tells you the network latency (delay). The IP address is also exposed, however it might not be the real IP if the domain is behind a CDN e.g. CloudFlare.

To check a particular URL, you can visit this online utility (with Ajax and API) which checks the webpage connectivity.

Ping a Domain via API with Ajax

Ping a Domain via API (Application Programming Interface)

The API following has a rate-limit 1 call per second.
https://steakovercooked.com/api/ping/?host=HelloACM.com
It will return JSON-encoded data:
"PING HelloACM.com (104.24.3.35) 56(84) bytes of data.\n64 bytes from 104.24.3.35: icmp_seq=1 ttl=59 time=6.01 ms\n64 bytes from 104.24.3.35: icmp_seq=2 ttl=59 time=5.97 ms\n64 bytes from 104.24.3.35: icmp_seq=3 ttl=59 time=6.00 ms\n\n--- HelloACM.com ping statistics ---\n3 packets transmitted, 3 received, 0% packet loss, time 2002ms\nrtt min\/avg\/max\/mdev = 5.977\/5.999\/6.015\/0.090 ms\n"
Parameter host is the domain name.

Available API Servers

This API is provided for free on the following API servers depending on the Geo locations that is closer to you. All API calls are closely monitored and used based on fair use policy.
  1. Load Balancer: https://api.justyy.workers.dev/api/

Complete API Source Code (PHP)

  $host = '';
  if (isset($_GET['host'])) {
    $host = trim($_GET['host']);
  }
  $data = '';
  if ($host) {
    $host = preg_replace('/[^\w-_\.]/', '', $host);
    if ($host) {
      $data = shell_exec('ping -c 3 '. removeCmd($host));
    }
  }
  header("Access-Control-Allow-Origin: *");  
  header('Content-Type: application/json');
  die(json_encode($data));  

Share: List of Many Other Online Tools