# Get Workspaces from Power BI API with Python

> I explain how to call the Power BI APIs from Python with a Service Principal to get all the workspaces managed in your tenant. I share also a github gist for a Python script which retrieves all workspace objects, including users, datasets, reports, etc.

- URL: https://data-goblins.com/get-workspaces-power-bi-python
- Author: Kurt Buhler
- Published: 2022-05-07
- Topic: Admin and governance

# USE PYTHON TO GET DATA FROM POWER BI APIs

*…such as the workspaces that a **user** or **service principle** has access to*

---

## IN THIS ARTICLE

![](https://images.data-goblins.blog/2025/12/workspaces-python-output.png)
- **Get Workspaces** from Power BI Admin API using Python

- In the linked Github Gist

  - Get **Artifacts in Workspaces (Datasets, Reports, Dataflows…)**

  - Get **Users with roles in Workspaces**

---

## HOW TO SET IT UP?

I wrote a post about setting up a Service Principal, permissions & settings to get you started, as well as explaining the Authentication. You can [**find that post, here**](https://data-goblins.com/power-bi/power-bi-api-in-python).

---

---

*Code is provided as-is with no guarantees or warranties of any kind. Just something I did quickly in spare time.*

---
