Skip to main content
Glama

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
NameRequiredDescriptionDefault
currencyidNoCurrency 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.getTLDPricing
    server.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) }], }; } );
  • 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); }
  • Zod input schema validation for the tool: optional currencyid parameter
    inputSchema: { currencyid: z.number().optional().describe('Currency ID'), },
  • Generic API call helper method used by all WHMCS API functions, including authentication, param flattening for URL encoding, and response parsing/error handling
    async 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/scarecr0w12/whmcs-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server