Power Query for QuickBooks Desktop
Power Query, built into Excel and Power BI, can read the Desktop Books API directly. Paste the query the file page generates, choose Basic when Excel asks how to connect, paste your API key as the user name and leave the password empty. Excel keeps the key in its own credential store, so the workbook never contains it, and every refresh pulls all pages.
Get the query
Each company file's page has an Excel (Power Query) box with the query for that file, ready to copy. You can also fetch it from the API for any resource or report:
curl -u "dbk_your_key:" \
"https://desktop-app.greatwork.company/v1/files/file_8f2c41/power-query/invoices?status=open" -o invoices.pq
The name can be any resource (customers, bills, invoices...) or report (ar-aging, profit-and-loss...), and filters you add, such as status=open, are written into the query. Add rows=lines for one row per line item.
Steps in Excel
These are the menu names in Excel for Microsoft 365 on Windows.
- Data > Get Data > From Other Sources > Blank Query. The Power Query Editor opens.
- Home > Advanced Editor. Select everything in the box, paste the query and click Done.
- Excel asks how to connect to
https://desktop-app.greatwork.company. Click Edit Credentials, choose Basic, paste your API key into User name, leave Password empty, and pickhttps://desktop-app.greatwork.companyas the level to apply it to. Click Connect. - Check the preview, then Home > Close & Load. The rows land in a table on a new sheet.
Use a key for one company file, labeled after the workbook ("Client A aging workbook"). If the workbook ever leaves your hands, revoking that one key on the API keys page cuts it off without touching anything else.
The query, line by line
This is the query the file page generates for open invoices:
// Desktop Books: Invoices from "Acme Construction"
// In Excel: Data > Get Data > From Other Sources > Blank Query, then Advanced Editor. Paste this and click Done.
// The first refresh asks how to connect: choose Basic, paste your API key as the User name, leave Password empty.
let
Path = "v1/files/file_8f2c41/invoices",
Options = [flat = "1", limit = "500", status = "open"],
GetPage = (cursor as nullable text) as record =>
let
Query = if cursor = null then Options else Options & [cursor = cursor],
Body = Json.Document(Web.Contents("https://desktop-app.greatwork.company", [RelativePath = Path, Query = Query, ManualStatusHandling = {400, 404, 409, 429, 500, 503}])),
Checked = if Record.FieldOrDefault(Body, "error", null) <> null then error Error.Record("Desktop Books", Record.FieldOrDefault(Record.Field(Body, "error"), "message", "The request didn't work."), Record.FieldOrDefault(Record.Field(Body, "error"), "hint", "")) else if Record.FieldOrDefault(Body, "status", "") = "queued" then error Error.Record("Desktop Books", Record.FieldOrDefault(Body, "message", "This company file answers at the next Web Connector check-in. Refresh again after that.")) else Body
in
Checked,
Pages = List.Generate(() => GetPage(null), each _ <> null, each if _[next_cursor] = null then null else GetPage(_[next_cursor]), each _[data]),
Rows = List.Combine(Pages),
Columns = {"id", "edit_sequence", "created_at", "modified_at", "number", "date", "memo", "currency", "exchange_rate", "customer_id", "customer_name", "due_date", "subtotal", "tax", "total", "applied", "balance", "is_paid", "terms_id", "terms_name", "class_id", "class_name", "status", "days_overdue", "line_count"},
Table = if List.IsEmpty(Rows) then #table(Columns, {}) else Table.FromRecords(Rows, Columns, MissingField.UseNull),
Typed = Table.TransformColumnTypes(Table, {{"id", type text}, {"edit_sequence", type text}, {"created_at", type datetimezone}, {"modified_at", type datetimezone}, {"number", type text}, {"date", type date}, {"memo", type text}, {"currency", type text}, {"exchange_rate", type number}, {"customer_id", type text}, {"customer_name", type text}, {"due_date", type date}, {"subtotal", type number}, {"tax", type number}, {"total", type number}, {"applied", type number}, {"balance", type number}, {"is_paid", type logical}, {"terms_id", type text}, {"terms_name", type text}, {"class_id", type text}, {"class_name", type text}, {"status", type text}, {"days_overdue", Int64.Type}, {"line_count", Int64.Type}}, "en-US")
in
Typed
| Part | Why it's written this way |
|---|---|
A fixed base URL, with the path in RelativePath and the filters in Query | Microsoft's Power BI documentation says models with a dynamic data source (a URL built in code) usually can't refresh in the Power BI service, and names RelativePath and Query on Web.Contents as the exception. This form keeps scheduled refresh working there |
No Headers field | A key in a header would sit in the query text, in plain view, in every copy of the workbook |
Not ApiKeyName | Microsoft's Web.Contents reference shows that option adding the key to the URL as a query parameter. The API refuses keys in URLs (400 key_in_url) |
List.Generate over next_cursor | Follows every page until there are no more, so you get all 3,400 invoices, not the first 500 |
ManualStatusHandling and Checked | Shows the API's own error message and hint in Excel instead of a bare HTTP code |
Columns and Typed | Fixed column names and types, so dates are dates and an empty result still loads a table with headers |
Keeping it current
- Data > Refresh All refreshes every query in the workbook.
- In Data > Queries & Connections, right-click the query, Properties, and tick Refresh data when opening the file or Refresh every N minutes. Matching the company file's check-in interval (60 minutes by default) is enough; refreshing more often returns the same data. See Freshness and sync.
- To change or remove the key Excel saved: Data > Get Data > Data Source Settings, select
https://desktop-app.greatwork.company, then Edit Permissions or Clear Permissions.
Sharing the workbook
The credential stays with you, on your computer. Someone else who opens the workbook and refreshes is asked for a key of their own, so give each person their own key rather than sharing one.
Power BI
The same query works in Power BI Desktop (Get data > Blank query > Advanced Editor) with the same Basic credentials. After you publish, enter those credentials again under the semantic model's data source credentials in the Power BI service to turn on scheduled refresh. The service checks the credentials against the base address, https://desktop-app.greatwork.company, which answers without data; if it says the credentials are invalid, tick Skip test connection in that dialog and save.
No-copy files
A file in no-copy mode can't answer a refresh straight away, so the query stops with "This company file keeps no copy here. The answer arrives at the next Web Connector check-in" and the table keeps its last rows. For Excel, keep a copy.
More on reports in Excel, such as A/R aging by client, is on QuickBooks Desktop in Excel. For keys and scopes, see Authentication.
Checked on November 29, 2026 against Microsoft's Web.Contents reference and Data refresh in Power BI (dynamic data sources).