{"id":185,"date":"2022-01-05T15:47:05","date_gmt":"2022-01-05T15:47:05","guid":{"rendered":"http:\/\/duff.io\/?p=185"},"modified":"2022-01-05T17:03:33","modified_gmt":"2022-01-05T17:03:33","slug":"meraki-api","status":"publish","type":"post","link":"https:\/\/duff.io\/?p=185","title":{"rendered":"Meraki API"},"content":{"rendered":"\n<p>So Cisco\/Meraki has some <a href=\"https:\/\/developer.cisco.com\/meraki\/api-v1\/#!python\">pretty good documentation at using the Meraki API with Python.<\/a> Short version is use pip to install Meraki (<code>pip install meraki<\/code>) and then in your shell set an environmental variable called <code>MERAKI_DASHBOARD_API_KEY<\/code> to your Meraki API key (<code>export MERAKI_DASHBOARD_API_KEY=xxxxxxx<\/code>) which can be enabled and found (see <a href=\"https:\/\/documentation.meraki.com\/zGeneral_Administration\/Other_Topics\/The_Cisco_Meraki_Dashboard_API\">https:\/\/documentation.meraki.com\/zGeneral_Administration\/Other_Topics\/The_Cisco_Meraki_Dashboard_API<\/a>). Below is a little script to grab information about the APs in your network. You&#8217;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&#8217;ll have to loop through those to find the id of your organization. The script also makes calls to <code>getDeviceWirelessRadioSettings<\/code> and <code>getDeviceWirelessStatus<\/code> which provides more information about those APs, but I don&#8217;t make any efforts to format or do anything with the results.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">import meraki\n\ndashboard = meraki.DashboardAPI()\n#name of my network that has APs\nap_network_name = \"xyxy\"\n\n# Get orgs linked to API key\nmy_orgs = dashboard.organizations.getOrganizations()\n# Get networks linked to org. Assuming there is only one org (true in my case)\nmy_networks = dashboard.organizations.getOrganizationNetworks(organizationId=my_orgs[0][\"id\"])\n# Find the network ID of the network with my network name\nfor netw in my_networks:\n\tif (netw[\"name\"] == ap_network_name):\n\t\tmy_netw = netw[\"id\"]\n\nmy_devices = dashboard.networks.getNetworkDevices(networkId=my_netw)\n\nfor a_device in my_devices:\n\ttry:\n\t\t# Filter out the devices that aren't APs\n\t\tif(a_device[\"firmware\"][:8] == \"wireless\"):\n\t\t\t# print some basic info on the APs\n\t\t\tprint(a_device[\"name\"],a_device[\"serial\"],a_device[\"firmware\"],a_device[\"model\"],a_device[\"firmware\"])\n\t\t\tserial = a_device[\"serial\"]\n\t\t\t# get some info on the radio settings for the AP\n\t\t\twireless = dashboard.wireless.getDeviceWirelessRadioSettings(serial)\n\t\t\tprint(wireless)\n\t\t\t# get some more detailed info on the AP\n\t\t\twifi_status = dashboard.wireless.getDeviceWirelessStatus(serial)\n\t\t\tprint(wifi_status)\n\texcept:\n\t\tprint(\"error for\", a_device[\"serial\"])\n# print(my_devices)\n<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 https:\/\/documentation.meraki.com\/zGeneral_Administration\/Other_Topics\/The_Cisco_Meraki_Dashboard_API). Below is a little [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,18],"tags":[],"class_list":["post-185","post","type-post","status-publish","format-standard","hentry","category-meraki","category-python"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=185"}],"version-history":[{"count":2,"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts\/185\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}