# TLDs

List the TLDs available to your reseller account and read their list pricing per currency.

Use these endpoints to discover which TLDs you can sell and what each one costs.

Both endpoints authenticate with the `username` and `token` headers described in [Authentication](/guides/authentication) and take no parameters.

## Get available TLDs

Return every TLD enabled for your reseller account.

`GET /tlds`

### Request

<CodeGroup>
```bash cURL
API_KEY="your-api-key"
EMAIL="you@example.com"
ENDPOINT="https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"
TS=$(date -u +"%y-%m-%d %H")
TOKEN=$(printf '%s' "$API_KEY" \
  | openssl dgst -sha256 -hmac "$EMAIL:$TS" -hex \
  | sed 's/^.*= //' | tr -d '\n' | base64 -w0)

curl -s "$ENDPOINT/tlds" \
  -H "username: $EMAIL" \
  -H "token: $TOKEN"
```

```php PHP
<?php
$apiKey   = "your-api-key";
$email    = "you@example.com";
$endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php";

$token = base64_encode(hash_hmac("sha256", $apiKey, "{$email}:" . gmdate("y-m-d H")));

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "{$endpoint}/tlds");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
    "username: {$email}",
    "token: {$token}",
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

```python Python
from datetime import datetime, timezone

API_KEY  = "your-api-key"
EMAIL    = "you@example.com"
ENDPOINT = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"

def token() -> str:
    ts = datetime.now(timezone.utc).strftime("%y-%m-%d %H")
    digest = hmac.new(f"{EMAIL}:{ts}".encode(), API_KEY.encode(), hashlib.sha256).hexdigest()
    return base64.b64encode(digest.encode()).decode()

resp = requests.get(f"{ENDPOINT}/tlds", headers={"username": EMAIL, "token": token()})
print(resp.json())
```

```javascript Node.js

const API_KEY  = "your-api-key";
const EMAIL    = "you@example.com";
const ENDPOINT = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php";

function token() {
  const ts = new Date().toISOString().slice(2, 13).replace("T", " "); // "yy-mm-dd HH" UTC
  const digest = crypto.createHmac("sha256", `${EMAIL}:${ts}`).update(API_KEY).digest("hex");
  return Buffer.from(digest, "utf8").toString("base64");
}

const res = await fetch(`${ENDPOINT}/tlds`, {
  headers: { username: EMAIL, token: token() },
});
console.log(await res.json());
```

```go Go
package main

	"crypto/hmac"
	"crypto/sha256"
	"encoding/base64"
	"encoding/hex"
	"fmt"
	"io"
	"net/http"
	"time"
)

const (
	apiKey   = "your-api-key"
	email    = "you@example.com"
	endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"
)

func token() string {
	ts := time.Now().UTC().Format("06-01-02 15") // yy-mm-dd HH
	mac := hmac.New(sha256.New, []byte(email+":"+ts))
	mac.Write([]byte(apiKey))
	return base64.StdEncoding.EncodeToString([]byte(hex.EncodeToString(mac.Sum(nil))))
}

func main() {
	req, _ := http.NewRequest("GET", endpoint+"/tlds", nil)
	req.Header.Set("username", email)
	req.Header.Set("token", token())
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```
</CodeGroup>

### Response

The response is an array of TLD strings, each with a leading dot. The array can contain `null` entries where a slot has no active TLD — filter these out before using the list.

```json
[
  ".com", ".net", ".org", ".biz", ".info", ".co.ke", ".app", ".blog",
  ".business", ".buzz", ".cloud", ".club", ".co", null, null, ".de",
  ".io", ".me", ".online", ".site", ".tech", ".top", ".tv", ".uk",
  ".us", ".vip", ".website", ".xyz", ".ke", ".co.tz", ".ng", ".co.za"
]
```

## Get TLDs pricing

Return list pricing for every TLD, once per supported currency.

`GET /tlds/pricing`

### Request

<CodeGroup>
```bash cURL
API_KEY="your-api-key"
EMAIL="you@example.com"
ENDPOINT="https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"
TS=$(date -u +"%y-%m-%d %H")
TOKEN=$(printf '%s' "$API_KEY" \
  | openssl dgst -sha256 -hmac "$EMAIL:$TS" -hex \
  | sed 's/^.*= //' | tr -d '\n' | base64 -w0)

curl -s "$ENDPOINT/tlds/pricing" \
  -H "username: $EMAIL" \
  -H "token: $TOKEN"
```

```php PHP
<?php
$apiKey   = "your-api-key";
$email    = "you@example.com";
$endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php";

$token = base64_encode(hash_hmac("sha256", $apiKey, "{$email}:" . gmdate("y-m-d H")));

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "{$endpoint}/tlds/pricing");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
    "username: {$email}",
    "token: {$token}",
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

