Meraki Dashboard API Python Library
The Meraki Dashboard API Python library provides all current Meraki Dashboard API calls to interface with the Cisco Meraki cloud-managed platform. It handles error handling, logging, automatic retries for rate limits, and pagination. Generated from the OpenAPI specification, it aims to stay up-to-date with API releases. The library currently requires Python 3.10+ and is actively maintained with frequent updates.
Warnings
- breaking Version 2.0.0 decoupled the library version from the API version, which included changes to operation IDs that were breaking for the library's method calls. This could require updates to existing scripts.
- breaking Version 2.0.1 addressed a substantial issue (severity of #290) in the retry handler and user agent string. Users on version 2.0.0 should upgrade immediately to 2.0.1 or later to avoid potential request failures or incorrect behavior.
- deprecated Versions of the library starting with `0.x.y` (e.g., 0.34) are end-of-life and are not supported or recommended. These legacy versions used a different import pattern (`from meraki import meraki`).
- gotcha Meraki API keys provide authentication to all organizations accessible by the associated Dashboard administrator account. Storing the API key directly in source code is insecure. Also, the Meraki API returns a 404 (Not Found) for a missing or incorrect API key, rather than a 403 (Forbidden), to prevent leaking information about resource existence.
- gotcha Prior to version 2.0.0, the library could encounter a `KeyError` when paginating through API endpoints whose response payloads were JSON objects using the `items/meta` pattern.
Install
-
pip install meraki
Imports
- DashboardAPI
import meraki dashboard = meraki.DashboardAPI()
- AsyncDashboardAPI
import meraki.aio async_dashboard = meraki.aio.AsyncDashboardAPI()
- MerakiSdkClient
import meraki dashboard = meraki.DashboardAPI()
Quickstart
import os
import meraki
API_KEY = os.environ.get('MERAKI_DASHBOARD_API_KEY', 'YOUR_API_KEY_HERE')
if API_KEY == 'YOUR_API_KEY_HERE':
print("Warning: MERAKI_DASHBOARD_API_KEY not set. Using placeholder.")
try:
dashboard = meraki.DashboardAPI(api_key=API_KEY, suppress_logging=True)
organizations = dashboard.organizations.getOrganizations()
if organizations:
print("Successfully connected to Meraki Dashboard.")
print("Organizations found:")
for org in organizations:
print(f" - {org['name']} (ID: {org['id']})")
else:
print("No organizations found or API key is invalid.")
except meraki.exceptions.APIError as e:
print(f"Meraki API Error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")