INFO: get ALL SM devices in ALL networks for a given org ID and API key

Meraki Employee

INFO: get ALL SM devices in ALL networks for a given org ID and API key



I had a request from a customer who, because they had 35 networks, wanted a more automated way to export Systems Manager device data. So, I wanted to share this:


# This script, for a given API key, and org ID
# For each network, get the SM devices and print to screen
# Mandatory arguments:
# -k <API KEY>      : Your Meraki Dashboard API Key
# -o <Org. ID>      : Your Meraki Org ID
# Pre requisites:
# Meraki library : pip install meraki :

import meraki
import sys, getopt

def main(argv):

    print("Meraki Library version: ")

    arg_apikey = False

        opts, args = getopt.getopt(argv, 'k:o:')
    except getopt.GetOptError:

    for opt, arg in opts:
        if opt == '-k':
            arg_apikey = arg
        if opt == "-o":
            arg_orgId = arg

    # Create Meraki Client Object and initialise
    client = meraki.DashboardAPI(api_key=arg_apikey)

    networks = client.organizations.getOrganizationNetworks(organizationId=arg_orgId)

    print("networkID, model, osName, systemModel")
    for network in networks:
        networkName = (network['name'])
        networkID = (network['id'])

            devices =, fields={"ip"})
            if len(devices) == 0:
                # no devices
                print("No devices in this SM network")
                for device in devices:
                    print(networkID, ",", device["name"], ",", device["osName"], ",", device["systemModel"])

        except meraki.APIError as e:
            print("No SM in " + networkName + " network")

def printhelp():
    # prints help information
    print('This is a script to Get the SM ldevices across multiple networks.')
    print('Mandatory arguments:')
    print(' -k <api key>         : Your Meraki Dashboard API key')
    print(' -o <Org. ID>         : Your Meraki Org ID')

if __name__ == '__main__':


You'll note:

fields={"ip"} : As per!get-network-sm-devices 

The default fields are: id, name, tags, ssid, wifiMac, osName, systemModel, uuid, and serialNumber. The additional fields are: ip,
systemType, availableDeviceCapacity, kioskAppName, biosVersion, lastConnected, missingAppsCount, userSuppliedAddress, location, lastUser, ownerEmail, ownerUsername, osBuild, publicIp, phoneNumber, diskInfoJson, deviceCapacity, isManaged, hadMdm, isSupervised, meid, imei, iccid, simCarrierNetwork, cellularDataUsed, isHotspotEnabled, createdAt, batteryEstCharge, quarantined, avName, avRunning, asName, fwName, isRooted, loginRequired, screenLockEnabled, screenLockDelay, autoLoginDisabled, autoTags, hasMdm, hasDesktopAgent, diskEncryptionEnabled,hardwareEncryptionCaps, passCodeLock, usesHardwareKeystore, androidSecurityPatchVersion, and url.


print(networkID, ",", device["name"], ",", device["osName"], ",", device["systemModel"])

the script prints just a handful of fields returned for demo purposes. You can expand the above as you see fit


It's called with:


python3 -k yourMerakiAPIKey -o yourMerfakiOrgID


Kind of a big deal

Good effort!

Get notified when there are additional replies to this discussion.