> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moduluslabs.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Ping

> Public health check endpoint to verify QR API connectivity and availability

The Ping endpoint is a simple health check that allows you to:

* Test connectivity to Modulus Labs servers
* Verify API availability and response time
* Confirm your network can reach the API endpoints

<Tip>
  This endpoint does not require authentication, making it perfect for quick connectivity tests and uptime monitoring.
</Tip>

<Check>
  If you receive `Pong!`, the API is available and your network connectivity is working!
</Check>

## Use Cases

<CardGroup cols={2}>
  <Card title="Connection Test" icon="signal">
    Verify your application can reach Modulus Labs servers
  </Card>

  <Card title="Health Monitoring" icon="heart-pulse">
    Include in your application's health check endpoints
  </Card>

  <Card title="CI/CD Testing" icon="gears">
    Use in automated tests to verify API availability
  </Card>

  <Card title="Uptime Monitoring" icon="clock">
    Monitor API uptime and response times without authentication overhead
  </Card>
</CardGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl https://qrph.sbx.moduluslabs.io/ping

  # Successful response:
  # Pong!
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  async function ping() {
    try {
      const response = await axios.get('https://qrph.sbx.moduluslabs.io/ping');

      console.log('Response:', response.data);
      // Output: Pong!

      console.log('API is reachable!');
    } catch (error) {
      if (error.response) {
        console.error('Error:', error.response.status);
        console.error('Details:', error.response.data);
      } else {
        console.error('Request failed:', error.message);
      }
    }
  }

  ping();
  ```

  ```python Python theme={null}
  import requests

  def ping():
      try:
          response = requests.get('https://qrph.sbx.moduluslabs.io/ping')

          response.raise_for_status()

          print('Response:', response.text)
          # Output: Pong!

          print('API is reachable!')

      except requests.exceptions.HTTPError as e:
          print(f'Error: {e.response.status_code}')
          print('Details:', e.response.text)
      except requests.exceptions.RequestException as e:
          print(f'Request failed: {str(e)}')

  if __name__ == '__main__':
      ping()
  ```

  ```php PHP theme={null}
  <?php

  $ch = curl_init('https://qrph.sbx.moduluslabs.io/ping');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

  $response = curl_exec($ch);
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  curl_close($ch);

  if ($httpCode === 200) {
      echo "Response: $response\n";
      // Output: Pong!
      echo "API is reachable!\n";
  } else {
      echo "Error: HTTP $httpCode\n";
      echo "Details: $response\n";
  }
  ```

  ```csharp C# / .NET theme={null}
  using System;
  using System.Net.Http;
  using System.Threading.Tasks;

  class Program
  {
      static async Task Main(string[] args)
      {
          await Ping();
      }

      static async Task Ping()
      {
          using var client = new HttpClient();

          try
          {
              var response = await client.GetAsync("https://qrph.sbx.moduluslabs.io/ping");
              var responseBody = await response.Content.ReadAsStringAsync();

              if (response.IsSuccessStatusCode)
              {
                  Console.WriteLine($"Response: {responseBody}");
                  // Output: Pong!

                  Console.WriteLine("API is reachable!");
              }
              else
              {
                  Console.WriteLine($"Error: HTTP {(int)response.StatusCode}");
                  Console.WriteLine($"Details: {responseBody}");
              }
          }
          catch (HttpRequestException e)
          {
              Console.WriteLine($"Request failed: {e.Message}");
          }
          catch (Exception e)
          {
              Console.WriteLine($"Unexpected error: {e.Message}");
          }
      }
  }
  ```

  ```go Go theme={null}
  package main

  import (
  	"fmt"
  	"io"
  	"net/http"
  )

  func main() {
  	resp, err := http.Get("https://qrph.sbx.moduluslabs.io/ping")
  	if err != nil {
  		fmt.Printf("Request failed: %v\n", err)
  		return
  	}
  	defer resp.Body.Close()

  	body, _ := io.ReadAll(resp.Body)

  	if resp.StatusCode == 200 {
  		fmt.Printf("Response: %s\n", string(body))
  		// Output: Pong!
  		fmt.Println("API is reachable!")
  	} else {
  		fmt.Printf("Error: HTTP %d\n", resp.StatusCode)
  		fmt.Printf("Details: %s\n", string(body))
  	}
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.*;

  public class PingExample {
      public static void main(String[] args) throws Exception {
          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://qrph.sbx.moduluslabs.io/ping"))
              .GET()
              .build();

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

          if (response.statusCode() == 200) {
              System.out.println("Response: " + response.body());
              // Output: Pong!
              System.out.println("API is reachable!");
          } else {
              System.out.println("Error: HTTP " + response.statusCode());
              System.out.println("Details: " + response.body());
          }
      }
  }
  ```
</RequestExample>

## Monitoring Example

Include the Ping endpoint in your monitoring strategy:

```javascript theme={null}
const HEALTH_CHECK_INTERVAL = 60000; // 1 minute

setInterval(async () => {
  try {
    const response = await axios.get(
      'https://qrph.sbx.moduluslabs.io/ping',
      { timeout: 5000 } // 5 second timeout
    );

    if (response.data === 'Pong!') {
      console.log('Modulus Labs API is healthy');
      // Update your monitoring dashboard
    }
  } catch (error) {
    console.error('Modulus Labs API health check failed');
    // Alert your team
    // Log to monitoring service
  }
}, HEALTH_CHECK_INTERVAL);
```

## Best Practices

<AccordionGroup>
  <Accordion title="Implement Timeouts">
    Always set appropriate timeouts when making ping requests to avoid hanging your application.

    ```javascript theme={null}
    { timeout: 5000 } // 5 seconds
    ```
  </Accordion>

  <Accordion title="Log Failures">
    Log health check failures for debugging and monitoring.

    ```javascript theme={null}
    console.error('Ping failed:', {
      timestamp: new Date().toISOString(),
      error: error.message,
      statusCode: error.response?.status
    });
    ```
  </Accordion>

  <Accordion title="Don't Overuse">
    The ping endpoint is for health checks, not request validation. Don't call it before every API request.

    **Bad:** Call ping before every QR creation

    **Good:** Call ping during startup and periodically for monitoring (every 1-5 minutes)
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Network Timeout">
    **Symptom:** Request times out without response

    **Possible Causes:**

    * Firewall blocking outbound HTTPS requests
    * Network connectivity issues
    * DNS resolution problems

    **Solutions:**

    * Check firewall rules allow HTTPS (port 443)
    * Test DNS resolution: `nslookup qrph.sbx.moduluslabs.io`
    * Try from a different network
    * Verify no proxy is blocking the request
  </Accordion>

  <Accordion title="SSL Certificate Error">
    **Symptom:** SSL/TLS certificate validation fails

    **Possible Causes:**

    * System time incorrect
    * Missing CA certificates
    * Corporate proxy intercepting SSL

    **Solutions:**

    * Verify system time is correct
    * Update SSL certificates on your system
    * Configure proxy settings if applicable
  </Accordion>

  <Accordion title="Unexpected Response">
    **Symptom:** Response is not `Pong!`

    **Possible Causes:**

    * Wrong endpoint URL
    * Proxy or CDN modifying response
    * API maintenance or issues

    **Solutions:**

    * Verify URL is exactly `https://qrph.sbx.moduluslabs.io/ping`
    * Check for any middleware modifying responses
    * Contact Modulus Labs support if issue persists
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Create QR Code" icon="qrcode" href="/api-reference/qr/create">
    Generate a Dynamic QR Ph for payments (requires authentication)
  </Card>

  <Card title="Authentication Guide" icon="key" href="/docs/qr/authentication">
    Set up HTTP Basic Auth for protected endpoints
  </Card>

  <Card title="Error Handling" icon="triangle-exclamation" href="/docs/errors">
    Understand error codes and responses
  </Card>

  <Card title="QR API Introduction" icon="book" href="/docs/qr/introduction">
    Learn about the QR API features
  </Card>
</CardGroup>


## OpenAPI

````yaml api-reference/qr/openapi.json GET /ping
openapi: 3.1.0
info:
  title: Modulus Labs QR API
  description: >-
    API for generating Dynamic QR Ph codes for Consumer Scans Business
    transactions
  version: 1.0.0
servers:
  - url: https://qrph.sbx.moduluslabs.io
    description: Sandbox
security: []
paths:
  /ping:
    get:
      tags:
        - Health
      summary: Ping
      description: >-
        Public health check endpoint to verify API connectivity and
        availability. This endpoint does not require authentication.
      operationId: ping
      responses:
        '200':
          description: API is available and responding
          content:
            text/plain:
              schema:
                type: string
                example: Pong!
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: '10000001'
                error: An unexpected error occurred. Please try again later.
                referenceNumber: 097bf60a-bdab-40bf-b615-3c0eae693b86
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: SERVICE_UNAVAILABLE
                error: Service temporarily unavailable. Please try again later.
                referenceNumber: 097bf60a-bdab-40bf-b615-3c0eae693b86
      security: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
        error:
          type: string
          description: Error message
        referenceNumber:
          type: string
          description: Reference number for support inquiries

````