This is a snippit of a script I have used that does some of what you are interested in. It finds ports that have no usage for 30 days.
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']
If total_usage_kb == 0, you could consider the port unused. You could also use a small threshold for ports that are actually up, but not really in use.
You could also run this every day (with an interval of 24 hours) and record the usage for the last 24 hours. Then look at the change in usage from the prior day to determine if the port has started/stopped being used.