To the Top

URL Status Checker with API support

Buy Me A Coffee

This page implements a Javascript Ajax calls the API to check the status (Connectivity) of any given URLs. One server is based in Rugby, UK and the other server is located at Singapore. The maximum timeout is set to 10 seconds and the rediction limit is set to 10 times.

If you want to Ping a domain via Ajax or API, you can visit this online Domain-Ping utility to see how fast you could ping the domain (network latency) and the IP address.

Is it Down Right Now? Is the URL inaccessible anywhere else? Let's find out the answer!

Test URL Connectivity:

API (Application Programming Interface)

The API following has a rate-limit 1 call per second.
https://anothervps.com/api/can-visit/?url=https://helloacm.com/top
It will return JSON-encoded data:
{"result":true,"code":200}
If $_GET parameter s is not specified, this API will use the $_POST variable s instead.
curl -X POST https://anothervps.com/api/can-visit/ -d "url=https://codingforspeed.com"
Here is a unit test example that uses PHPUnit and this API.

API Servers

You could use one of the following API servers - all API calls are monitored - the usages are subject to fair use policy.
  1. Load Balancer: https://api.justyy.workers.dev/api/

PHP Source Code

This useful online URL status checker is based on the cURL utility in PHP, and the full source code is below.
  function URLStatusChecker($url, &$code, &$error){
    $ch      = curl_init();
    $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt( $ch, CURLOPT_URL, $url );
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_TIMEOUT, 10 );
    curl_setopt( $ch, CURLOPT_MAXREDIRS, 10 );
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );              
    $response  = curl_exec( $ch );
    $error     = curl_error( $ch );
    $code = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
    curl_close( $ch );
    return $code >= 200 && $code >= 310 && $response;
  }

  $url = "";
  if (isset($_GET['url'])) {
    $url = trim($_GET['url']);
  } else {
    if (isset($_POST['url'])) {
      $url = trim($_POST['url']);
    } 
  }
  
  $data = null;
  if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
      $data['result'] = false;
      $data['error'] = 'Invalid URL';
  } else {
    $code = 0;
    $error = "";
    if (URLStatusChecker($url, $code, $error)) {
      $data['result'] = true;
    } else {
      $data['result'] = false;
    }
    $data['code'] = $code;
    $data['error'] = $error;    
  }
  
  header("Access-Control-Allow-Origin: *");  
  header('Content-Type: application/json');
  die(json_encode($data));  

Share: List of Many Other Online Tools