```python Python
from datetime import datetime, timezone

API_KEY  = "your-api-key"
EMAIL    = "you@example.com"
ENDPOINT = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"

def token() -> str:
    ts = datetime.now(timezone.utc).strftime("%y-%m-%d %H")
    digest = hmac.new(f"{EMAIL}:{ts}".encode(), API_KEY.encode(), hashlib.sha256).hexdigest()
    return base64.b64encode(digest.encode()).decode()

resp = requests.get(f"{ENDPOINT}/tlds/pricing", headers={"username": EMAIL, "token": token()})
print(resp.json())
```

```javascript Node.js

const API_KEY  = "your-api-key";
const EMAIL    = "you@example.com";
const ENDPOINT = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php";

function token() {
  const ts = new Date().toISOString().slice(2, 13).replace("T", " "); // "yy-mm-dd HH" UTC
  const digest = crypto.createHmac("sha256", `${EMAIL}:${ts}`).update(API_KEY).digest("hex");
  return Buffer.from(digest, "utf8").toString("base64");
}

const res = await fetch(`${ENDPOINT}/tlds/pricing`, {
  headers: { username: EMAIL, token: token() },
});
console.log(await res.json());
```

```go Go
package main

	"crypto/hmac"
	"crypto/sha256"
	"encoding/base64"
	"encoding/hex"
	"fmt"
	"io"
	"net/http"
	"time"
)

const (
	apiKey   = "your-api-key"
	email    = "you@example.com"
	endpoint = "https://portal.hostraha.com/modules/addons/DomainsReseller/api/index.php"
)

func token() string {
	ts := time.Now().UTC().Format("06-01-02 15") // yy-mm-dd HH
	mac := hmac.New(sha256.New, []byte(email+":"+ts))
	mac.Write([]byte(apiKey))
	return base64.StdEncoding.EncodeToString([]byte(hex.EncodeToString(mac.Sum(nil))))
}

func main() {
	req, _ := http.NewRequest("GET", endpoint+"/tlds/pricing", nil)
	req.Header.Set("username", email)
	req.Header.Set("token", token())
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```
</CodeGroup>

### Response

The response is an array of pricing objects. The same TLD appears once per supported currency (USD, TZS, KES, and others), distinguished by `currencyCode`. One element:

```json
{
  "tld": ".com",
  "registrationPrice": "10.00",
  "renewalPrice": "12.00",
  "transferPrice": "12.00",
  "graceFee": "0.00",
  "graceDays": 30,
  "redemptionDays": -1,
  "redemptionFee": "69.00",
  "currencyCode": "USD",
  "years": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
```

<ResponseField name="tld" type="string">
  The TLD, including its leading dot.
</ResponseField>

<ResponseField name="registrationPrice" type="string">
  Price to register the domain for one year, in `currencyCode`.
</ResponseField>

<ResponseField name="renewalPrice" type="string">
  Price to renew the domain for one year.
</ResponseField>

<ResponseField name="transferPrice" type="string">
  Price to transfer the domain in.
</ResponseField>

<ResponseField name="graceFee" type="string">
  Fee to renew during the grace period after expiry.
</ResponseField>

<ResponseField name="graceDays" type="number">
  Number of days in the grace period after expiry.
</ResponseField>

<ResponseField name="redemptionDays" type="number">
  Number of days in the redemption period. `-1` means no redemption window is defined.
</ResponseField>

<ResponseField name="redemptionFee" type="string">
  Fee to restore the domain during the redemption period.
</ResponseField>

<ResponseField name="currencyCode" type="string">
  ISO currency code the prices in this object are quoted in.
</ResponseField>

<ResponseField name="years" type="array">
  Registration periods, in years, offered for this TLD.
</ResponseField>

For the price of a specific domain in your account currency, use [Domain pricing](/api-reference/pricing).
