UAPI Functions - NVData::get

Description

This function retrieves an environment variable's value.

Examples 


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/execute/NVData/get?names=testfile

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// Get the NVData file "testfile".
$get_nvdata $cpanel->uapi(
    'NVData''get',
    array(
        'names'    => 'testfile',
    )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# Get the NVData file "testfile".
my $get_nvdata $cpliveapi->uapi(
    'NVdata''get',
    {
        'names'    => 'testfile',
    }
);

 cPanel Template Toolkit

<!--  Get the minimum password strength for webdisk. -->
[% data = execute( 'NVdata', 'get', { names => 'testfile'} ); %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]

 Command Line

uapi --user=username NVData get names=testfile

 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.

 Output (JSON)

{
  "messages": null,
  "errors": null,
  "status": 1,
  "data": [
    {
      "value": "testvalue",
      "name": "testfile"
    }
  ],
  "metadata": {
    "transformed": 1
  }
}

 

Note:

Use cPanel's API Shell interface (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

 Parameter 

Type

Description

Possible values

 Example 

names

 string 

Required

 The file or files to retrieve. 

 A valid file path, relative to the /home/user/.cpanel/nvdata directory, where user represents the cPanel user. 

Note:

To retrieve multiple files, separate each file with a pipe (|) character.

testfile

 

 

Returns

 Return 

Type

Description

Possible values

 Example 

 

 array of hashes 

 An array of hashes that contains information about the non-volatile data. 

 This array of hashes includes the nameand value returns. 

 

name

string

The file's name.

The function returns this value in the unnamedhash.

A valid string.

testfile

value

string

The file's contents.

The function returns this value in the unnamedhash.

A valid string.

testvalue

 

  • 15 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....