Generate Camera Snapshots with the Cisco Meraki Snapshot API in Python

Remotely take camera snapshots with your Meraki MV camera.

Elise Landman
3 min readMay 7, 2021
Image by author.

Cisco Meraki is characterized by making the setup, provisioning and overall management of your network remarkably easy. In addition to its user-friendly and intuitive cloud management dashboard, Meraki provides a set of APIs so that you can make use of additional solutions and pre-built integrations, but also build your own features and automation workflows.

Apart from classic network management APIs, Meraki provides the camera Snapshot API which enables users to remotely take snapshots with the cameras in their network.

In this article I will demonstrate how to use the Meraki Snapshot API with Python.

Image from https://developer.cisco.com/meraki/api-v1/.

Workflow

To obtain a snapshot from our Meraki MV camera we need the serial number of the respective camera. To obtain the serial number, we need to make an API call to obtain device information of the cameras in our organization (or network, depending on your needs). To make this API request, we need to specify our organization ID, which we will also obtain by making an API call.

Nevertheless, before making API calls we need to enable our Meraki Dashboard for API calls and obtain our API token. To do this, log in to your Meraki Dashboard and go to Organization > Configure > Settings > “Dashboard API access” and check the respective checkmark.

Image from Cisco Meraki Cloud Dashboard.

After enabling, we need to copy our API token and save it as a Python variable.

meraki_api_key = "#######################"

1 | Get Organization ID

In our first request we need to obtain our organization ID.

We make a simple API call with the Python requests library, and we save the respective organization ID in a separate variable. Depending on how many organizations you have, you need to choose which one contains the Meraki cameras you would like to use. In the code snippet above, it extracts result 0, therefore the first organization ID returned by our API response.

2 | Get Organization Devices

Now that we have our organization ID we can obtain a list of all the devices that we have in this organization. After obtaining this list, we will filter the list by cameras and extract their serial numbers into a separate Python list.

Our serialNumber list will look approximately as following, depending on how many cameras you have in your organization:

serialNumbers = ["ABCD-DEFG-HIJK", "LMNO-PQRS-TUVW", ...]

Tip: if you have a lot of devices in your organization, it may be more efficient to extract the camera serial numbers from a specific network instead of from your whole organization. In this case you would need to make an API call to obtain the network ID and then make an API call to obtain the list of devices in this network. Afterwards you would proceed identically to extract the serial numbers.

3 | Generate Camera Snapshot

Now that we have extracted the serial numbers of our cameras we can make the API call to take a camera snapshot.

In the code snippet below, we take a snapshot with the first camera in our list of serial numbers.

A successful response will generate a URL with which you can access your snapshot. This URL will expire after some time, so we can save our snapshot on our local machine using the following code:

Using Meraki APIs really is no rocket science! 🚀

You can read more on Meraki APIs in the official documentation and feel free to ping me or comment below if you have any questions.

--

--

Elise Landman

Data Analytics MSc @UCD and Customer Engineer @Google Cloud — passionate about data science & programmability with 🐍