Hello Folks,
I just want to confirm if it is possible to fetch the client name (laptop name) if I have a list of IP addresses in hand.
If yes,
I am trying to retrieve the device names corresponding to the IPs that I have, in order to create a list of IPs to use for different projects. Otherwise, I would need to check each device name one by one corresponding to the IP.
I am running Python code. It was executed with no errors, but it is not giving me the name of the device. However, when I manually check in the client section of the Cisco Meraki dashboard, and search the IP in the clients section, it gives me the device name (Client).
code:
import requests
# Your API key, organization ID, and network ID
API_KEY = 'abcd'
ORG_ID = 'abcd'
NETWORK_ID = 'abcd'
IP_ADDRESS = '0.0.0.0' # Single IP address
# Meraki API endpoint URL for clients
clients_url = f"https://api.meraki.com/api/v1/networks/{NETWORK_ID}/clients"
# Set request headers
headers = {
"X-Cisco-Meraki-API-Key": API_KEY,
"Content-Type": "application/json"
}
# Make GET request to retrieve clients
response = requests.get(clients_url, headers=headers)
# Check rate limit headers
print("Rate Limit Headers:")
for header, value in response.headers.items():
if header.startswith('X-RateLimit'):
print(f"{header}: {value}")
# Check if request was successful
if response.status_code == 200:
clients = response.json()
# Find client with specified IP address
client_info = None
for client in clients:
if client['ip'] == IP_ADDRESS:
client_info = client
break
# Print client information
if client_info:
print("Client Information:")
print(client_info)
else:
print(f"No client found for the specified IP address {IP_ADDRESS}.")
else:
print("Error:", response.status_code, ",", response.text)
Any help will be greatly appreciated.
regards,
Sal