Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hey everyone! I currently have a Python script that makes an API call to my team's workspace to retrieve two things:
1. A list of all reports/dashboards that current exist and are being worked on
2. A sublist of every page within each report/dashboard
My next requirement is to expand this script to retrieve the visual information off of each page - the number of visuals on the page, which type of visuals/elements are they, what data sources are they connected to, how many slicers and buttons are there, where is everything positioned/placed etc. The goal is to have an executable that retrieve and consolidate the information of our workspace in a simple, text-based format so we have all our "metadata" in one place to analyze and keep track of.
Here is my script so far (assuming imports and constants):
def getReportsInGroup(GROUP_ID):
API_URL = f"https://api.powerbi.com/v1.0/myorg/groups/{GROUP_ID}/reports"
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}
response = requests.get(API_URL, headers=headers)
if response.status_code == 200:
print("Retrieved report metadata:")
reports = response.json()['value']
for report in reports:
print(f"{report['name']} | Dataset ID = {report['id']}")
getPagesInReport(report['id'])
else:
print(f"Failed to retrieve metadata. Status code: {response.status_code}")
try:
error_content = response.json()
print(json.dumps(error_content, indent=4))
except requests.exceptions.JSONDecodeError:
print("No JSON response content.")
print(f"Response text: {response.text}")
def getPagesInReport(DATASET_ID):
API_URL = f"https://api.powerbi.com/v1.0/myorg/groups/{GROUP_ID}/reports/{DATASET_ID}/pages"
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}
response = requests.get(API_URL, headers=headers)
if response.status_code == 200:
pages = response.json()['value']
sortedPages = sorted(pages, key=lambda x: x['order'])
for page in sortedPages:
print(f"--> {page['order']}) {page['displayName']}")
else:
print(f"Failed to retrieve metadata. Status code: {response.status_code}")
try:
error_content = response.json()
print(json.dumps(error_content, indent=4))
except requests.exceptions.JSONDecodeError:
print("No JSON response content.")
print(f"Response text: {response.text}")
Is it possible to continue using Python methods to get the information I am looking for? I have looked up some idea and saw that some people had luck with embedding reports and running JS on it to get information on what the user actually gets to see since the API calls themselves would not render the same dashboard. I would like to keep it simple, but understand that that is not always possible! Any guidance, tips, and leads will be appreciated! Thank you!
Solved! Go to Solution.
The console is the standard web browser console (F12/dev tools)
Any particular reason for not using the sempy library?
Semantic link propagation with SemPy - Microsoft Fabric | Microsoft Learn
I was not aware it existed. Thanks for the suggestion. However, I don't see any documentation to get the info on the visuals being shown on a page 😞
sempy.fabric.TOMWrapper class | Microsoft Learn
Also look into the Embedded Analytics Playground, it has sample code for enumerating report pages and visuals.
Thank you Ibendlin! I have been trying to use the Embedded Analytics Playground, but there does not seem to be any console where I can see any output. If I try any event-related code (like opening a Print dialog or Saving the report), there is no issue. But if try something like logging the pages in the report, there is no console that appears to see that output. Is this a common issue?
The console is the standard web browser console (F12/dev tools)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
6 | |
6 | |
3 | |
2 | |
2 |