Meraki provide a sample script in their SDK github to export info on all clients in the org.
https://github.com/meraki/dashboard-api-python/blob/main/examples/aio_org_wide_clients_v1.py
You can use something along these lines for finding unused ports.
dashboard = meraki.DashboardAPI('your_api_key', suppress_logging=True)
devices = dashboard.organizations.getOrganizationDevices('your_org_id', total_pages='all')
for device in devices:
if device['productType'] == 'switch':
port_statuses = dashboard.switch.getDeviceSwitchPortsStatuses(device['serial'], timespan=(31*24*60*60))
for port_status in port_statuses:
port_id = port_status['portId']
total_usage_kb = port_status['usageInKb']['total']
# This shuts the port down
#if total_usage_kb == 0:
# dashboard.switch.updateDeviceSwitchPort(device['serial'], port_id,enabled=False)