Code examples

The following page contains code examples of common languages for convenient integration with the Pepchecker check request endpoint.

Java example

    
      String apiKey = "test-d8269f8b-721a-42bf-8dba-6d2a30dcff68";
      String firstName = "Donald";
      String lastName = "Trump";

      HttpClient client = HttpClient.newHttpClient();
      HttpRequest request = HttpRequest.newBuilder()
          .uri(URI.create("https://pepchecker.com/api/v1/check?firstName=" + firstName + "&lastName=" + lastName))
          .header("api-key", apiKey)
          .build();

      HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
    
  

Curl example

    
      curl "https://pepchecker.com/api/v1/check?firstName=Donald&lastName=Trump&apiKey=test-d8269f8b-721a-42bf-8dba-6d2a30dcff68"
    
  

PHP example

    
      $apiKey = 'test-d8269f8b-721a-42bf-8dba-6d2a30dcff68';
      $firstName = 'Donald';
      $lastName = 'Trump';

      $opts = array(
        'http' => array(
          'method' => "GET",
          'header' => "api-key: " . $apiKey . "\r\n"
        )
      );

      $context = stream_context_create($opts);
      $response = file_get_contents('https://pepchecker.com/api/v1/check?firstName=' . $firstName . '&lastName=' . $lastName, false, $context);

      var_dump($response);
    
  

JS example

    
      const http = new XMLHttpRequest();
      const apiKey = 'test-d8269f8b-721a-42bf-8dba-6d2a30dcff68';
      const firstName = 'Donald';
      const lastName = 'Trump';

      http.setRequestHeader('api-key', apiKey);
      http.open('GET', 'https://pepchecker.com/api/v1/check?firstName=' + firstName + '&lastName=' + lastName);
      http.send();

      http.onreadystatechange = (e) => {
          console.log(http.responseText)
      };
    
  

Python example

    
      import urllib3

      http = urllib3.PoolManager()
      apiKey = 'test-d8269f8b-721a-42bf-8dba-6d2a30dcff68'
      firstName = 'Donald'
      lastName = 'Trump'

      response = http.request('GET', 'https://pepchecker.com/api/v1/check?firstName=' += firstName += '&lastName=' += lastName, headers={
          'api-key': apiKey
      })

      print(response)