Meraki API

So Cisco/Meraki has some pretty good documentation at using the Meraki API with Python. Short version is use pip to install Meraki (pip install meraki) and then in your shell set an environmental variable called MERAKI_DASHBOARD_API_KEY to your Meraki API key (export MERAKI_DASHBOARD_API_KEY=xxxxxxx) which can be enabled and found (see Below is a little script to grab information about the APs in your network. You’ll need to specify the network name in the Meraki Dashboard. The script assumes there is only one organization, if you have more than one, you’ll have to loop through those to find the id of your organization. The script also makes calls to getDeviceWirelessRadioSettings and getDeviceWirelessStatus which provides more information about those APs, but I don’t make any efforts to format or do anything with the results.

import meraki

dashboard = meraki.DashboardAPI()
#name of my network that has APs
ap_network_name = "xyxy"

# Get orgs linked to API key
my_orgs = dashboard.organizations.getOrganizations()
# Get networks linked to org. Assuming there is only one org (true in my case)
my_networks = dashboard.organizations.getOrganizationNetworks(organizationId=my_orgs[0]["id"])
# Find the network ID of the network with my network name
for netw in my_networks:
	if (netw["name"] == ap_network_name):
		my_netw = netw["id"]

my_devices = dashboard.networks.getNetworkDevices(networkId=my_netw)

for a_device in my_devices:
		# Filter out the devices that aren't APs
		if(a_device["firmware"][:8] == "wireless"):
			# print some basic info on the APs
			serial = a_device["serial"]
			# get some info on the radio settings for the AP
			wireless = dashboard.wireless.getDeviceWirelessRadioSettings(serial)
			# get some more detailed info on the AP
			wifi_status = dashboard.wireless.getDeviceWirelessStatus(serial)
		print("error for", a_device["serial"])
# print(my_devices)


Leave a Reply

Your email address will not be published. Required fields are marked *