Update Python script to get *.dynamic-m.com host name address?

mvalpreda
Here to help

Update Python script to get *.dynamic-m.com host name address?

Have the following script I used in the past to grab a little bit of information from the organization. Need to update it to grab the dynamic IP address that Meraki uses. I'm not sure what I'm looking for in the documentation. Can someone point me in the right direction? Thanks!

 

 

import requests
import json

#https://dashboard.meraki.com/api_docs

meraki_organizationID = 'MY ORG ID'
meraki_apikey = '-----'
meraki_apibaseurl = 'https://api.meraki.com/api/v0/organizations/'
#----------------------------------
meraki_apidevicestatusurl = meraki_apibaseurl + meraki_organizationID + '/deviceStatuses'
headers = {'X-Cisco-Meraki-API-Key': meraki_apikey}

url = meraki_apidevicestatusurl
response = requests.get(url,headers=headers)
# improve this to look at response code first
#Response code: 200
#print response.text
json_data = json.loads(response.text)
#print json_data
error = False
for i in json_data:
    try:
        print(i['name'] + ',' + i['status'] + ',' + i['publicIp'] + ',' + i['wan1Ip']  + ',' + i['networkId'] + ',' + i['serial'])
    except:
        #print 'error'
        error = True

 

Guessing it needs to go at the end of the print line at the bottom. Just not sure what to add!

 

2 REPLIES 2
sungod
Building a reputation

By "dynamic IP" do you mean each device's IP address?

 

That would be the lanIp element, see here for the full list of return data...

https://developer.cisco.com/meraki/api-v1/#!get-organization-devices-statuses

 

You could add...

 

+ ',' + i['lanIp']

 

 

Edit, just noticed you are using the v0 API, this is now in sunset, really you should switch to v1.

 

The v0 return values are documented here...

https://developer.cisco.com/meraki/api/#!get-organization-device-statuses

 

RaphaelL
Head in the Cloud

I think you are refering to the DDNS adress ? ( since you left a comment on a different post regarding DDNS ).

 

If so , you need to use the endpoint : 

{0}/devices/{1}/managementInterface
Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.