/
Creating dynamic FOLIO reports in Excel using API queries

Creating dynamic FOLIO reports in Excel using API queries

This guide was written in 2021-05-04, and so will contain instructions that are no longer correct.

Create a user with the relevant set of permissions

For creating reports, you would ideally have a user with only READ rights. You might also consider having different users for reports that only involve resource data, and reports involving user or circulation data.

The stricter the permissions, the smaller the risk of making mistakes such as allowing access to user data too freely, or accidentally changing or deleting records.

Get credentials for the API request

You need a URL (not the same as the one you see in your browser’s address bar) and an ID for your tenant, as well as a token which is specific to your FOLIO user and holds the information about user permissions.

  1. Log into the FOLIO web interface as your user of choice.

  2. Press F12 on your keyboard to open your browser’s Developer tools, and click on the Network pane.

  3. Refresh the page.

  4. In Developer tools, click on a GET request to open the detailed information.

  5. You will find the data you need in Host, X-Okapi-Tenant and the X-Okapi-Token under Headers > Request headers.

image-20250224-091844.png

Test the request query in Postman

Use Postman or another tool for making API requests.

Set up the basics

  1. Create a new GET request by clicking New in the top left corner.

image-20250224-091938.png
  1. The new request should look like this. Verify that the method (to the left of the URL field) is GET.

image-20250224-092000.png
  1. In the request URL field, add https//: followed by the Host value you found in Developer Tools

  2. Under headers, add the following:

    image-20250224-092010.png

Key X-Okapi-Tenant with the X-Okapi-Tenant value you found in Developer Tools

Key X-Okapi-Token with the X-Okapi-Token value you found in Developer Tools

Specify an API endpoint

To get a list of FOLIO Items, you make a GET request to the inventory/items endpoint.

The following request would return all* existing items:

image-20250224-092024.png

* The API may have a default limit. If the number of items in your Inventory is higher than that limit, you need to use pagination to retrieve all items.

Specify a query

In order to get only those items which have an item status of Missing, you need to add a CQL (Contextual Query Language) query.

The following request would return a maximum of 100 items with the item status Missing.

image-20250224-092106.png

This request consists of the following elements:

  • A base URL

  • The API endpoint /inventory/items

  • A “?” which introduces the parameters

  • The parameter query, which contains our CQL query

  • The parameter limit, which limits the response to 100 items - I added this because, in many cases, you only get 10 objects back if you don’t specify a limit higher than that

The CQL query status.name=="Missing" returns items where status > name exactly matches the string “Missing”.


       "status": {

       "name": "Missing"

     }

Run the query from an Excel document

  1. This can be useful if you plan to recreate the same report semi-regularly.

  2. In an empty Excel spreadsheet/tab, click Data and select From Web.

image-20250224-092530.png
  1. Select Advanced and fill the following (just like in Postman):

a.     The request URL

b.     The tenant and token parameters

image-20250224-092636.png
  1. Click OK

Design the report in Excel

  1. When you saved your “From Web” connection, or if you import data from a JSON file, PowerQuery opens. This is where you can tailor the JSON response into something that is concise and easy to read by selecting which data elements to display.

  2. Click on the word List to expand the list of records (one per missing FOLIO item).

    image-20250224-092652.png
  3. Once you see the list expanded, click on To Table.

image-20250224-092659.png
  1. Click OK without changing anything:

    image-20250224-092734.png
  2. Click the little square with two arrows, in the top right corner of the column header, to select the JSON data elements you want to use as columns.

image-20250224-092759.png

10.  Make a selection, and click OK. (If you are missing something, you can click Load more to see all existing elements.)

11.  If all rows in a column still display as “Record”, click the double arrows in the header to expand that column. Choose the element you want to include in your table.

image-20250224-092811.png

12.  Reorder and rename the columns to your heart’s content, and then click Close & load (under the tab Home).

image-20250224-092822.png

13.  Tada! The data from FOLIO is loaded into a table.

image-20250224-092830.png

Refresh the data to get a fresh report

Since you’ve saved the connection and query to the FOLIO API, you can at any time make a new request to FOLIO and get fresh data by clicking Refresh all. You can save the document and refresh the data next time you open it.

image-20250224-092843.png

Update the token

Sometimes you need to update the token used in your query. This can be after a FOLIO version upgrade, or after you’ve added a new permission to your report user. The easiest way to do that is in Power query’s Advanced editor.

  1. Open your Excel file and go to Data >  Queries & Connections.

  2. In the Queries & Connections pane the right, double click the query you want to edit.

image-20250224-092851.png
  1. In the Power Query Editor that shows up, choose Advanced Editor.

  2. Find and update your token. Use Display Options to wrap text for better view. {{add-new-token-here}}

    image-20250224-092905.png
  3. Click Done. Choose Close & Load. Repeat for all your queries.

  4. Done till next upgrade.

 

Related content