Meraki#004_Play with API

In this tutorial I will show you how to play with Meraki API to get the Meraki Device status – And you can also use this API to create your own dashboard,Do the auto-configuration.

Node.js/Python are also supported.

Find your API Key

Go to Organization>CONFIGURE>Settings.

In the Dashboard API Access , Please check the “Enable access to Cisco Meraki Dashboard API”.

Click the API access Profie.

Press the Generate new API Key Button to create your API Key.

Your APU Key is shown in a Popup and please Copy and store it in a safe place.This is your only chance to find your API Key. 

API Key is created.

Play it!

Please access this link to test with the Meraki API.

https://developer.cisco.com/meraki/api-v1/#!getting-started

Click the Configuration button.

Please input your API Key to the X-Cisco-Meraki-API-Key Field.

Get Device

Go to EndPoints>API>GENERAL>devices>CONFIGURE>Get Device.

There are very detaily explaination of each request in the API.

Open the Parameter Tab, and enter the Serial Number of your Meraki Device>Press Run to test it.

Response 200 OK is displayed if the request is send and normal response is received.


GET NETWORK

Let’s try one more API Request.
Go to EndPoints>API>GENERAL>devices>CONFIGURE>Get Network.

We can get the Networkid from Get Device Request.

Then input your Networkid>Press Run.

If 401 is displayed, please make sure the correct API Key is entered.

Done and Response 200 OK is returned!


CURL

This time we will use the curl command to test the API.

Installation

Enter this command to install the curl packages.

sudo apt-get install curl

Open the Template Tab.

CurlのTabにExampleがのっています。

Thanks for the API Documents and you can just copy the templates to your terminal.

Copy it.

Test

Paste to your Terminal and do not forget to change the Api Key and Networkid.

Python

Finally I will show how to use python to play with Meraki API.

import requests
serial=’xxxx’
Network_ID=’xxxx’

import os
API_KEY=os.environ.get(‘MERAKI_DASHBOARD_API_KEY’)

url=”https://api.meraki.com/api/v1/devices/{}”.format(serial)
print(url)
payload=None
headers={
    “Content-Type”: “application/json”,
    “Accept”: “application/json”,
    “X-Cisco-Meraki-API-Key”: “{}”.format(API_KEY)
   
}
response = requests.request(‘GET’, url, headers=headers, data = payload)

print(response.text.encode(‘utf8’))

Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする