Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Retrieve the Value of an Option in Tweak Settings — get_tweaksetting

You can use this function to retrieve the value of an option available on the WHM Tweak Settings screen. The keys and values needed to perform this function are in the /var/cpanel/cpanel.config file.

Calling Functions

Using the XML API

To use the XML API to perform the get_tweaksetting function from within your custom script:

  • Append the /xml-api/get_tweaksetting function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/get_tweaksetting

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the get_tweaksetting function from within your custom script:

  • Append the /json-api/get_tweaksetting function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/get_tweaksetting

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The following parameter is required:
  • api.version (integer) — The version of the API to use. When using the get_tweaksetting function, this parameter should always be passed: 1

The following variable is required:

  • key (string) — The Tweak Settings option whose value you wish to retrieve.

The following variable is optional:

  • module (string) — The option's tab or section on the Tweak Settings screen. This parameter's default value is Main.

Output

  • result — The function's root-level results container.
    • data — The function's data container.
      • tweaksetting — The results container for the Tweak Settings option.
        • value — The value of the requested Tweak Settings option. When an option is undef, no value parameter will be returned by the function. If the value parameter is empty, you will see the following:
          • <value></value>
        • key (string) — The key for the Tweak Settings option.
    • metadata — The function's metadata container.
      • version (integer) — The API version.
      • reason (string) — A message of success or a reason for failure.
      • command (string) — The function used to retrieve the data. In this case, get_tweaksetting.

Examples

XML API

Calling the following function in WebHost Manager:

https://domain.tld:2087/xml-api/get_tweaksetting?api.version=1&key=update_log_analysis_retention_length

will produce output similar to:

<result>
  <data>
    <tweaksetting>
      <value>90</value>
      <key>update_log_analysis_retention_length</key>
    </tweaksetting>
  </data>
  <metadata>
    <version>1</version>
    <reason>OK</reason>
    <result>1</result>
    <command>get_tweaksetting</command>
  </metadata>
</result>

JSON API

Calling the following function in WebHost Manager:

https://domain.tld:2087/json-api/get_tweaksetting?api.version=1&key=update_log_analysis_retention_length

will produce output similar to:

{
    result:{
        data:{
            tweaksetting:{
                value:90,
                key:'update_log_analysis_retention_length'
            }
        },
        metadata:{
            version:1,
            reason:'OK',
            result:1,
            command:'get_tweaksetting'
        }
    }
}

Topic revision: r6 - 13 Jan 2014 - 19:03:39 - Main.ShavaunTesareski