Methods

The complete information that you can obtain with the Metadata APi is the following.

http://169.254.169.254

2017-04-23/ All methods available in this first version of the API released on 23/04/2017. When new methods are added/changed, new dates will appear.
latest/ All current methods available in the API.
meta_data/ All metadata information related with the server from which you are querying.
user_data Information set by the user when created the server. More information here.
vendor_data Internal information about the configuration of the Cloud Config modules.

http://169.254.169.254/latest/meta_data

server_id Id of the server where this request is executed. The id matches with the internal server’s id for the public Cloud Server API.
hostname Initial hostname of the server.
public_hostname Public hostname of the server. Not available for all servers. Empty in that case.
datacenter datecenter where the server is located.
interfaces/ information regarding the public and private interfaces.
dns/ intormation about the dns configured for the server.

http://169.254.169.254/latest/meta_data/interfaces/

public/ lists the public interfaces assigned to the server. Usually only one.
private/ lists the private interfaces assigned to the server.

http://169.254.169.254/latest/meta_data/interfaces/public/

0/ shows information about the first public interface.

http://169.254.169.254/latest/meta_data/interfaces/public/0/

mac MAC of the interface.
ipv4/ lists the IPv4 IP assigned to the server.

http://169.254.169.254/latest/meta_data/interfaces/public/0/ipv4/

0/ first IP assigned to the server.

http://169.254.169.254/latest/meta_data/interfaces/public/0/ipv4/0/

ip_address IP address.
netmask/ Netmask configured for the IP.
gateway/ gateway configured for the IP.

http://169.254.169.254/latest/meta_data/dns/

nameservers list of the nameservers configured for the server.

UserData

http://169.254.169.254/latest/meta_data/interfaces/

When you are creating a server from the CloudPanel, there is a special field in Advanced Options called UserData. There you can type any text that will be saved as the UserData for the server. It will be accessible from the Metadata API.

But the real use of the UserData is the connection that it has with Cloud Init. Cloud Init is a special package that we have preinstalled in certain OS (CentOS, Ubuntu, Debian, Windows) that allows you to execute scripts that you type in the UserData field within your server.

CloudInit has its own meta-language called CloudConfig. You can see different examples in its webpage.

There are also other programming languages allowed as bash, Powershell or Command-Line These scripts can take advantage of the Metadata API because they will be executed after your server is deployed. So, you can declare a variable IP with the content of the request:

curl http://169.254.169.254/latest/meta_data/interfaces/public/0/ipv4/0/ip_address

These scripts are useful to configure the server as you like after its creation. You can install packages, users, configure services, etc.