whmcs_get_tld_pricing
Retrieve domain extension pricing data from WHMCS for specific currencies to support accurate billing and client quotes.
Instructions
Get domain TLD pricing information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| currencyid | No | Currency ID |
Implementation Reference
- src/index.ts:731-746 (registration)Registration of the 'whmcs_get_tld_pricing' tool, including input schema, description, and thin handler wrapper that calls WhmcsApiClient.getTLDPricingserver.registerTool( 'whmcs_get_tld_pricing', { title: 'Get TLD Pricing', description: 'Get domain TLD pricing information', inputSchema: { currencyid: z.number().optional().describe('Currency ID'), }, }, async (params) => { const result = await whmcsClient.getTLDPricing(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } );
- src/whmcs-client.ts:896-923 (handler)Core handler implementation in WhmcsApiClient: makes authenticated API POST request to WHMCS 'GetTLDPricing' action with optional currencyid parameter, including detailed TypeScript type definition for the response/** * Get TLD pricing */ async getTLDPricing(params: { currencyid?: number; } = {}) { return this.call<WhmcsApiResponse & { currency: { id: number; code: string; prefix: string; suffix: string; }; pricing: Record<string, { categories: string[]; addons: { dns: boolean; email: boolean; idprotect: boolean; }; register: Record<string, string>; transfer: Record<string, string>; renew: Record<string, string>; grace_period: Record<string, unknown>; redemption: Record<string, unknown>; }>; }>('GetTLDPricing', params); }
- src/index.ts:736-738 (schema)Zod input schema validation for the tool: optional currencyid parameterinputSchema: { currencyid: z.number().optional().describe('Currency ID'), },
- src/whmcs-client.ts:29-93 (helper)Generic API call helper method used by all WHMCS API functions, including authentication, param flattening for URL encoding, and response parsing/error handlingasync call<T extends WhmcsApiResponse>(action: string, params: Record<string, unknown> = {}): Promise<T> { const url = `${this.config.apiUrl.replace(/\/$/, '')}/includes/api.php`; const postData: Record<string, string> = { identifier: this.config.apiIdentifier, secret: this.config.apiSecret, action: action, responsetype: 'json', ...this.flattenParams(params) }; if (this.config.accessKey) { postData.accesskey = this.config.accessKey; } const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams(postData).toString(), }); if (!response.ok) { throw new Error(`WHMCS API request failed: ${response.status} ${response.statusText}`); } const data = await response.json() as T; if (data.result === 'error') { throw new Error(`WHMCS API error: ${data.message || 'Unknown error'}`); } return data; } /** * Flatten nested params for URL encoding */ private flattenParams(params: Record<string, unknown>, prefix = ''): Record<string, string> { const result: Record<string, string> = {}; for (const [key, value] of Object.entries(params)) { const newKey = prefix ? `${prefix}[${key}]` : key; if (value === null || value === undefined) { continue; } else if (typeof value === 'object' && !Array.isArray(value)) { Object.assign(result, this.flattenParams(value as Record<string, unknown>, newKey)); } else if (Array.isArray(value)) { value.forEach((item, index) => { if (typeof item === 'object') { Object.assign(result, this.flattenParams(item as Record<string, unknown>, `${newKey}[${index}]`)); } else { result[`${newKey}[${index}]`] = String(item); } }); } else { result[newKey] = String(value); } } return result; }