Börsdata API in Python: download prices, reports and ratios

API
Data Sources
Tutorial
Python
I show how to download Börsdata’s daily stock prices, company reports, and ratios such as P/E in Python, compute free cash flow yield, then convert them into panels and save them as three CSV files.
Published

November 26, 2026

downloading Börsdata stock data in Python

Börsdata is a Swedish database for private investors with daily prices, reports, and ratios for about 1,500 Nordic stocks, mostly Swedish. In this post, I show how to download this data into Python. This tutorial and script are for anyone with a Börsdata Pro+ membership.

Setting up

Using the API requires a key, which Pro+ members apply for on their Börsdata page (MinSida). Once you have the key, you can save it on your Windows machine instead of in the notebook, which would otherwise expose it if you accidentally shared your notebook with someone else. On Windows, save the key in PowerShell with setx BORSDATA_API_KEY "your key". Then close Jupyter and the program you started it from, reopen both, and run the notebook from the first cell.

The code uses borsdata-client, a third-party Python client for the API. I installed the version I tested from GitHub, together with pandas and tenacity. The client needs tenacity but does not install it.

pip install pandas tenacity https://github.com/alexwox/Modern-Borsdata-Client/archive/df4231e4ad72a803202dfd32dfa459c4d03afa49.zip

Choosing the stocks

I set the folder for the CSV files, and I connect to the API with the key. Then I ask Börsdata for its markets and its instruments, each with an id. In the list of instruments, I keep the common shares (instrument type 0) on Nasdaq Stockholm Large Cap, Mid Cap, and Small Cap (market IDs 1, 2, and 3): 367 stocks on 26 November 2026.

An error message from the API shows the request URL, which contains the key, so the code removes the key from every error message using the without_key function.

NoteCode: choosing the stocks
import os
from datetime import datetime
from pathlib import Path

import pandas as pd
from borsdata_client import BorsdataClient
from borsdata_client.models import ReportsArrayResp

FOLDER = Path.home() / "Downloads"
FOLDER.mkdir(parents=True, exist_ok=True)
client = BorsdataClient(api_key=os.environ["BORSDATA_API_KEY"])


def without_key(error):
    return str(error).replace(client.api_key, "[API key]")[:200]


try:
    markets = pd.DataFrame(market.model_dump() for market in client.get_markets())
    instruments = pd.DataFrame(instrument.model_dump() for instrument in client.get_instruments())
except Exception as error:
    raise RuntimeError(without_key(error)) from None
print(markets[["id", "name", "exchange_name"]].to_string(index=False))
stocks = instruments.query("market_id in [1, 2, 3] and instrument_type == 0")
ids = stocks["ins_id"].tolist()
print(len(ids), "stocks")

Downloading daily prices

I use each stock’s ID to retrieve its daily prices from January 2016 (Börsdata gives at most 20 years). I store stocks whose download failed in a list, along with their error messages.

rows, failed = [], []
for ins_id in ids:
    try:
        bars = client.get_stock_prices(instrument_id=ins_id, from_date=datetime(2016, 1, 1),
                                       to_date=datetime.now(), max_count=20)
    except Exception as error:
        failed.append({"ins_id": ins_id, "error": without_key(error)})
        continue
    rows += [bar.model_dump() | {"ins_id": ins_id} for bar in bars]
assert rows, "No prices came back. The list failed shows why."

labels = {"d": "date", "o": "open", "h": "high", "l": "low", "c": "close", "v": "volume"}
prices = (pd.DataFrame(rows).rename(columns=labels)
          .merge(stocks[["ins_id", "ticker", "name", "isin", "stock_price_currency"]], on="ins_id")
          .rename(columns={"stock_price_currency": "currency"}))
columns = ["date", "ins_id", "ticker", "name", "isin", "currency", "open", "high", "low", "close",
           "volume"]
prices[columns].sort_values(["ticker", "date"]).to_csv(FOLDER / "borsdata_prices.csv", index=False)
print(len(prices), "rows saved,", len(failed), "stocks failed")

Each row shows a stock day, including its open, high, low, and close prices in the stock’s currency, plus volume. The prices are adjusted for splits and exclude dividends.

Downloading company reports

Each request I send can include up to 50 stocks, with 20 annual and 40 quarterly reports per stock. I could use the client’s reports function, but then Börsdata would limit my request to only 10 quarters per stock, so I have to call the API directly. To ensure that the value I retrieve is in the report’s currency, I set original to 1.

