Need to pull the latitude and longitude for every network in my organization

karlwinters
New here

Need to pull the latitude and longitude for every network in my organization

I am trying to bulk add all my Meraki sites to Cisco DNA.  To do this I need the latitude and longitude for each network in my organization.  I have called myself looking but just can't find anything.  Any help would be awesome!!!

2 Replies 2
alemabrahao
Kind of a big deal
Kind of a big deal

GET List the networks in an organization

{{baseUrl}}/organizations/{{organizationId}}/networks

 

Loop over them and get the devices in each network:

GET List the devices in a network

{{baseUrl}}/networks/{{networkId}}/devices

Then loop over the devices and set their locations:

PUT Update the attributes of a device
{{baseUrl}}/networks/{{networkId}}/devices/{{serial}}

 

Parameters for that update call:

 

parametersDescription of the parameter
nameThe name of a device
tagsThe tags of a device
latThe latitude of a device
lngThe longitude of a device
addressThe address of a device
moveMapMarkerWhether or not to set the latitude and longitude of a device based on the new address. Only applies when lat and lng are not specified.

 

Put pauzes in your script so you don't go over the rate limit for the calls:

Note: Call volume is limited to 5 calls per second (per organization)
Edited:
https://developer.cisco.com/meraki/api-v1/#!update-device
I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
rhbirkelund
Kind of a big deal
Kind of a big deal

Try something like this;

#! /usr/bin/env python3

import meraki

def main():
    # Instantiate Meraki Dashboard API object - Assumes APIKEY stored as env var MERAKI_DASHBOARD_API_KEY
    dashboard = meraki.DashboardAPI()

    # Organizations ID
    org_id = ""

    networks  = dashboard.organizations.getOrganizationNetworks(org_id)

    Network_Devices = []
    for network in networks:
        network_devices = dashboard.networks.getNetworkDevices(network['id'])
        Network_Devices.append({
            'id': network['id'],
            'name': network['name'],
            'devices': network_devices
        })

    for network in Network_Devices:
        print("Network",network['name'],"with id",network['id'],"has the following devices")
        for device in network['devices']:
            print("\tDevice",device['serial'],"is located at Lat",device['lat'],"and long",device['lng'])
    

if __name__ == "__main__":
    main()
LinkedIn ::: https://blog.rhbirkelund.dk/

Like what you see? - Give a Kudo ## Did it answer your question? - Mark it as a Solution 🙂

All code examples are provided as is. Responsibility for Code execution lies solely your own.
Get notified when there are additional replies to this discussion.