MerakiApiUtilities/getMerakiNetworks.py
Tanner van Teeffelen 8f4bf8dcd4 Initial commit.
2026-05-07 09:40:00 -04:00

32 lines
No EOL
729 B
Python

import requests, os
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("API_KEY")
HEADERS = {
"X-Cisco-Meraki-API-Key": API_KEY,
"Content-Type": "application/json"
}
# Step 1: get organizations
orgs = requests.get(
"https://api.meraki.com/api/v1/organizations",
headers=HEADERS
).json()
for org in orgs:
print("Org:", org["name"], org["id"])
# Step 2: get networks in each org
nets = requests.get(
f"https://api.meraki.com/api/v1/organizations/{org['id']}/networks",
headers=HEADERS
).json()
for net in nets:
try:
print(" Network:", net["name"], net["id"])
except Exception as e:
print(f"Something went wrong: {e}")