Construct a Python script that uses a Cisco SDK given SDK documentation

📘Cisco DevNet Associate (200-901 DEVASC)


This topic is very important for the Cisco DevNet Associate (200-901 DEVASC) exam. You must understand:

  • What an SDK is
  • Why Cisco provides SDKs
  • How to read SDK documentation
  • How to install and use a Cisco SDK in Python
  • How to authenticate
  • How to call API methods using the SDK
  • How to handle responses and errors
  • How to troubleshoot problems

This guide explains everything in simple and easy English, so even beginners can understand.


1. What Is an SDK?

SDK = Software Development Kit

An SDK is a collection of:

  • Pre-written code
  • Libraries
  • Functions
  • Documentation
  • Examples

It helps developers interact with an API more easily.

Instead of manually writing HTTP requests using:

  • requests library
  • URLs
  • Headers
  • JSON formatting

The SDK provides ready-made Python functions that handle this for you.


2. What Is a Cisco SDK?

Cisco provides SDKs for many of its platforms, such as:

  • Cisco Systems
  • Cisco DNA Center
  • Cisco Meraki Dashboard
  • Cisco Webex
  • Cisco Intersight

Each platform may have its own Python SDK.

Example:

  • Cisco DNA Center → dnacentersdk
  • Cisco Meraki → meraki Python library
  • Webex → webexteamssdk

3. Why Use a Cisco SDK Instead of Raw REST APIs?

Without SDK:

  • You manually build HTTP requests
  • You manage authentication tokens
  • You parse JSON manually
  • You handle errors manually

With SDK:

  • Authentication is built-in
  • API endpoints are already mapped to Python methods
  • JSON is automatically converted to Python objects
  • Error handling is simplified

For the exam, you must understand:

SDK = Wrapper around REST API

It still uses REST internally.


4. General Steps to Construct a Python Script Using a Cisco SDK

When the exam gives you SDK documentation, you must know how to:

Step 1 – Install the SDK

Step 2 – Import the library

Step 3 – Authenticate

Step 4 – Call an API method

Step 5 – Handle the response

Step 6 – Handle errors

Let’s break each one down clearly.


5. Step 1 – Install the Cisco SDK

Most Cisco SDKs are installed using pip:

pip install dnacentersdk
pip install meraki
pip install webexteamssdk

You must:

  • Use correct package name
  • Ensure Python 3 is installed
  • Install inside a virtual environment (best practice)

6. Step 2 – Import the SDK

After installation:

from dnacentersdk import DNACenterAPI

or

import meraki

The documentation tells you:

  • What class to import
  • What objects are available

For the exam, always read:

  • “Getting Started”
  • “Authentication”
  • “Example Code” sections

7. Step 3 – Authentication

Authentication is required to access Cisco platforms.

Common methods:

1. Username and Password

2. API Token

3. Bearer Token

4. Environment Variables

Example (DNA Center):

api = DNACenterAPI(
username="admin",
password="Cisco123",
base_url="https://sandboxdnac.cisco.com",
version="2.3.5.3",
verify=False
)

Example (Meraki API Key):

dashboard = meraki.DashboardAPI(api_key="your_api_key")

Important exam knowledge:

  • API keys must be kept secure
  • Do not hardcode credentials in production
  • Use environment variables when possible

Example:

import osapi_key = os.getenv("MERAKI_API_KEY")

8. Step 4 – Calling an API Method Using the SDK

This is the most important exam part.

The SDK converts REST endpoints into Python methods.

For example:

REST API:

GET /network-device

SDK method:

devices = api.devices.get_network_device()

Or in Meraki:

networks = dashboard.organizations.getOrganizationNetworks(org_id)

Notice:

  • The method name usually matches API documentation
  • It is grouped logically
  • You don’t write HTTP GET manually

9. Step 5 – Handling the Response

SDK usually returns:

  • Dictionary
  • List
  • Python object

Example:

