### Connection Setup APIs Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/apiclient.APIClient.html Methods to configure the connection setup for API communication, allowing selection between default and high-performance options. ```APIDOC ## POST /api/client/connection/default ### Description Activates the Default Connection Setup. This is the standard configuration for API communication. ### Method POST ### Endpoint /api/client/connection/default ### Response #### Success Response (200) - **APIClient** (object) - The current APIClient instance, enabling method chaining. #### Response Example ```json { "message": "Default connection setup activated." } ``` ## POST /api/client/connection/high-performance ### Description Activates the High Performance Connection Setup. This configuration is optimized for speed and throughput. ### Method POST ### Endpoint /api/client/connection/high-performance ### Response #### Success Response (200) - **APIClient** (object) - The current APIClient instance, enabling method chaining. #### Response Example ```json { "message": "High performance connection setup activated." } ``` ``` -------------------------------- ### Initialize and Configure APIClient Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Instantiate and configure the APIClient for different environments (OT&E/LIVE), set credentials, enable debug mode, and customize user agent, proxy, and referer settings. Supports high-performance connection setup. ```javascript import { APIClient } from "@team-internet/apiconnector"; // Create a new API client instance const client = new APIClient(); // Configure for OT&E (test) environment with credentials client.useOTESystem() .setCredentials("your-username", "your-password"); // Or configure for LIVE production environment (default) client.useLIVESystem() .setCredentials("your-username", "your-password"); // Configure with role-based credentials client.setRoleCredentials("your-username", "role-id", "role-password"); // Enable debug mode for logging client.enableDebugMode(); // Set custom user agent (useful for integration tracking) client.setUserAgent("MyApp", "1.0.0", ["module1/1.0", "module2/2.0"]); // Result: "MyApp (linux; x64; rv:1.0.0) module1/1.0 module2/2.0 node-sdk/8.0.2 node/v20.0.0" // Configure proxy if needed client.setProxy("http://proxy.example.com:8080"); // Configure referer header client.setReferer("https://www.yoursite.com"); // Use high performance connection setup (local proxy) client.useHighPerformanceConnectionSetup(); ``` -------------------------------- ### Handle Response Class Instance Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Examples of accessing response data via the new Response Class methods. ```javascript const response = await apiclient.request(command) const r = response.getHash() // or response.getListHash() console.log(r.CODE) ``` ```javascript const response = await apiclient.request(command) console.log(r.getCode()) ``` -------------------------------- ### Initialize Theme and Show App Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/hierarchy.html Sets the theme from local storage or defaults to 'os', hides the body, and then shows the app or removes the display property after a delay. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Custom API Client Request Override Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Override the request method to customize the Response object. This example shows how to manipulate the plain text response before creating a new Response instance. Ensure the returned object is an instance of a class inheriting from Response. ```typescript import { APIClient } from "@hexonet/apiconnector" import { Response } from "@hexonet/apiconnector" export class CustomAPIClient extends APIClient { public async request(cmd: any): Promise { const r = await super.request(cmd) let manipulatedplain = r.getPlain() manipulatedplain = manipulatedplain.replace(/(\r\n)+EOF\r\n$/, "\r\nEOF\r\n") // or change it however you want return new Response(manipulatedplain) } } ``` -------------------------------- ### APIClient Initialization and Configuration Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt The APIClient class is the primary entry point for configuring the SDK, including environment selection, authentication credentials, and network settings. ```APIDOC ## APIClient Initialization ### Description Initializes and configures the API client for communication with the CentralNic Reseller backend. ### Methods - **useOTESystem()**: Configures the client for the OT&E (test) environment. - **useLIVESystem()**: Configures the client for the LIVE production environment. - **setCredentials(username, password)**: Sets standard authentication credentials. - **setRoleCredentials(username, roleId, rolePassword)**: Sets role-based authentication credentials. - **enableDebugMode()**: Enables verbose logging for debugging. - **setUserAgent(name, version, modules)**: Sets a custom User-Agent header. - **setProxy(url)**: Configures an HTTP proxy for requests. - **setReferer(url)**: Sets the Referer header. - **useHighPerformanceConnectionSetup()**: Enables high-performance connection settings. ``` -------------------------------- ### Perform Simple API Request Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Demonstrates the transition from passing socket parameters and callbacks to using credential setters and async/await. ```javascript var socketparameters = { params: { entity: '1234', remoteaddr: '1.2.3.4:80', login: 'test.user', pw: 'test.passw0rd' } } var callbackSuccess = function(r) { // your logic } var callbackError = function(r) { // your logic } apiclient.request({ COMMAND: "StatusAccount" }, socketparameters, cb, cb) ``` ```javascript // covering the previous example code // read the session-based section for details about // all socket parameter replacements apiclient.setCredentials("test.user", "test.passw0rd") .useOTESystem() .setRemoteIPAddress("1.2.3.4:80") const r = await apiclient.request({ COMMAND: "StatusAccount" }) // your logic here ``` -------------------------------- ### Theme Configuration Script Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/modules/response.html Initializes the theme based on local storage settings and manages page visibility during load. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Perform Domain Registration Workflow Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Executes a full registration sequence including login, availability check, contact creation, and domain registration. Requires environment variables CNR_USER and CNR_PASSWORD for authentication. ```javascript import { APIClient } from "@team-internet/apiconnector"; const client = new APIClient(); async function registerDomain(domainName, contactData) { // Configure client client.useLIVESystem() // Use .useOTESystem() for testing .setCredentials(process.env.CNR_USER, process.env.CNR_PASSWORD) .enableDebugMode(); try { // Step 1: Login to establish session const loginResponse = await client.login(); if (!loginResponse.isSuccess()) { throw new Error(`Login failed: ${loginResponse.getDescription()}`); } console.log("Session established"); // Step 2: Check domain availability const checkResponse = await client.request({ COMMAND: "CheckDomains", DOMAIN: [domainName] }); if (!checkResponse.isSuccess()) { throw new Error(`Domain check failed: ${checkResponse.getDescription()}`); } const availability = checkResponse.getColumnIndex("DOMAINCHECK", 0); console.log(`Domain ${domainName} availability: ${availability}`); if (!availability.includes("210")) { throw new Error(`Domain ${domainName} is not available`); } // Step 3: Create contact const contactResponse = await client.request({ COMMAND: "AddContact", FIRSTNAME: contactData.firstName, LASTNAME: contactData.lastName, ORGANIZATION: contactData.organization || "", STREET: contactData.street, CITY: contactData.city, STATE: contactData.state, ZIP: contactData.zip, COUNTRY: contactData.country, PHONE: contactData.phone, EMAIL: contactData.email }); if (!contactResponse.isSuccess()) { throw new Error(`Contact creation failed: ${contactResponse.getDescription()}`); } const contactId = contactResponse.getColumnIndex("CONTACT", 0); console.log(`Contact created: ${contactId}`); // Step 4: Register domain const registerResponse = await client.request({ COMMAND: "AddDomain", DOMAIN: domainName, PERIOD: 1, // 1 year OWNERCONTACT0: contactId, ADMINCONTACT0: contactId, TECHCONTACT0: contactId, BILLINGCONTACT0: contactId, NAMESERVER0: "ns1.example.com", NAMESERVER1: "ns2.example.com" }); if (registerResponse.isSuccess()) { console.log(`Domain ${domainName} registered successfully!`); console.log("Expiration:", registerResponse.getColumnIndex("EXPIRATIONDATE", 0)); } else if (registerResponse.isPending()) { console.log(`Domain ${domainName} registration is pending approval`); } else { throw new Error(`Registration failed: ${registerResponse.getDescription()}`); } // Step 5: Logout await client.logout(); console.log("Session closed"); return registerResponse; } catch (error) { // Attempt logout even on error try { await client.logout(); } catch (e) { // Ignore logout errors } throw error; } } // Usage const contact = { firstName: "John", lastName: "Doe", organization: "Example Corp", street: "123 Main St", city: "New York", state: "NY", zip: "10001", country: "US", phone: "+1.2125551234", email: "john@example.com" }; registerDomain("my-new-domain.com", contact) .then(response => console.log("Registration complete")) .catch(error => console.error("Registration error:", error.message)); ``` -------------------------------- ### ISPAPI SDK Login with Two-Factor Authentication (2FA) Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Illustrates how to perform a login with a two-factor authentication (2FA) code by passing the OTP code as an argument to the `login` method. ```javascript const socketparameters = { // ... otp: "12345678", // your 2FA / otp code // ... } apiclient.login(socketparameters, function(r, socketcfg) { // your logic }) ``` ```javascript const r = await apiclient.login("12345678") // your logic here ``` -------------------------------- ### Methods Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html A comprehensive list of methods available in the SDK. ```APIDOC ## Methods ### Description Methods for manipulating and retrieving data within the SDK. ### Methods - **addColumn**(columnName: string, columnType: string) - Adds a column to the data structure. - **addRecord**(record: object) - Adds a new record. - **getCode**() - Retrieves the status code. - **getColumn**(columnName: string) - Retrieves a specific column. - **getColumnIndex**(columnName: string) - Retrieves the index of a column. - **getColumnKeys**() - Retrieves all column keys. - **getColumns**() - Retrieves all columns. - **getCommand**() - Retrieves the command object. - **getCommandPlain**() - Retrieves the command object as plain data. - **getCurrentPageNumber**() - Retrieves the current page number. - **getCurrentRecord**() - Retrieves the current record. - **getDescription**() - Retrieves the description. - **getFirstRecordIndex**() - Retrieves the index of the first record. - **getHash**() - Retrieves the hash value. - **getLastRecordIndex**() - Retrieves the index of the last record. - **getListHash**() - Retrieves the hash of the list. - **getNextPageNumber**() - Retrieves the next page number. - **getNextRecord**() - Retrieves the next record. - **getNumberOfPages**() - Retrieves the total number of pages. - **getPagination**() - Retrieves pagination information. - **getPlain**() - Retrieves the data as plain format. - **getPreviousPageNumber**() - Retrieves the previous page number. - **getPreviousRecord**() - Retrieves the previous record. - **getQueuetime**() - Retrieves the queue time. - **getRecord**(index: number) - Retrieves a record by its index. - **getRecords**() - Retrieves all records. - **getRecordsCount**() - Retrieves the count of records. - **getRecordsLimitation**() - Retrieves the records limitation. - **getRecordsTotalCount**() - Retrieves the total count of records. - **getRuntime**() - Retrieves the runtime information. - **hasNextPage**() - Checks if there is a next page. - **hasPreviousPage**() - Checks if there is a previous page. - **isError**() - Checks if an error occurred. - **isPending**() - Checks if the operation is pending. - **isSuccess**() - Checks if the operation was successful. - **isTmpError**() - Checks if a temporary error occurred. - **rewindRecordList**() - Rewinds the record list. ``` -------------------------------- ### ISPAPI SDK StartSession with Extended Parameters Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Shows how to pass extended parameters, such as `TIMEOUT`, to the `StartSession` API call using the `loginExtended` method. The OTP code for 2FA can also be provided. ```javascript // check definition of `socketparameters` in previous example apiclient.login(socketparameters, function(r, socketcfg) { // your logic }, "https://coreapi.1api.net/call/call.cgi", { TIMEOUT: 60 }) ``` ```javascript // check replacements for `socketparameters` in previous examples // providing otp code -> optional, use it for 2FA const r = await apiclient.loginExtended({ TIMEOUT: 60 }, "") // your logic here ``` -------------------------------- ### Access Response Templates Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Migrates from direct access to Response templates to using the ResponseTemplateManager singleton. ```javascript var defaultresponses = require("@hexonet/ispapi-apiconnector").Response.responses var tpl404 = defaultresponses["404"] //or any other template than 404 ``` ```javascript //singleton class const rtm = require("@hexonet/ispapi-apiconnector").ResponseTemplateManager.getInstance() const tpl404 = rtm.getTemplate("404").getPlain() ``` -------------------------------- ### Response Class Constructor Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html Initializes a new instance of the Response class with raw API data. ```APIDOC ## Constructor ### Description Initializes a new Response object to process raw API response strings. ### Parameters - **raw** (string) - Required - The plain API response string. - **cmd** (any) - Optional - The API command used for the request. - **ph** (any) - Optional - Placeholder array for dynamic description replacement. ### Returns - **Response** - A new instance of the Response class. ``` -------------------------------- ### Execute API Commands with APIClient Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Demonstrates sending commands to the API, including automatic IDN conversion, parameter flattening, and retrieving responses in various formats. ```javascript import { APIClient } from "@team-internet/apiconnector"; const client = new APIClient(); client.useOTESystem() .setCredentials("your-username", "your-password"); // Simple command execution (sessionless) const statusResponse = await client.request({ COMMAND: "StatusAccount" }); console.log("Code:", statusResponse.getCode()); // e.g., 200 console.log("Description:", statusResponse.getDescription()); // "Command completed successfully" console.log("Runtime:", statusResponse.getRuntime()); // e.g., 0.023 console.log("Queuetime:", statusResponse.getQueuetime()); // e.g., 0.004 // Check domain availability with bulk parameters (array automatically flattened) const checkResponse = await client.request({ COMMAND: "CheckDomains", DOMAIN: ["example.com", "example.net", "example.org"] }); // Internally converted to: DOMAIN0=example.com, DOMAIN1=example.net, DOMAIN2=example.org // Query domain list with pagination const listResponse = await client.request({ COMMAND: "QueryDomainList", FIRST: 0, LIMIT: 10 }); // IDN domains are automatically converted to punycode const idnResponse = await client.request({ COMMAND: "CheckDomains", DOMAIN: ["münchen.de", "日本.jp", "مثال.مصر"] }); // Get response in different formats console.log("Plain response:", statusResponse.getPlain()); console.log("Hash format:", statusResponse.getHash()); console.log("List format:", statusResponse.getListHash()); ``` -------------------------------- ### Constructors Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html Information about the constructors available in the SDK. ```APIDOC ## Constructors ### Description Details about the constructors used to initialize SDK components. ### Constructor - **constructor** - Initializes a new instance of the class. ``` -------------------------------- ### System Environment APIs Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/apiclient.APIClient.html Methods to switch between different system environments for API communication, including LIVE and OT&E systems. ```APIDOC ## POST /api/client/system/live ### Description Sets the API communication to use the LIVE System. This is the default setting. ### Method POST ### Endpoint /api/client/system/live ### Response #### Success Response (200) - **APIClient** (object) - The current APIClient instance, enabling method chaining. #### Response Example ```json { "message": "LIVE System selected for API communication." } ``` ## POST /api/client/system/ote ### Description Sets the API communication to use the OT&E (Outsourced Testing and Evaluation) System. ### Method POST ### Endpoint /api/client/system/ote ### Response #### Success Response (200) - **APIClient** (object) - The current APIClient instance, enabling method chaining. #### Response Example ```json { "message": "OT&E System selected for API communication." } ``` ``` -------------------------------- ### POST /login (Session-Based Authentication) Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Establishes a session with the API to reduce authentication overhead for subsequent requests. ```APIDOC ## POST /login ### Description Establishes a session with the API, returning a session ID that is automatically used for subsequent requests. ### Method POST ### Response #### Success Response (200) - **SESSIONID** (string) - The active session identifier. - **EXPIRATION DATE** (string) - The timestamp when the session expires. ### Response Example { "code": 200, "description": "Command completed successfully", "data": { "SESSIONID": "xyz123", "EXPIRATION DATE": "2023-12-31 23:59:59" } } ``` -------------------------------- ### Record Class Constructor Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/record.Record.html Initializes a new instance of the Record class. ```APIDOC ## new Record(data: any): Record ### Description Constructor for the Record class. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **data** (any) - Required - data object (use column names as object keys) ### Request Example ```json { "example": "{ \"column1\": \"value1\", \"column2\": \"value2\" }" } ``` ### Response #### Success Response (200) - **Record** - An instance of the Record class. #### Response Example ```json { "example": "Record object instance" } ``` ``` -------------------------------- ### Column Class Methods Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/column.Column.html Documentation for the constructor and methods of the Column class. ```APIDOC ## Column Class ### Description Represents a column of data associated with a specific key. ### Constructor - **new Column(key: string, data: string[])** - Creates a new instance of the Column class. ### Properties - **length** (number) - The count of column data entries. ### Methods #### getData() - **Description**: Get all column data. - **Returns**: string[] - The column data. #### getDataByIndex(idx: number) - **Description**: Get column data at a specific index. - **Parameters**: - **idx** (number) - Required - The index of the data to retrieve. - **Returns**: string | null - The data at the given index or null if not found. #### getKey() - **Description**: Get the column name (key). - **Returns**: string - The column name. ``` -------------------------------- ### APIClient Configuration Methods Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/apiclient.APIClient.html Methods to retrieve current configuration settings such as proxy, referer, and connection URL. ```APIDOC ## getProxy ### Description Get the proxy server configuration. ### Returns - **string | null** - Proxy server configuration value or null if not set ## getReferer ### Description Get the referer configuration. ### Returns - **string | null** - Referer configuration value or null if not set ## getURL ### Description Get the API connection URL that is currently set. ### Returns - **string** - API connection URL currently in use ``` -------------------------------- ### APIClient.setUserView() - Subuser Account Access Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Demonstrates how to use the `setUserView()` method to operate on behalf of a subuser account, enabling reseller scenarios. It also shows how to reset the view back to the main account. ```APIDOC ## APIClient.setUserView() - Subuser Account Access ### Description The `setUserView()` method allows operating on behalf of a subuser account, enabling reseller scenarios where actions are performed for sub-accounts. ### Method ```javascript client.setUserView("subuser-id"); ``` ### Endpoint N/A (This is a client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import { APIClient } from "@team-internet/apiconnector"; const client = new APIClient(); client.useOTESystem() .setCredentials("reseller-username", "reseller-password"); // Set view to a subuser account client.setUserView("subuser-id"); // All subsequent requests are executed in context of the subuser const response = await client.request({ COMMAND: "StatusAccount" }); console.log("Subuser registrar:", response.getColumnIndex("REGISTRAR", 0)); console.log("Subuser balance:", response.getColumnIndex("AMOUNT", 0)); // Reset back to main account view client.resetUserView(); const mainResponse = await client.request({ COMMAND: "StatusAccount" }); console.log("Main account registrar:", mainResponse.getColumnIndex("REGISTRAR", 0)); ``` ### Response N/A (This method modifies client state and does not return a direct API response.) ### Error Handling Refer to the general API client error handling for potential issues during credential setup or request execution. ``` -------------------------------- ### Manage API Sessions Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Illustrates saving a session object after login and reusing it in a new client instance. ```javascript import { APIClient } from "@team-internet/apiconnector"; const client = new APIClient(); client.useOTESystem() .setCredentials("your-username", "your-password"); // Login and establish session const loginResponse = await client.login(); if (loginResponse.isSuccess()) { // Save session to an object (e.g., for storing in Express session) const sessionStore = {}; client.saveSession(sessionStore); // sessionStore now contains: { socketcfg: { login: "...", session: "..." } } // Later, in another request handler or instance: const newClient = new APIClient(); newClient.useOTESystem() .reuseSession(sessionStore); // newClient can now make requests using the existing session const response = await newClient.request({ COMMAND: "StatusAccount" }); console.log("Session reused:", response.isSuccess()); } ``` -------------------------------- ### Session-Based Authentication with login() Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Establish a session using the login() method to obtain a session ID for subsequent authenticated API requests. Handles successful login, retrieves session details, and performs logout. ```javascript import { APIClient } from "@team-internet/apiconnector"; const client = new APIClient(); client.useOTESystem() .setCredentials("test.user", "test.password"); // Perform login to get session const loginResponse = await client.login(); if (loginResponse.isSuccess()) { console.log("Login successful!"); console.log("Session ID:", loginResponse.getColumnIndex("SESSIONID", 0)); console.log("Expiration:", loginResponse.getColumnIndex("EXPIRATION DATE", 0)); // Session is now active - subsequent requests will use the session automatically const statusResponse = await client.request({ COMMAND: "StatusAccount" }); console.log("Account Status:", statusResponse.getCode(), statusResponse.getDescription()); // Perform logout when done const logoutResponse = await client.logout(); if (logoutResponse.isSuccess()) { console.log("Logged out successfully"); } } else { console.error("Login failed:", loginResponse.getCode(), loginResponse.getDescription()); } ``` -------------------------------- ### Perform API Request with 2FA Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Shows how to set OTP codes for requests, noting that this must be done for every request. ```javascript var socketparameters = { params: { // ... otp: '12345678' // your 2FA / opt code here } } var callbackSuccess = function(r) { // your logic } var callbackError = function(r) { // your logic } apiclient.request({ COMMAND: "StatusAccount" }, socketparameters, cb, cb) ``` ```javascript // covering the previous example code // read the session-based section for details about // all socket parameter replacements // ... // set the otp code. this has to be done for EVERY request // therefore we suggest to switch to session-based API communication // if you are using 2FA or if you plan to use it apiclient.setOTP("12345678") const r = await apiclient.request({ COMMAND: "StatusAccount" }) // your logic here ``` -------------------------------- ### getCommand Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html Retrieves the command used in the request. ```APIDOC ## getCommand ### Description Get Command used in this request. ### Response - **Returns** (any) - command ``` -------------------------------- ### Handle Pagination with requestNextResponsePage Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Shows how to iterate through large result sets using requestNextResponsePage or fetch all pages at once with requestAllResponsePages. ```javascript import { APIClient } from "@team-internet/apiconnector"; const client = new APIClient(); client.useOTESystem() .setCredentials("your-username", "your-password"); // Initial query with pagination let response = await client.request({ COMMAND: "QueryDomainList", FIRST: 0, LIMIT: 100 }); console.log("Total domains:", response.getRecordsTotalCount()); console.log("Current page:", response.getCurrentPageNumber()); console.log("Total pages:", response.getNumberOfPages()); // Process all pages while (response !== null) { const records = response.getRecords(); records.forEach((record) => { console.log("Domain:", record.getDataByKey("DOMAIN")); console.log("Expiry:", record.getDataByKey("EXPIRATIONDATE")); }); // Check if there's a next page if (response.hasNextPage()) { response = await client.requestNextResponsePage(response); } else { response = null; } } // Or fetch all pages at once const allResponses = await client.requestAllResponsePages({ COMMAND: "QueryDomainList", LIMIT: 100 }); console.log(`Fetched ${allResponses.length} pages`); allResponses.forEach((page, index) => { console.log(`Page ${index + 1}: ${page.getRecordsCount()} records`); }); ``` -------------------------------- ### Pagination and Navigation Methods Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html Methods for navigating through paginated results. ```APIDOC ## hasNextPage ### Description Check if this list query has a next page. ### Returns - **boolean** - True if next page exists. ## hasPreviousPage ### Description Check if this list query has a previous page. ### Returns - **boolean** - True if previous page exists. ## rewindRecordList ### Description Reset the index in the record list back to zero. ### Returns - **Response** - Current Response instance for method chaining. ``` -------------------------------- ### Manage Response Templates with ResponseTemplateManager Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt Use the singleton instance to retrieve, add, and validate response templates for testing or fallback scenarios. ```javascript import { APIClient, ResponseTemplateManager, Response } from "@team-internet/apiconnector"; // Get the singleton instance const rtm = ResponseTemplateManager.getInstance(); // View all available templates const templates = rtm.getTemplates(); console.log("Available templates:", Object.keys(templates)); // ["404", "500", "empty", "error", "expired", "httperror", "invalid", "nocurl", "notfound", "unauthorized"] // Get a specific template const errorTemplate = rtm.getTemplate("httperror"); console.log("HTTP Error template:", errorTemplate.getPlain()); console.log("Error code:", errorTemplate.getCode()); console.log("Error description:", errorTemplate.getDescription()); // Add custom templates for testing or fallback scenarios rtm.addTemplate( "maintenance", rtm.generateTemplate("503", "API is under maintenance. Please try again later.") ); rtm.addTemplate( "customSuccess", "[RESPONSE]\r\nproperty[status][0] = OK\r\ndescription = Custom success\r\ncode = 200\r\nEOF\r\n" ); // Check if a response matches a template const response = await client.request({ COMMAND: "StatusAccount" }); const isHttpError = rtm.isTemplateMatchHash(response.getHash(), "httperror"); console.log("Is HTTP error:", isHttpError); // Check template existence console.log("Has maintenance template:", rtm.hasTemplate("maintenance")); // Generate template programmatically const customTemplate = rtm.generateTemplate("429", "Rate limit exceeded"); console.log("Generated template:", customTemplate); ``` -------------------------------- ### Modernize ISPAPI Client Login with Method Chaining Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Replace the parameter object for `apiclient.login` with chained method calls like `useOTESystem`, `setCredentials`, and `setRemoteIPAddress`. This approach simplifies login configuration and uses `async/await` for the login call. ```javascript const socketparameters = { entity: "1234", //OT&E system, use "54cd" for LIVE system login: "test.user", //your user id, here: the OT&E demo user pw: "test.passw0rd", //your user password //user: "",//can be used to work with a subuser account - optional remoteaddr: "1.2.3.4:80" //optional: provide your remote ip address (use for ip filter) } apiclient.login(socketparameters, function(r, socketcfg) { // your logic }) ``` ```javascript // replacement for the entity property // for "1234"/OTE system apiclient.useOTESystem() // for "54cd"/LIVE system - BY DEFAULT ACTIVE!!! // .useLIVESystem() //replacement for the login and pw properties .setCredentials("test.user", "test.passw0rd") // replacement for the user property // .setUserView("subuser_uid") // replacement for the remoteaddr property .setRemoteIPAddress("1.2.3.4:80") // perform login (+create a api session) const r = await apiclient.login() // your logic ``` -------------------------------- ### Properties Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html Details on the properties exposed by the SDK objects. ```APIDOC ## Properties ### Description Properties available on SDK objects. ### Properties - **hash** (any) - Represents a hash value. - **raw** (any) - Represents raw data. ``` -------------------------------- ### Client Configuration API Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/apiclient.APIClient.html Utility methods for retrieving client information and managing data views. ```APIDOC ## getUserAgent ### Description Get the User Agent. ### Returns - **string** - User Agent string ## getVersion ### Description Get the current module version. ### Returns - **string** - module version ## resetUserView ### Description Reset data view back from subuser to user. ### Returns - **APIClient** - Current APIClient instance for method chaining ``` -------------------------------- ### getInstance Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/responsetemplatemanager.ResponseTemplateManager.html Retrieves the singleton instance of the ResponseTemplateManager. ```APIDOC ## getInstance ### Description Get ResponseTemplateManager Instance. ### Returns - **ResponseTemplateManager** - ResponseTemplateManager Instance ``` -------------------------------- ### Core SDK Classes Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/modules/index.html Overview of the primary classes available in the @team-internet/apiconnector package. ```APIDOC ## Core Classes ### APIClient - **Description**: The primary client used to interface with the API. ### Response - **Description**: Represents the response object returned by API calls. ### ResponseTemplateManager - **Description**: Manages templates for processing or formatting API responses. ``` -------------------------------- ### Login with Role User Credentials in ISPAPI SDK Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Shows how to log in using role-based credentials by specifying the role user ID and password via `setRoleCredentials` before calling `login`. ```javascript const socketparameters = { // ... login: "test.user!testrole", // your user id and role user id separated by `!` pw: "test.passw0rd", // password set for the role user // ... } apiclient.login(socketparameters, function(r, socketcfg) { // your logic }) ``` ```javascript // when using a role user (directly available under user `uid`) // apiclient.setRoleCredentials("", "", "") // in case of the above example apiclient.setRoleCredentials("test.user", "testrole", "test.passw0rd") const r = await apiclient.login() ``` -------------------------------- ### getPlain Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html Retrieves the plain API response. ```APIDOC ## getPlain ### Description Get Plain API response. ### Returns - **string** - Plain API response ``` -------------------------------- ### Request with Specific Response Type Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Illustrates how to handle different response formats using the new Response object methods. ```javascript apiclient.request(command, socketcfg, callbackSuccess, callbackError, "list") apiclient.request(command, socketcfg, callbackSuccess, callbackError, "hash") ``` ```javascript const r = await apiclient.request(command) console.dir(r.getPlain()) // for plain API response console.dir(r.getHash()) // for hash format console.dir(r.getListHash()) // for list format ``` -------------------------------- ### getDescription Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html Retrieves the API response description. ```APIDOC ## getDescription ### Description Get API response description. ### Response - **Returns** (string) - API response description ``` -------------------------------- ### Save and Reuse ISPAPI Client Sessions Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Demonstrates how to save the current API client session using `saveSession` and reuse it later with `reuseSession`. This avoids repeated logins for subsequent requests. ```javascript //callback method of login method provides socketcfg req.session.socketcfg = socketcfg ``` ```javascript const apiclient = new apiconnector.Client() apiclient.request(command, req.session.socketcfg, cbSuccess, cbError, type) ``` ```javascript apiclient.saveSession(req.session) ``` ```javascript const apiclient = new apiconnector.Client() apiclient.reuseSession(req.session) const r = await apiclient.request(command) const typedresponse = (type === "list") ? r.getListHash() : r.getHash() ``` -------------------------------- ### SocketConfig Class Methods Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/socketconfig.SocketConfig.html Methods for managing login, password, session, and connection data within the SocketConfig class. ```APIDOC ## SocketConfig Methods ### getLogin - **Description**: Get account login to use. - **Returns**: string (Current login) ### getPOSTData - **Description**: Create POST data string out of connection data. - **Returns**: string (POST data string) ### getSession - **Description**: Get API Session ID in use. - **Returns**: string (API Session ID) ### setLogin - **Description**: Set account login to use. - **Parameters**: - **value** (string) - Required - account login - **Returns**: SocketConfig (Current instance) ### setPassword - **Description**: Set account password to use. - **Parameters**: - **value** (string) - Required - account password - **Returns**: SocketConfig (Current instance) ### setPersistent - **Description**: Set persistent to request session id. - **Returns**: SocketConfig (Current instance) ### setSession - **Description**: Set API Session ID to use. - **Parameters**: - **value** (string) - Required - API Session ID - **Returns**: SocketConfig (Current instance) ``` -------------------------------- ### APIClient.requestNextResponsePage() - Pagination Support Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt The `requestNextResponsePage()` method fetches the next page of results for list queries, enabling efficient iteration through large result sets. `requestAllResponsePages` can fetch all pages at once. ```APIDOC ## APIClient.requestNextResponsePage() & APIClient.requestAllResponsePages() ### Description Provides methods to handle paginated API responses, allowing you to fetch subsequent pages of results or retrieve all pages in a single operation. ### Method `requestNextResponsePage(response)` `requestAllResponsePages(commandObject)` ### Parameters #### `requestNextResponsePage` - **response** (object) - Required - The current response object obtained from a previous `request()` call that supports pagination. #### `requestAllResponsePages` - **commandObject** (object) - Required - An object containing the API command and its parameters, similar to the `request()` method. Must include pagination parameters like `LIMIT`. ### Request Example ```javascript import { APIClient } from "@team-internet/apiconnector"; const client = new APIClient(); client.useOTESystem() .setCredentials("your-username", "your-password"); // Initial query with pagination let response = await client.request({ COMMAND: "QueryDomainList", FIRST: 0, LIMIT: 100 }); console.log("Total domains:", response.getRecordsTotalCount()); console.log("Current page:", response.getCurrentPageNumber()); console.log("Total pages:", response.getNumberOfPages()); // Process all pages using requestNextResponsePage while (response !== null) { const records = response.getRecords(); records.forEach((record) => { console.log("Domain:", record.getDataByKey("DOMAIN")); console.log("Expiry:", record.getDataByKey("EXPIRATIONDATE")); }); if (response.hasNextPage()) { response = await client.requestNextResponsePage(response); } else { response = null; } } // Fetch all pages at once using requestAllResponsePages const allResponses = await client.requestAllResponsePages({ COMMAND: "QueryDomainList", LIMIT: 100 }); console.log(`Fetched ${allResponses.length} pages`); allResponses.forEach((page, index) => { console.log(`Page ${index + 1}: ${page.getRecordsCount()} records`); }); ``` ### Response #### Success Response (200) - **getRecordsTotalCount()** (integer) - Total number of records available across all pages. - **getCurrentPageNumber()** (integer) - The current page number being processed. - **getNumberOfPages()** (integer) - The total number of pages available. - **getRecords()** (array) - An array of records for the current page. - **hasNextPage()** (boolean) - Indicates if there is a next page of results. - **getRecordsCount()** (integer) - The number of records on the current page. #### Response Example ```javascript // Example for processing a single page console.log("Total domains:", response.getRecordsTotalCount()); console.log("Current page:", response.getCurrentPageNumber()); console.log("Total pages:", response.getNumberOfPages()); const records = response.getRecords(); records.forEach((record) => { console.log("Domain:", record.getDataByKey("DOMAIN")); }); // Example for processing all pages fetched by requestAllResponsePages console.log(`Fetched ${allResponses.length} pages`); allResponses.forEach((page, index) => { console.log(`Page ${index + 1}: ${page.getRecordsCount()} records`); }); ``` ``` -------------------------------- ### CNR_CONNECTION_URL_LIVE Constant Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/variables/apiclient.CNR_CONNECTION_URL_LIVE.html This constant defines the live API connection URL for the RRPProxy service. ```APIDOC ## Variable CNR_CONNECTION_URL_LIVE ### Description Defines the live URL for connecting to the RRPProxy API. ### Type Const ### Value `"https://api.rrpproxy.net/api/call.cgi"` ### Defined in `apiclient.ts:9` ``` -------------------------------- ### getCommandPlain Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/response.Response.html Retrieves the command used in the request as plain text. ```APIDOC ## getCommandPlain ### Description Get Command used in this request in plain text format. ### Response - **Returns** (string) - command as plain text ``` -------------------------------- ### APIClient.request() - Execute API Commands Source: https://context7.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/llms.txt The `request()` method sends commands to the CentralNic Reseller API. It automatically handles IDN conversion, parameter flattening, and response parsing. ```APIDOC ## APIClient.request() ### Description Executes commands against the CentralNic Reseller API, with automatic handling of Internationalized Domain Names (IDN) conversion, parameter flattening, and response parsing. ### Method `request(commandObject)` ### Parameters #### Request Body - **commandObject** (object) - Required - An object containing the API command and its parameters. - **COMMAND** (string) - Required - The name of the API command to execute (e.g., "StatusAccount", "CheckDomains"). - **DOMAIN** (string or array of strings) - Optional - Domain name(s) for the command. If an array, it will be flattened into numbered parameters (e.g., DOMAIN0, DOMAIN1). - **FIRST** (integer) - Optional - Used for pagination, specifies the starting offset. - **LIMIT** (integer) - Optional - Used for pagination, specifies the number of records to retrieve. ### Request Example ```javascript import { APIClient } from "@team-internet/apiconnector"; const client = new APIClient(); client.useOTESystem() .setCredentials("your-username", "your-password"); // Simple command execution const statusResponse = await client.request({ COMMAND: "StatusAccount" }); // Check domain availability with bulk parameters const checkResponse = await client.request({ COMMAND: "CheckDomains", DOMAIN: ["example.com", "example.net", "example.org"] }); // Query domain list with pagination const listResponse = await client.request({ COMMAND: "QueryDomainList", FIRST: 0, LIMIT: 10 }); // IDN domains are automatically converted to punycode const idnResponse = await client.request({ COMMAND: "CheckDomains", DOMAIN: ["münchen.de", "日本.jp", "مثال.مصر"] }); ``` ### Response #### Success Response (200) - **getCode()** (integer) - The HTTP status code of the response. - **getDescription()** (string) - A description of the command's outcome. - **getRuntime()** (float) - The execution time of the command in seconds. - **getQueuetime()** (float) - The time spent in the queue before execution in seconds. - **getPlain()** (string) - The raw response body. - **getHash()** (object) - The response parsed into a hash map. - **getListHash()** (object) - The response parsed into a list of hash maps. #### Response Example ```javascript console.log("Code:", statusResponse.getCode()); console.log("Description:", statusResponse.getDescription()); console.log("Runtime:", statusResponse.getRuntime()); console.log("Queuetime:", statusResponse.getQueuetime()); console.log("Plain response:", statusResponse.getPlain()); console.log("Hash format:", statusResponse.getHash()); console.log("List format:", statusResponse.getListHash()); ``` ``` -------------------------------- ### getPOSTData Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/classes/apiclient.APIClient.html Serializes a command for a POST request, including connection configuration data. ```APIDOC ## getPOSTData ### Description Serialize given command for POST request including connection configuration data. ### Parameters - **cmd** (any) - Required - API command to encode - **secured** (boolean) - Optional - Default: false ### Returns - **string** - Encoded POST data string ``` -------------------------------- ### Update Client Instantiation in ISPAPI Node.js SDK Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide Update how the ISPAPI client is instantiated by changing `new apiconnector.Client()` to `new apiconnector.APIClient()` and using `require` with `const`. ```javascript var apiconnector = require('@hexonet/ispapi-apiconnector') var apiclient = new apiconnector.Client() ``` ```javascript const apiconnector = require('@hexonet/ispapi-apiconnector') const apiclient = new apiconnector.APIClient() ``` -------------------------------- ### SocketConfig Class Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/modules/socketconfig.html Represents the configuration settings for socket connections. ```APIDOC ## SocketConfig ### Description Class used to manage and store configuration settings required for establishing socket connections. ### Class Reference - **SocketConfig** (Class) - Provides the structure for socket-related configuration parameters. ``` -------------------------------- ### Simplified ISPAPI Request Method Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/wiki/Migration-Guide The `request` method has been simplified. It no longer requires the `socketcfg` parameter or separate success/error callbacks. The response is now a single object that handles both success and error cases. ```javascript // NOTE: socketcfg provided by the login method callback var callbackSuccess = function(r) { //your logic } var callbackError = function(r) { //your logic } apiclient.request({ COMMAND: "StatusUser" }, socketcfg, callbackSuccess, callbackError) ``` ```javascript const r = await apiclient.request({ COMMAND: "StatusUser" }) // your logic here. success case and error case logic covered // in that single request and returned as Response object // accordingly ``` -------------------------------- ### Record Class Source: https://github.com/centralnicgroup-opensource/rtldev-middleware-node-sdk/blob/master/docs/modules/record.html Documentation for the Record class used in the SDK. ```APIDOC ## Record Class ### Description The Record class is a core component of the @team-internet/apiconnector module, providing functionality for handling record-based operations within the middleware SDK. ```