Can Power BI Make API Calls?
Yes, Power BI can absolutely make API calls, and it's one of its most powerful and flexible features for getting live data. By connecting directly to web APIs, you can pull information from almost any modern SaaS application or web service, bypassing the need for manual CSV downloads. This article will walk you through exactly how to connect Power BI to an API, from your first simple request to handling more complex scenarios like authentication and pagination.
Why Connect Power BI to an API?
Before jumping into the "how," let's quickly cover the "why." Manually exporting data from various platforms is time-consuming and prone to errors. By connecting directly to an API (Application Programming Interface), you create a live, automated pipeline for your data.
- Real-Time Data: Your reports can be updated automatically by simply hitting refresh. No more downloading the same file every Monday morning.
- Universal Connectivity: Most modern apps - from marketing and sales tools to project management software - have an API. This means if there isn't a pre-built connector for a service you use, you can probably still get the data into Power BI.
- Access to All Data: Sometimes, the standard "export to CSV" function only gives you a fraction of the available data fields. APIs often provide access to a much richer set of information.
- Reduced Manual Work: Automating data retrieval frees up your time to focus on what matters: finding insights and building meaningful visualizations.
The Tool for the Job: An Intro to Power Query
The magic behind Power BI's data connection capabilities is the Power Query Editor. This is the data transformation engine built into Power BI (and Excel) that lets you connect to hundreds of sources, clean the data, and shape it for analysis.
When you're making an API call, you aren't writing code inside the Power BI dashboard itself. Instead, you'll be using Power Query’s user-friendly interface - and occasionally its underlying formula language, called M - to fetch and prepare your data before it even loads into your Power BI report.
Step-by-Step Guide: Making Your First API Call
Let's start with a simple example using a free public API called JSONPlaceholder. It provides sample data without needing any authentication, making it perfect for a first attempt.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
1. Select "From Web" as Your Data Source
In the Power BI Desktop home ribbon, click on Get Data and select Web. You can find it under the "Common" or "Other" categories.
2. Enter the API URL
A dialog box will appear asking for a URL. We're going to get a list of sample "to-dos" from the JSONPlaceholder API. Enter the following URL and click OK:
https://jsonplaceholder.typicode.com/todosPower BI will now attempt to connect to that address. Because this is a public API, the "Access anonymously" option is fine. Then press "Connect" and the Power BI Query editor automatically opens, showing the data Power BI received from your API call.
3. Transform the JSON Response into a Table
Your API call returns the data in a web-native format called JSON (JavaScript Object Notation). It looks like Power Query has imported it as a long list of Records. This isn’t quite a usable table yet, but we're just a few clicks away.
- First, we need to convert this list into a table. On the Transform tab in the ribbon at the top of the Query Editor, click the Into Table button. A small options dialog will pop-up. Simply click "OK," and you'll see a single column with the word
[Record]in each row. - Now we need to expand these records. Click the expand icon (two arrows pointing in opposite directions) in the column header.
- A dropdown will appear showing all the fields inside the records (like
userId,id,title, andcompleted). Ensure all fields are selected and uncheck "Use original column name as prefix." - Click OK.
Voila! You now have a clean, familiar table of data pulled directly from a live web API. Each key from the JSON data is now a column in your table.
4. Load Your Data into Power BI
With your data properly formatted, click the Close & Apply button in the top-left corner of the Power Query Editor. This loads the data into your Power BI data model, and you can start building charts and visuals just like you would with any other data source.
Handling Authentication in Power BI
The first example was easy because the API was public. Most APIs you’ll want to use for your business require some form of authentication to prove you have permission to access the data. There are several ways to handle this, but the most common for simple APIs is using an API key.
Using an API Key in a Header
An API key is a long string of characters that you include with your request. It's often sent in the request "header" - a piece of metadata that goes along with your API call.
You can't add headers using the basic Web connector, so you'll need to use the Advanced Editor. Let's modify our original query.
- In the Power Query Editor, go to the Home tab and click on the Advanced Editor. This will show you the M code that Power Query generated behind the scenes.
- We're going to use the
Web.Contentsfunction, which gives us more control. Let's pretend our API requires a key in a header calledx-api-key. The M code would look like this:
let
Source = Web.Contents("https://jsonplaceholder.typicode.com/todos",
[
Headers=[#"x-api-key"="YOUR_API_KEY_GOES_HERE"]
]),
Json = Json.Document(Source),
#"Converted to Table" = Table.FromList(Json, Splitter.SplitByNothing(), null, null, ExtraValues.Error)
in
#"Converted to Table"You can see we've wrapped our URL in Web.Contents and added an optional [Headers] record. Just replace "YOUR_API_KEY_GOES_HERE" with your actual key. This is a common pattern for many SaaS tools.
Security Tip: Be careful with how you store and share Power BI files that contain credentials like API keys. Consider using parameters to manage keys so you can update them easily without digging through M code.
What About OAuth 2.0?
For more complex services like Salesforce, QuickBooks, or Google Analytics, another authentication method called OAuth 2.0 is used. This is the process where a popup asks you to sign into your account and grant permission for an app (in this case, Power BI) to access your data.
Fortunately, you rarely have to handle this yourself. For major platforms, Power BI has pre-built connectors that manage the OAuth 2.0 flow for you. When you select the "Google Analytics" or "Salesforce" connector, Power BI will prompt you to sign in, handling the authentication securely behind the scenes.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Advanced Topic: Dealing with Paged Data
Another common hurdle is pagination. When an API has a lot of data to return, it won't send it all at once. Instead, it "pages" the results, sending back maybe 100 items at a time and providing a link or an indicator to request the next page.
Handling this in Power Query requires a more advanced approach, typically by creating a custom function.
The basic logic is:
- Create a Function: Build a Power Query function that takes a page number as an input.
- Make the API Call: Inside the function, construct the API URL with the correct page number (e.g.,
https://api.example.com/data?page=1). - Retrieve a List of Pages: Determine how many pages you need to fetch. You might make an initial call that tells you the total number of records, or you might have to create a loop that keeps fetching pages until it gets an empty response.
- Invoke the Function: Use the list of page numbers to call your function for each page, generating a list of tables (one table for each page's data).
- Combine Results: Finally, combine all the tables into one large table.
While the full process is beyond the scope of this single article, know that Power Query is fully equipped to handle it. Searching for "Power BI API pagination" will yield many detailed guides on this very topic.
Tips for API Success in Power BI
- Read the Documentation: Always start by reading an API's documentation. It will tell you the correct URLs to use, what parameters are available, how authentication works, and how to handle pagination. It's the instruction manual for your data source.
- Start Small: Begin with a simple endpoint that doesn't require complex parameters, just to make sure you can get a successful connection.
- Understand Rate Limits: Most APIs limit how many requests you can make in a given time period (e.g., 100 requests per minute). Be mindful of this when designing refresh schedules and pagination logic to avoid being blocked.
- Use Parameters: For things that might change, like base URLs or API keys, use Power Query parameters. This makes your reports more maintainable and easier to update when you deploy them from a test to a production environment.
Final Thoughts
Pulling data directly from APIs is an intermediate skill that totally transforms what you can do with Power BI. Using Power Query, you can connect to thousands of online services, automate data pipelines, and keep your dashboards updated with near real-time information. It all starts with the humble Get Data > From Web button.
While a powerful skill to have, learning Power Query's M language and navigating complex API logic isn't always something you have time for. We built Graphed to simplify this entire process. We offer one-click integrations for dozens of marketing and sales platforms, handling all the tough parts like authentication and pagination automatically. Instead of writing functions to fetch your data, you can simply ask questions in plain English to build real-time dashboards in seconds.
Related Articles
Facebook Ads for Coaches: The Complete 2026 Strategy Guide
Learn how coaches use Facebook ads to generate premium clients in 2026. Discover the proven funnel strategy, creative formulas, and budget guidelines that work.
Facebook Ads for Pool Cleaners: The Complete 2026 Strategy Guide
Learn how to use Facebook Ads for pool cleaning businesses in 2026. Complete strategy guide covering targeting, ad creative, budgeting, and lead generation.
Facebook Ads for Insurance Agents: The Complete 2026 Strategy Guide
Learn how to use Facebook ads to generate quality leads for your insurance agency in 2026. This comprehensive guide covers targeting, creative strategies, and compliance rules.