for device in devices["response"]:
print(device["hostname"])

You must understand:

  • How to access dictionary keys
  • How to loop through lists
  • How to print selected fields

Very common exam task:

Extract specific information from the response.


10. Step 6 – Error Handling

Even with SDK, errors happen.

Common problems:

  • Invalid credentials
  • Expired token
  • Network issue
  • Wrong parameter
  • Permission denied

Basic error handling:

try:
devices = api.devices.get_network_device()
print(devices)
except Exception as e:
print("Error:", e)

You may also see SDK-specific exceptions.

For example:

from dnacentersdk.exceptions import ApiError

11. Reading SDK Documentation (Very Important for Exam)

When the exam gives SDK documentation, you must identify:

1. Required Parameters

Example:

  • organizationId
  • networkId
  • deviceId

2. Optional Parameters

3. Return Type

4. Example Usage

You must know how to:

  • Match documentation to Python syntax
  • Identify correct method name
  • Pass parameters correctly

Example from documentation:

getDevice(deviceId)

Correct Python usage:

device = api.devices.get_device(deviceId="12345")

12. Understanding Method Naming Structure

Most Cisco SDKs follow this pattern:

api.<resource>.<action>()

Example:

api.devices.get_network_device()
api.networks.get_network()
api.users.get_users()

Where:

  • resource = devices, networks, users
  • action = get, create, update, delete

This matches REST:

RESTSDK
GETget_
POSTcreate_
PUTupdate_
DELETEdelete_

You must recognize this mapping.


13. Pagination in SDK

Some APIs return large data sets.

SDK may support:

  • Automatic pagination
  • Manual pagination

Example parameter:

limit=50
offset=0

You must know:

  • How to request next page
  • How to loop through pages

14. Creating, Updating, and Deleting Resources

Creating resource:

api.networks.create_network(name="TestNetwork")

Updating resource:

api.networks.update_network(networkId="123", name="NewName")

Deleting resource:

api.networks.delete_network(networkId="123")

Understand:

  • Required parameters
  • Payload data
  • Response verification

15. Best Practices for Exam

You must remember:

✔ Always read SDK documentation carefully

✔ Identify required parameters

✔ Understand authentication method

✔ Match REST to SDK methods

✔ Handle responses correctly

✔ Use try/except for errors


16. Sample Complete Script (Generic Example)

from dnacentersdk import DNACenterAPI
import osapi = DNACenterAPI(
username=os.getenv("DNA_USER"),
password=os.getenv("DNA_PASS"),
base_url="https://sandboxdnac.cisco.com",
verify=False
)try:
devices = api.devices.get_network_device() for device in devices["response"]:
print("Hostname:", device["hostname"])
print("IP:", device["managementIpAddress"])
print("------")except Exception as error:
print("An error occurred:", error)

This script:

  • Imports SDK
  • Authenticates
  • Calls API
  • Parses response
  • Handles error

This is exactly what the exam expects you to understand.


17. Common Exam Mistakes

❌ Forgetting authentication
❌ Using wrong parameter name
❌ Mixing REST syntax with SDK syntax
❌ Not reading documentation carefully
❌ Forgetting to install SDK
❌ Not handling exceptions


18. Key Concepts to Remember for 200-901 DEVASC

  • SDK simplifies REST API usage
  • SDK is language-specific (Python SDK for Python)
  • Authentication is mandatory
  • Methods map to REST operations
  • Documentation tells you everything
  • Python data types (dict, list) are important
  • Error handling is important

Final Summary

To pass this section of the Cisco DevNet Associate (200-901 DEVASC) exam, you must be able to:

  1. Understand what a Cisco SDK is
  2. Install it using pip
  3. Import it correctly
  4. Authenticate securely
  5. Call API methods using SDK syntax
  6. Parse and display responses
  7. Handle errors properly
  8. Read and interpret SDK documentation

If you understand these clearly, you will confidently answer any SDK-related exam question.

Buy Me a Coffee