rows, failed = [], []
for first in range(0, len(ids), 50):
    batch = ",".join(map(str, ids[first:first + 50]))
    try:
        response = client._get("/instruments/reports", {"instList": batch, "maxYearCount": "20",
                                                        "maxR12QCount": "40", "original": "1"})
        items = ReportsArrayResp(**response).report_list or []
    except Exception as error:
        failed.append({"first_ins_id": ids[first], "error": without_key(error)})
        continue
    for item in items:
        if item.error:
            failed.append({"ins_id": item.instrument, "error": item.error})
            continue
        rows += [{"ins_id": item.instrument, "report_type": "annual"} | report.model_dump()
                 for report in item.reports_year or []]
        rows += [{"ins_id": item.instrument, "report_type": "quarterly"} | report.model_dump()
                 for report in item.reports_quarter or []]
assert rows, "No reports came back. The list failed shows why."

reports = stocks[["ins_id", "ticker", "name"]].merge(pd.DataFrame(rows), on="ins_id")
reports = reports.sort_values(["ticker", "report_type", "year", "period"])
reports.to_csv(FOLDER / "borsdata_reports.csv", index=False)
print(len(reports), "reports saved,", len(failed), "failures")

Each row is one annual or quarterly report for one stock, with variables such as revenue, operating income, earnings per share, the number of shares, and free cash flow. The column period is 1 to 4 for the quarters and 5 for the full year, and report_date is the day the report was published. Amounts are in millions of the report currency, the number of shares is in millions, and per-share values are in the currency itself.

Downloading ratios

Börsdata calls its ratios KPIs, and the KPI list gives each one’s id, name and unit. In this example, I download P/E, P/B, EBIT/EV, P/FCF, return on capital (ROC) and return on equity (ROE) for each fiscal year (“year”), with the mean price over the year (“mean”) in the price ratios. The KPI list has no free cash flow yield, so I compute it as 100 divided by P/FCF. For other variables, Börsdata’s KPI table on GitHub lists each KPI’s ID and the report and price types it uses.

try:
    kpi_list = pd.DataFrame(kpi.model_dump() for kpi in client.get_kpi_metadata())
except Exception as error:
    raise RuntimeError(without_key(error)) from None
print(kpi_list[["kpi_id", "name_en", "format"]].to_string(index=False))

KPIS = {2: "PE", 4: "PB", 17: "EBIT_EV", 76: "P_FCF", 36: "ROC", 33: "ROE"}
rows, failed = [], []
for kpi_id, name in KPIS.items():
    for first in range(0, len(ids), 50):
        try:
            answer = client.get_kpi_history_batch(ids[first:first + 50], kpi_id, "year", "mean",
                                                  max_count=20)
        except Exception as error:
            failed.append({"kpi": name, "first_ins_id": ids[first], "error": without_key(error)})
            continue
        for item in answer.kpis_list or []:
            if item.error:
                failed.append({"kpi": name, "ins_id": item.instrument, "error": item.error})
                continue
            rows += [{"ins_id": item.instrument, "year": value.y, "period": value.p, "kpi": name,
                      "value": value.v} for value in item.values or []]
assert rows, "No ratios came back. The list failed shows why."

ratios = pd.DataFrame(rows).pivot(index=["ins_id", "year", "period"], columns="kpi", values="value")
ratios = ratios.reindex(columns=list(KPIS.values())).reset_index()
ratios["FCF_YIELD"] = (100 / ratios["P_FCF"]).where(ratios["P_FCF"] != 0)
ratios = stocks[["ins_id", "ticker", "name"]].merge(ratios, on="ins_id")
ratios.sort_values(["ticker", "year", "period"]).to_csv(FOLDER / "borsdata_ratios.csv", index=False)
print(len(ratios), "rows saved,", len(failed), "failures")

Each row is a stock and a fiscal year, with one column per ratio. EBIT/EV, free cash flow yield, ROC and ROE are in percent, and P/E, P/B and P/FCF are multiples. Pay attention to the column period, because a stock’s latest row can cover the 12 months up to its most recent quarter (e.g., 2026 with period 3), while completed fiscal years have period 5. Missing prices show a price ratio of 0, which mostly concerns the sample period before they are listed.

Limitations

One disadvantage of Börsdata’s API is survivorship bias. You only get companies that are listed today. This issue can have different degrees of impact depending on how, or if, you are forming a backtesting strategy using Börsdata. You can use LSEG to include delisted companies, but it is much more expensive than Börsdata.

Conclusion

In this post, I showed how to pull Börsdata’s prices, reports and ratios in Python and convert each into a panel. This data is convenient if you want to study the prices and fundamentals of Nordic stocks, year by year and quarter by quarter.

References

alexwox. (2025). Modern-Borsdata-Client [Computer software]. GitHub. https://github.com/alexwox/Modern-Borsdata-Client

Börsdata. (n.d.). API [API documentation]. GitHub. Retrieved November 26, 2026, from https://github.com/Borsdata-Sweden/API/wiki

Börsdata. (n.d.). KPI history [API documentation]. GitHub. Retrieved November 26, 2026, from https://github.com/Borsdata-Sweden/API/wiki/KPI-History