circle

Check out our latest report on bankruptcies and restructurings in the retail sector. Download »

Public Registers API

Many companies are passing up the benefits of APIs out of fear of the high costs associated with implementing IT systems. In fact, all you need to bulk-download data from public registries (such as the National Court Register) via an API is Excel.

With Power Query, you can connect your spreadsheet directly to MGBI resources, turning a simple list of KRS numbers into a comprehensive database of business partners—without writing a single line of code.

In this guide, we explain how to use this solution to gain broad access to data from numerous public registries.

You can find a list of data sources available through the MGBI API at:
👉Public Registers API

See also the technical documentation for the Public Registers API:
👉 Technical Documentation - Public Registers API


1. Preparing a list of identifiers

The first step is to create a column in the spreadsheet containing the identifiers of the entities you want to check (e.g., KRS numbers).

Give the column a clear heading, such as "KRS Number," and enter the numbers as text values. This will help you avoid formatting errors (such as leading zeros being omitted).

Screenshot 1 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Next, select the data and press Ctrl + T on your keyboard. Then click "OK" to create the table.

Screenshot 2 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

The table view will change, which can be taken as confirmation that the previous steps were performed correctly.

Screenshot 3 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel


2. Import into Power Query

Select the table and go to the Data tab. Select the option Get DataFrom Other SourcesFrom a Table/Range.

Screenshot 4 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

The Power Query Editor will open—this is where you can connect to the MGBI API.

Make sure the data type of the column containing the KRS numbers is still set to "text." If the program has changed it to "numeric," change it back so that API queries are valid.

In the table header, click the "123" icon.

Screenshot 5 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

From the drop-down list, select "Text".

Screenshot 6 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

The data will be refreshed, and the KRS numbers will then be displayed correctly.

Screenshot 7 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel


3. Query Configuration

The next step is to add a function in the Power Query Editor that will send a query to the MGBI API for each row (KRS number) in your table.

Go to the " Add Column " tab and select " Custom Column."

Screenshot 8 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

A new window will appear.

Screenshot 9 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

In the Custom Column Formula field, paste a query that uses the Json.Document and Web.Contents functions.

Example formula:

GET /v1/models/pl-krs-rdf-record/records?identifiers.pl_krs=[KRS number] HTTP/1.1
Host: api.mgbi.pl
Authorization: [authorization key]

The & symbol will automatically insert the appropriate number from your list into the API endpoint URL. After entering the formula, click the "OK" button.

Screenshot 10 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

A message will appear at the top of the page. Click " Edit credentials" to continue.

Screenshot 11 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

In the new window, verify that the selected level corresponds to the API endpoint address from which you want to retrieve data, and then click the Connect button.

Screenshot 12 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Another message will appear. Click Continue.

Screenshot 13 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Select the "Ignore privacy level checks for this file" option to allow data to flow freely. Finally, click the Save button.

Screenshot 14 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel


4. Unpacking and selecting data

In the new custom column, you'll see values of the Record or Table type. Click the double-arrow icon in the column header to "expand" the data.

Screenshot 15 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Select all options: count, pages, results. Then click the "OK" button.

Screenshot 16 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Click the two-arrow icon in the header of the custom column again.

Screenshot 17 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Now you can select the range of data to include in your file. Then click "OK".

Screenshot 18 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Continue in the same way until the table preview contains all the data you want to import into your spreadsheet.


5. Updating data in the spreadsheet

Once the table looks the way you planned, select " Close and Load."

Screenshot 19 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

The prepared data will be inserted into your spreadsheet as a new tab called " Table."

Screenshot 20 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Information about businesses available in public registries, such as the National Court Register (KRS), is subject to frequent changes (e.g., changes in the registered office address, the composition of the management board, or the amount of share capital).

To make sure the information in your spreadsheet is up to date, go to the Data tab and select Refresh All.

Screenshot 21 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Excel will connect to the MGBI API, retrieve the latest records, and overwrite the old data in your spreadsheet.

With this solution, your database is always ready to go, and you save time by avoiding the need to manually check each entity individually.


6. Adding new entities

If you want to add more entities to your file, you don't need to create a new query.

Go to the source table containing the KRS numbers and enter the new identifier directly in the next empty row below the table.

Screenshot 22 - How to retrieve data from the MGBI API using Power Query in Microsoft Excel

Because you used the Ctrl + T shortcut earlier, Excel will automatically recognize the new entry and "stretch" the table range to include it.

Please note that the new KRS number must also be entered as plain text for the API request to work correctly.

A demo is worth more than a thousand words

Contact Us
arrow_forward