PHPackages                             interworks/laravel-powerbi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. interworks/laravel-powerbi

ActiveLibrary[API Development](/categories/api)

interworks/laravel-powerbi
==========================

A Laravel PowerBI REST API package

0.1.1(3w ago)1801↓20.5%1[1 issues](https://github.com/InterWorks/laravel-powerbi/issues)[8 PRs](https://github.com/InterWorks/laravel-powerbi/pulls)MITPHPPHP ^8.2CI passing

Since Jan 8Pushed 3w agoCompare

[ Source](https://github.com/InterWorks/laravel-powerbi)[ Packagist](https://packagist.org/packages/interworks/laravel-powerbi)[ Docs](https://github.com/interworks/laravel-powerbi)[ GitHub Sponsors](https://github.com/InterWorks)[ RSS](/packages/interworks-laravel-powerbi/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (5)Dependencies (51)Versions (14)Used By (0)

Laravel Power BI
================

[](#laravel-power-bi)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b88473fd2d42d77b5112c0a184dd77f9b18062c16ab96116ea0151d4f1cb26f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e746572776f726b732f6c61726176656c2d706f77657262692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/interworks/laravel-powerbi)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8cf582a44d9ed9a427cc81c55a64fbcc9c3d2681bf5a22b0299b634b550211f6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696e746572776f726b732f6c61726176656c2d706f77657262692f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/interworks/laravel-powerbi/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/e45af41e46aebf3855da8fbb7dfe4046a603b645e71203814d162b04f3065f6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f696e746572776f726b732f6c61726176656c2d706f77657262692f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/interworks/laravel-powerbi/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/de73635a7a8001c9dcca5c2074f0ac5f458fd2c87379b4e6b544cde131e96db3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e746572776f726b732f6c61726176656c2d706f77657262692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/interworks/laravel-powerbi)

A comprehensive Laravel package for interacting with the Microsoft Power BI REST API. Built on [Saloon v4](https://docs.saloon.dev/) with type-safe responses, automatic caching, and multiple OAuth2 authentication flows.

Features
--------

[](#features)

- **Multiple Authentication Flows**: Service Principal, Admin Service Principal, and Azure User (authorization code)
- **Type-Safe DTOs**: Immutable response objects with full IDE autocomplete
- **Automatic Caching**: Configurable response caching via Saloon's cache plugin
- **Account Type Restrictions**: Automatic enforcement of API access restrictions
- **Pagination Support**: Automatic handling of continuation tokens
- **Comprehensive API Coverage**: Groups, Reports, Dashboards, Embed Tokens, and Admin endpoints

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 9.x, 10.x, 11.x, or 12.x
- Microsoft Power BI Pro or Premium account
- Azure AD application with Power BI API permissions

Installation
------------

[](#installation)

```
composer require interworks/laravel-powerbi
```

Publish the configuration file:

```
php artisan vendor:publish --tag="laravel-powerbi-config"
```

Add your Power BI credentials to your `.env` file:

```
# Azure AD Configuration
POWER_BI_TENANT=your-tenant-id

# Cloud Environment (Optional)
# One of: commercial (default), gcc, gcc_high, dod
POWER_BI_CLOUD_ENVIRONMENT=commercial

# Service Principal (Client Credentials)
POWER_BI_CLIENT_ID=your-client-id
POWER_BI_CLIENT_SECRET=your-client-secret

# Admin Service Principal (Optional)
POWER_BI_ADMIN_CLIENT_ID=your-admin-client-id
POWER_BI_ADMIN_CLIENT_SECRET=your-admin-client-secret

# Azure User OAuth Redirect (Optional)
POWER_BI_REDIRECT_URI=https://your-app.com/auth/powerbi/callback

# Caching Configuration
POWER_BI_CACHE_ENABLED=true
POWER_BI_CACHE_EXPIRY_SECONDS=3600
```

### US Government Sovereign Clouds (GCC, GCC High, DoD)

[](#us-government-sovereign-clouds-gcc-gcc-high-dod)

Power BI tenants on Microsoft US Government licenses use different REST API and authentication endpoints than the commercial cloud. Set `POWER_BI_CLOUD_ENVIRONMENT` (or pass `cloudEnvironment`to any factory method / connector) to route requests to the correct endpoints:

EnvironmentPower BI API baseEntra authorityResource URL`commercial``api.powerbi.com``login.microsoftonline.com``analysis.windows.net/powerbi/api``gcc``api.powerbigov.us``login.microsoftonline.com``analysis.usgovcloudapi.net/powerbi/api``gcc_high``api.high.powerbigov.us``login.microsoftonline.us``high.analysis.usgovcloudapi.net/powerbi/api``dod``api.mil.powerbigov.us``login.microsoftonline.us``mil.analysis.usgovcloudapi.net/powerbi/api`> **GCC authority:** GCC (moderate) identities live in commercial Microsoft Entra, so `gcc`authenticates against `login.microsoftonline.com` (same as commercial) while still using the `powerbigov.us` API host and `usgovcloudapi.net` resource. Only GCC High and DoD use the Azure Government authority `login.microsoftonline.us`.

```
// Explicit per-connector override
$connector = PowerBI::servicePrincipal(
    tenant: 'your-tenant-id',
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
    cloudEnvironment: 'gcc'
);
```

A missing or empty value defaults to `commercial`. Any other unrecognized value (e.g. a typo like `gcc-high`) throws an `InvalidArgumentException` when the connector is created, so a sovereign-cloud tenant can never be silently routed to the commercial endpoints.

> **Note:** When using the Azure User flow with explicit OAuth scopes, make sure your scope strings reference the resource URL for your cloud environment (see the table above) rather than the commercial `analysis.windows.net/powerbi/api` resource.

Quick Start
-----------

[](#quick-start)

```
use InterWorks\PowerBI\Facades\PowerBI;

// Authenticate
$token = PowerBI::getAccessToken();
PowerBI::authenticate($token);

// Get groups and reports
$groups = PowerBI::getGroups();
$reports = PowerBI::getReportsInGroup('group-id');
$report = PowerBI::getReportInGroup('group-id', 'report-id');

// Generate embed token
use InterWorks\PowerBI\Requests\EmbedToken\ReportsGenerateTokenInGroup;

$embedToken = PowerBI::send(new ReportsGenerateTokenInGroup(
    groupId: 'group-id',
    reportId: 'report-id',
    accessLevel: 'View'
));
```

Authentication
--------------

[](#authentication)

The package supports three authentication flows:

### Service Principal (Client Credentials)

[](#service-principal-client-credentials)

Best for backend automation and server-to-server communication.

```
$token = PowerBI::getAccessToken();
PowerBI::authenticate($token);
```

**Restriction**: Cannot access individual resource endpoints (`/reports/{id}`). Use group-scoped endpoints.

### Admin Service Principal

[](#admin-service-principal)

For tenant-wide administration with elevated permissions.

```
$adminConnector = PowerBI::adminServicePrincipal();
PowerBI::setConnector($adminConnector);
```

### Azure User (Authorization Code)

[](#azure-user-authorization-code)

For user-delegated permissions with browser-based consent.

```
$connector = PowerBI::azureUser(redirectUri: 'https://your-app.com/callback');
$authUrl = $connector->getAuthorizationUrl();
// Redirect user, then exchange code for token
```

Available Endpoints
-------------------

[](#available-endpoints)

The package provides request classes for Power BI API endpoints:

**Groups**: [`GetGroups`](src/Requests/Groups/GetGroups.php), [`GetGroupsAsAdmin`](src/Requests/Admin/Groups/GetGroupsAsAdmin.php)

**Reports**: [`GetReportsInGroup`](src/Requests/Reports/GetReportsInGroup.php), [`GetReportInGroup`](src/Requests/Reports/GetReportInGroup.php), [`GetReport`](src/Requests/Reports/GetReport.php)

**Dashboards**: [`GetDashboardsInGroup`](src/Requests/Dashboards/GetDashboardsInGroup.php), [`GetDashboardInGroup`](src/Requests/Dashboards/GetDashboardInGroup.php)

**Embed Tokens**: [`ReportsGenerateTokenInGroup`](src/Requests/EmbedToken/ReportsGenerateTokenInGroup.php), [`DashboardsGenerateTokenInGroup`](src/Requests/EmbedToken/DashboardsGenerateTokenInGroup.php)

**Admin**: [`GetUserArtifactAccessAsAdmin`](src/Requests/Admin/Users/GetUserArtifactAccessAsAdmin.php)

Browse all available requests in [`src/Requests`](src/Requests).

Response DTOs
-------------

[](#response-dtos)

All responses are transformed into type-safe DTOs with readonly properties:

**Collections**: [`Groups`](src/DTO/Groups.php), [`Reports`](src/DTO/Reports.php), [`Dashboards`](src/DTO/Dashboards.php), [`ArtifactAccessResponse`](src/DTO/ArtifactAccessResponse.php)

**Resources**: [`Group`](src/DTO/Group.php), [`Report`](src/DTO/Report.php), [`Dashboard`](src/DTO/Dashboard.php), [`EmbedToken`](src/DTO/EmbedToken.php), [`ArtifactAccessEntry`](src/DTO/ArtifactAccessEntry.php)

```
$groups = PowerBI::getGroups();

// Laravel Collections with full IDE support
$groups->groups->each(function ($group) {
    echo $group->name; // Fully typed properties
});
```

Caching
-------

[](#caching)

Responses are automatically cached using Laravel's cache system:

```
POWER_BI_CACHE_ENABLED=true
POWER_BI_CACHE_EXPIRY_SECONDS=3600
```

Check cache status:

```
if ($groups->response()->isCached()) {
    // Response served from cache
}
```

Account Type Restrictions
-------------------------

[](#account-type-restrictions)

Power BI API enforces different access levels by authentication type:

Endpoint TypeService PrincipalAdmin SPAzure UserGroup-scoped (`/groups/{id}/reports`)✅✅✅Individual (`/reports/{id}`)❌✅✅Admin (`/admin/*`)❌✅❌Restrictions are enforced automatically with clear exceptions.

Troubleshooting
---------------

[](#troubleshooting)

**Authentication failures**: Verify Azure AD credentials and Power BI API permissions in your app registration.

**Account type restrictions**: Service Principal cannot access individual resource endpoints - use group-scoped endpoints or switch to Azure User.

**Admin endpoint 401s**: Ensure Service Principal has Power BI Administrator role assigned.

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for release history.

Security
--------

[](#security)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [mrkbingham](https://github.com/mrkbingham)
- [All Contributors](../../contributors)

Built with [Saloon v4](https://docs.saloon.dev/).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance74

Regular maintenance activity

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~30 days

Recently: every ~37 days

Total

6

Last Release

26d ago

PHP version history (2 changes)0.0.1PHP ^8.1

0.1.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16199260?v=4)[Justin Lyons](/maintainers/jplcodes)[@jplcodes](https://github.com/jplcodes)

![](https://www.gravatar.com/avatar/513f09ff1dec66574186276e05928314db7743e75da3e6ea399b01ffa1718653?d=identicon)[Mrkbingham](/maintainers/Mrkbingham)

---

Top Contributors

[![Mrkbingham](https://avatars.githubusercontent.com/u/4382816?v=4)](https://github.com/Mrkbingham "Mrkbingham (73 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

liblaravelInterWorkslaravel-powerbi

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/interworks-laravel-powerbi/health.svg)

```
[![Health](https://phpackages.com/badges/interworks-laravel-powerbi/health.svg)](https://phpackages.com/packages/interworks-laravel-powerbi)
```

###  Alternatives

[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1123.7k](/packages/codebar-ag-laravel-docuware)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M102](/packages/dedoc-scramble)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816334.1k3](/packages/defstudio-telegraph)[codebar-ag/laravel-zammad

Zammad integration with Laravel

107.1k](/packages/codebar-ag-laravel-zammad)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

209.6k](/packages/njoguamos-laravel-plausible)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
