07-16-2025 08:51 AM
Hi,
I am trying to get a device list using the XIQ API which works fine but is only running it against my Home network.
I am using the below to get device list:
https://api.extremecloudiq.com/devices?page=1
What I require though is to be able to run this against the External sites that appear on this API:
https://api.extremecloudiq.com/account/external
I tried to find the VIQ but again only shows my Home account and not the external ones.
Any advice on this please ?
Monday
Here is example for Python . First, you will need to get a list of accounts that have been granted external access. The /account/external endpoint will be used for this. https://api.extremecloudiq.com/swagger-ui/index.html#/Account/listExternalAccounts
Create a new url variable and concatenate the baseurl with /account/external
url = baseurl + '/account/external’
This will override the url variable with the new URL. This is fine for our purpose. Next, we will build a new GET request and assign the response object to the response variable. This also overrides the response variable.
response = requests.get(url,headers=headers)
Next, print the JSON data from the response.
print(response.json()) .
With the ID of the VIQ you want to switch to, you can use the /account/:switch?id={{viq_id}} endpoint. Using the same process, we will create the URL, perform the POST call, and then update the header authorization with the new token.
url = baseurl + ‘/account/:switch?id={{viq_id}}
replace {{viq_id}} with the id returned for the VIQ
response = requests.post(url,headers=headers)
data = response.json()
headers[‘Authorization’] = ‘Bearer ‘ + data[‘access_token’] . Here is a code example :
import requests import json baseurl = "https://api.extremecloudiq.com" headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} body = { "username": "your_user_name@example.com", "password": "your_password" } # Login URL url = baseurl + '/login' # Login Request response = requests.post(url, headers=headers, json=body) # Check if login was successful if response.status_code != 200: print(f"Error getting access token - HTTP Status Code: {str(response.status_code)}") exit() # Extract token from response data = response.json() token = data.get('access_token') if not token: print("Error: No access token found in the response") exit() # Update headers with the Authorization token headers['Authorization'] = 'Bearer ' + token # GET request to /account/external url = baseurl + '/account/external' response = requests.get(url, headers=headers) if response.status_code == 200: external_data = response.json() print("External Account Data:") print(json.dumps(external_data, indent=4)) else: print(f"Error fetching external account data - HTTP Status Code: {response.status_code}") # GET request to /account/:switch?id={VIQ_ID} url = f"{baseurl}/account/:switch?id=398641" #Replace VIQ ID as needed response = requests.post(url, headers=headers) if response.status_code == 200: switch_data = response.json() print("Switch Data:") print(json.dumps(switch_data, indent=4)) else: print(f"Error fetching switch data - HTTP Status Code: {response.status_code}") headers['Authorization'] = 'Bearer ' + data['access_token'] # Print headers for verification print("Headers with Authorization token:") print(headers)