# Check availability

## checkDomain()

This function is used for each query if a domain is available. This query can be initiated by a customer in the storefront, an external module or via admin panel.

{% hint style="info" %}
**This function is optional**\
If not implemented, the default HwWHOIS will be used. Some domain registrars do not provide their own WHOIS API endpoints which can be implemented.
{% endhint %}

### Parameters

You get both the TLD and SLD of the requested domain. If the customer searches for "hostware.io", you get the following input:

<table><thead><tr><th width="142">Type</th><th width="166">Name</th><th>Description</th></tr></thead><tbody><tr><td>String</td><td>$sld</td><td>The SLD part, e.g. "hostware"</td></tr><tr><td>String</td><td>$tld</td><td>The TLD part, e.g. "io"</td></tr></tbody></table>

### Response

DomainCheckResponse() class.

<table><thead><tr><th width="142">Type</th><th width="166">Name</th><th>Description</th></tr></thead><tbody><tr><td>bool</td><td>$available</td><td>If the domain is available or not</td></tr><tr><td>null or String</td><td>$whoisResponse</td><td>The actual WHOIS response, if returned by the module. Can be empty.</td></tr></tbody></table>

### Example Code

```php
public function checkDomain(string $sld, string $tld): DomainCheckResponse {

    $data = $this->getClient()->domains()->isAvailable($sld, $tld);

    return new DomainCheckResponse(
        $data->data->available
    );
}
```

### Testing

Perform an availability check in the storefront on the domain listing page. This requires a Domain TLD Price to be attached to this module, so the function gets executed.
