Initialization

The NetworkAsCodeClient is the entry-point to all the functionality Network as Code provides. It allows you to identify the client and devices to use Network as Code. The Network as Code client and device creation comes right after the installation step described in our Getting-started guide.

Creating a Network as Code Client objectheader link

import network_as_code as nac

from network_as_code.models.device import Device, DeviceIpv4Addr

client = nac.NetworkAsCodeClient(
    token="<your-application-key-here>",
)

Creating a Device objectheader link

The client.devices.get() method is equally important and it will identify your client's device. It holds the DeviceIpv4Addr() model, previously imported in your code, and the multiple optional parameters for the client's device.

Learn more about the multiple ways you can identify devices here.

import network_as_code as nac

from network_as_code.models.device import Device, DeviceIpv4Addr

client = nac.NetworkAsCodeClient(
    token="<your-application-key-here>"
)

my_device = client.devices.get(
    "[email protected]",
    ipv4_address=DeviceIpv4Addr(
        public_address="233.252.0.2",
        private_address="192.0.2.25",
        public_port=80
    ),
    ipv6_address="2001:db8:1234:5678:9abc:def0:fedc:ba98",
    # The phone number does not accept spaces or parentheses
    phone_number="+36721601234567"
)

NOTE: All the parameters in the client.devices.get() method are optional, but you will need to use at least one of them.

Device parametersheader link

ParameterDescription
network_access_identifierThe Device ID can work as an alternate for phone number.
ipv4_addressPublic, private IPv4 addresses and ports can be passed within the DeviceIPv4Addr model.
ipv6_addressWhere a public or private IPv6 address can be informed.
phone_numberSimple phone-number identifier for devices or users owning the mobile subscription.

What's next?header link

Now you're ready to set up your Network as Code client and device and use its multiple functionalities. How about diving deeper into the multiple ways you can identify mobile network devices?

Last updated November 05, 2025