cPanel API 2 Functions - ZoneEdit::fetchzone_records

Description

This function retrieves the domain's zone record modifications.

Warning:

We strongly recommend that you use UAPI instead of cPanel API 2. However, no equivalent UAPI function exists.

 

Note:

On servers that run CentOS 7, you may see a named warning about the absence of SPF resource records on DNS.

  • This warning is not relevant on CentOS 7 servers, because RFC 7208 deprecated SPF records. CentOS 7 servers use TXT records instead of SPF records.
  • Red Hat 7.1 and CentOS 7.1 both contain bind-9.9.4-23.el7, which is an updated version of BIND that complies with RFC 7208. To resolve this issue, update your operating system to a version that contains the updated version of BIND. 

Examples 


 WHM API (JSON)

https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=fetchzone_records&domain=example.com

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// Retrieve the "example.com" domain's zone record modifications.
$fetchzone_record $cpanel->api2(
    'ZoneEdit''fetchzone_records',
 array(
        'domain' => 'example.com',
  )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# Retrieve the "example.com" domain's zone record modifications.
my $fetchzone_record $cpliveapi->api2(
    'ZoneEdit''fetchzone_records',
{
        'domain' => 'example.com',
   }
);

 cPanel Tag System (deprecated)

Warning:

In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs.

cPanel API 2 calls that use cPanel tags vary widely in code syntax and in their output. For more information, read ourDeprecated cPanel Tag Usage documentation. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI.


 Command Line

cpapi2 --user=username ZoneEdit fetchzone_records domain=example.com

 

Notes:

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

 Output (JSON)

{
  "cpanelresult": {
    "apiversion": 2,
    "func": "fetchzone_records",
    "data": [
      {
        "record": null,
        "Line": 1,
        "ttl": "86400",
        "type": ":RAW",
        "raw": "; cPanel first:11.47.0.9999 (update_time):1413489769 Cpanel::ZoneFile::VERSION:1.3 hostname:laurence.dev.cpanel.net latest:11.47.0.9999",
        "line": 1
      },
      {
        "record": null,
        "Line": 2,
        "ttl": "86400",
        "type": ":RAW",
        "raw": "; Zone file for example.com",
        "line": 2
      },
      {
        "record": null,
        "Line": 3,
        "ttl": "14400",
        "type": "$TTL",
        "line": 3
      },
      {
        "minimum": "86400",
        "ttl": "86400",
        "serial": "2014101608",
        "name": "example.com.",
        "mname": "ns1.dev.cpanel.net",
        "retry": "7200",
        "record": null,
        "refresh": "86400",
        "Line": 4,
        "Lines": 6,
        "class": "IN",
        "type": "SOA",
        "rname": "username.example.net",
        "expire": "3600000",
        "line": 4
      },
      {
        "record": null,
        "Line": 10,
        "ttl": "86400",
        "type": ":RAW",
        "raw": "",
        "line": 10
      },
      {
        "nsdname": "ns1.dev.cpanel.net",
        "ttl": "86400",
        "name": "example.com.",
        "record": null,
        "Line": 11,
        "type": "NS",
        "class": "IN",
        "line": 11
      },
      {
        "nsdname": "ns2.dev.cpanel.net",
        "ttl": "86400",
        "name": "example.com.",
        "record": null,
        "Line": 12,
        "type": "NS",
        "class": "IN",
        "line": 12
      },
      {
        "record": null,
        "Line": 13,
        "ttl": "86400",
        "type": ":RAW",
        "raw": "",
        "line": 13
      },
      {
        "record": null,
        "Line": 14,
        "ttl": "86400",
        "type": ":RAW",
        "raw": "",
        "line": 14
      },
      {
        "ttl": "14400",
        "name": "example.com.",
        "record": "10.215.214.95",
        "Line": 15,
        "type": "A",
        "class": "IN",
        "address": "10.215.214.95",
        "line": 15
      },
      {
        "ttl": "14400",
        "name": "example.com.",
        "record": "2001:db8:1a34:56cf:0:0:0:0",
        "Line": 16,
        "type": "AAAA",
        "class": "IN",
        "address": "2001:db8:1a34:56cf:0:0:0:0",
        "line": 16
      },
      {
        "ttl": "14400",
        "name": "localhost.example.com.",
        "record": "127.0.0.1",
        "Line": 17,
        "type": "A",
        "class": "IN",
        "address": "127.0.0.1",
        "line": 17
      },
      {
        "ttl": "14400",
        "name": "localhost.example.com.",
        "record": "0:0:0:0:0:0:0:1",
        "Line": 18,
        "type": "AAAA",
        "class": "IN",
        "address": "0:0:0:0:0:0:0:1",
        "line": 18
      },
      {
        "record": null,
        "Line": 19,
        "ttl": "86400",
        "type": ":RAW",
        "raw": "",
        "line": 19
      },
      {
        "ttl": "14400",
        "name": "example.com.",
        "preference": "0",
        "record": null,
        "Line": 20,
        "type": "MX",
        "class": "IN",
        "exchange": "example.com",
        "line": 20
      },
      {
        "record": null,
        "Line": 21,
        "ttl": "86400",
        "type": ":RAW",
        "raw": "",
        "line": 21
      },
      {
        "ttl": "14400",
        "name": "mail.example.com.",
        "cname": "example.com",
        "record": "example.com",
        "Line": 22,
        "type": "CNAME",
        "class": "IN",
        "line": 22
      },
      {
        "ttl": "14400",
        "name": "www.example.com.",
        "cname": "example.com",
        "record": "example.com",
        "Line": 23,
        "type": "CNAME",
        "class": "IN",
        "line": 23
      },
      {
        "ttl": "14400",
        "name": "ftp.example.com.",
        "record": "10.215.214.95",
        "Line": 24,
        "type": "A",
        "class": "IN",
        "address": "10.215.214.95",
        "line": 24
      },
      {
        "ttl": "14400",
        "name": "ftp.example.com.",
        "record": "2001:db8:1a34:56cf:0:0:0:0",
        "Line": 25,
        "type": "AAAA",
        "class": "IN",
        "address": "2001:db8:1a34:56cf:0:0:0:0",
        "line": 25
      },
      {
        "ttl": "14400",
        "name": "fish.example.com.",
        "record": "10.215.214.95",
        "Line": 26,
        "type": "A",
        "class": "IN",
        "address": "10.215.214.95",
        "line": 26
      },
      {
        "ttl": "14400",
        "name": "fish.example.com.",
        "record": "2001:db8:1a34:56cf:0:0:0:0",
        "Line": 27,
        "type": "AAAA",
        "class": "IN",
        "address": "2001:db8:1a34:56cf:0:0:0:0",
        "line": 27
      },
      {
        "ttl": "14400",
        "name": "default._domainkey.fish.example.com.",
        "unencoded": 1,
        "record": "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDw5nw4NP1RsWXlfmiMzByDfOT16QCZO\/xJtrPZKskZF8\/sU0zWGTqKUOErlyJfoJzMDUv3\/zzjGswc2nEmYqxxoQZaBkN4QaS6MvJQxysAr+sK8C248\/r9zMperQdhJedUVejtpFQHJwgqpHy1tQMxY37L7sQjdxmQ5WnQ1acXiwIDAQAB;",
        "Line": 28,
        "txtdata": "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDw5nw4NP1RsWXlfmiMzByDfOT16QCZO\/xJtrPZKskZF8\/sU0zWGTqKUOErlyJfoJzMDUv3\/zzjGswc2nEmYqxxoQZaBkN4QaS6MvJQxysAr+sK8C248\/r9zMperQdhJedUVejtpFQHJwgqpHy1tQMxY37L7sQjdxmQ5WnQ1acXiwIDAQAB;",
        "type": "TXT",
        "class": "IN",
        "line": 28
      },
      {
        "record": null,
        "Line": 29,
        "ttl": "86400",
        "type": ":RAW",
        "raw": "",
        "line": 29
      },
      {
        "ttl": "14400",
        "name": "cpanel.example.com.",
        "record": "10.215.214.95",
        "Line": 30,
        "type": "A",
        "class": "IN",
        "address": "10.215.214.95",
        "line": 30
      },
      {
        "ttl": "14400",
        "name": "webdisk.example.com.",
        "record": "10.215.214.95",
        "Line": 31,
        "type": "A",
        "class": "IN",
        "address": "10.215.214.95",
        "line": 31
      },
      {
        "ttl": "14400",
        "name": "whm.example.com.",
        "record": "10.215.214.95",
        "Line": 32,
        "type": "A",
        "class": "IN",
        "address": "10.215.214.95",
        "line": 32
      }
    ],
    "event": {
      "result": 1
    },
    "module": "ZoneEdit"
  }
}

 

Note:

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

 

Parameters

 Parameters 

 Type 

Description

Possible values

Example

domain

string

Required

 The record's domain. 

 A valid domain name. 

 example.com 

 

Returns


Return

Type

Description

Possible values

Example

result

hash

A hash of the results of the zonefile's records.

This hash includes the parameters below. The array's hashes depend on the zone file's record type.

 

Line

integer

The record's line in the zonefile.

The function returns this value in the result hash.

A positive integer.

1

Lines

integer

The number of lines within the record.

The function returns this value in the result hash.

A positive integer.

1

line

integer

The record's line in the zonefile.

The function returns this value in the result hash.

A positive integer.

1

record

integer

The address, cname, txtdata, or rawcontent of the record.

The function returns this value in the result hash.

A value from the address, cname, txtdata, or raw values.

(see address, cname,txtdata, and rawvalues)

mname

string

The name server record.

The function returns this value in the result hash.

A valid domain name.

ns1.example.com

rname

string

A contact address for the name server record.

The function returns this value in the result hash.

An email address, but a period (.) thatreplaces the at symbol (@).

username.example.com

retry

integer

 The time between retries if the secondary name server fails to contact the master when the refresh period expires, in seconds.

The function returns this value in the result hash.

A positive integer.

7200

refresh

integer

The interval between tries when the secondary name server refreshes a non-authoritative zone from the master.

The function returns this value in the result hash.

A positive integer that represents the interval in seconds.

86400

expire

integer

The period before the secondary name server marks the zone as no longer authoritative and tries to refresh the data, in seconds.

The function returns this value in the result hash.

A positive integer that represents the interval in seconds.

3600000

ttl

integer

The record's time to live, in seconds.

The function returns this value in the result hash.

A positive integer that represents the interval in seconds.

14400

txtdata

string

The record's text data.

The function returns this value in the result hash.

The contents of a DKIM, SPF, or other TXT-based record.

v=blahblahblah

uuencode

Boolean

Whether the record is uuencoded.

The function returns this value in the result hash.

  • 1 — uuencoded.
  • 0 — Not uuencoded.

1

raw

string

The record's raw output.

The function returns this value in the result hash.

A valid string.

v=blahblahblah

cname

string

The record's canonical name.

The function returns this value in the result hash.

A valid hostname.

hostname.example.com

address

string

The record's IP address.

The function returns this value in the result hash.

A valid IPv4 or IPv6 address.

192.168.0.1

class

string

The record's class.

The function returns this value in the result hash.

IN

IN

type

string

The record's type.

The function returns this value in the result hash.

The most common results will be the following:

  • A
  • AAAA
  • CNAME
  • MX
  • NS
  • RAW — This represents a blank line in the zone record. 
  • SOA

 

A

name

string

The record's name, which will map to the subdomain.

The function returns this value in the result hash.

A valid subdomain.

hostname.example.com

txtdata

string

If the type return's value is TXT, the record's text data.

The function returns this value in the result hash.

A valid string.

v=blahblahblah

cname

string

If the type return's value is CNAME, the record's canonical name.

The function returns this value in the result hash.

A valid string.

hostname.example.com

exchange

string

If the type return's value is MX, the mail exchange's hostname.

The function returns this value in the result hash.

A valid hostname.

mail.example.com

nsdname

string

If the type return's value is NS, the authoritative nameserver's hostname.

The function returns this value in the result hash.

A valid hostname.

ns1.example.com

 preference 

integer

If the type return's value is MX, the priority of the mail exchanger.

The function returns this value in the result hash.

A valid integer, where smaller numbers represent higher priority mail exchanges.

1

reason

string

A reason for failure.

Note:

This function only returns areason value if it failed.

A string that describes the error.

This is an error message.

result

 Boolean 

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.

1

 

  • 4 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....