Yes, you can automate Meraki's API calls to get the information you need. You'll just need a little code to get the job done. There are many ways and many tools you could use. This example uses Node.js. If you're not familiar with using Node, you may need a little help getting started.
I assume you already have a valid API Key. You will need to install the async and request packages using npm.
You can get a list of organizations that you can access pretty easily. If you don't want to do it manually (Postman is fine), you can use a bit of Node.js code:
var request = require('request');
var credentials=require('./credentials'); // Includes credentials.API_KEY
const options = {
url: 'https://dashboard.meraki.com/api/v0/organizations',
headers: {
"X-Cisco-Meraki-API-Key":credentials.API_KEY,
"Content-Type": 'application/json'
},
};
request.get(options, function(error, response, body) {
if (error) console.error(error);
else {
var orgList = JSON.parse(body);
orgList.forEach(function(item) {
console.log(item.id, item.name);
});
}
});
Now that you have the organization id, you can get the list of networks.
var request = require('request');
var credentials=require('./credentials'); // Includes credentials.API_KEY
const organizationId='ORG_ID_GOES_HERE';
const options = {
url: 'https://api.meraki.com/api/v0/organizations/' + organizationId + '/networks',
headers: {
"X-Cisco-Meraki-API-Key":credentials.API_KEY,
"Content-Type": 'application/json'
},
};
request.get(options, function(error, response, body) {
if (error) console.error(error);
else {
console.log('module.exports = ' + body);
}
});
When you run this code, send the output to a file. For example, "node getNetworks.js > networks.js"
Since the network list is now in a file, we can use it in the next script to accomplish your #3 request.
Getting the device list from each network takes a little more code, but it's not too bad.
var request = require('request');
var async = require('async');
var credentials=require('./credentials'); // Includes credentials.API_KEY
var networks=require('./networks.js');
const urlPattern = 'https://dashboard.meraki.com/api/v0/networks/{networkId}/devices'
var options = {
headers: {
"X-Cisco-Meraki-API-Key":credentials.API_KEY,
"Content-Type": 'application/json'
},
};
var devices = [];
async.eachSeries(networks, getDeviceList, processDeviceList);
function getDeviceList(network, next) {
options.url = urlPattern.replace('{networkId}', network.id);
request.get(options, function(error, response, body) {
if (error) next(error);
else {
devices = devices.concat(JSON.parse(body));
next();
}
});
}
function processDeviceList(err) {
if (err) console.error(err)
else {
console.log('module.exports = ' + JSON.stringify(devices));
}
}
One thing that I haven't addressed in any of this code is Meraki's API request limit. Since these requests are all running in serial, I doubt you'll hit the limit.