Return switchports matching a specific tag in v1?

Here to help

Return switchports matching a specific tag in v1?

I'm trying to monitor a specific set of switchports across our network. All of them have the same tag (cameras), but are spread across ~300 switches and ~10,000 switchports. Of those 10,000 ports, I'm only interested in the 85 that match the tag.


In the old v0 API, I'm finding plenty of examples that would have worked, and ChatGPT is happy to write me a script that should have solved my problem in about 5 seconds. But it seems that, in the new v1 API, I can only query ports by switch, not by tag, so I'll need to return every switch, then every port, then filter out just the ports I need. Then, querying those ports to get their usage within a time period seems like an additional layer of issues in v1.


Is there some mechanism to do this that I should be seeing? If it used to be as simple as "{network_id}/switchPorts/usage?timespan={six_hours_ago_unix}-...}", I'm hoping that they gave us a new method when they took the old method away.

Meraki Employee
Meraki Employee

How about the org-wide switch port API call!get-organization-switch-ports-by-switch


and filter the results by tag, which is returned?

Kind of a big deal

I haven't tested this in action, but something I suppose it's something along the lines of this. Feel free to use it as inspiration.

#! /usr/bin/env python3

import meraki
from datetime import datetime

def main():
    dashboard = meraki.DashboardAPI()

    organization_id = ''
    TargetTag = ''

    AllSwitchportsBySwitch = dashboard.switch.getOrganizationSwitchPortsBySwitch(
        organization_id, total_pages='all'

    Target = []
    for switch in AllSwitchportsBySwitch:
        TargetPortIds = []
        for port in switch['ports']:
            if TargetTag in port['tags']:
                "serial": switch['serial'],
                "name": switch['name'],
                "portId": TargetPortIds,

    for switch in Target:
        SwitchPorts = dashboard.switch.getDeviceSwitchPortsStatuses(
        for port in SwitchPorts:
            if port['portId'] in switch['portId']:

if __name__ == "__main__":
    StartTime =
    print("\nTime to execute:",
LinkedIn :::

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

All code is provided as is. Responsibility for Code execution is solely your own.
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.