Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
morningstar.com API

morningstar.com API

  • Get key ratio, return csv format file
http://financials.morningstar.com/ajax/exportKR2CSV.html?t=<market>:<stock>

Market

  • XHKG: Hong Kong Stock Exchange
  • XASE: American Stock Exchange
  • XNAS: Nasdaq Stock Exchange
  • XNYS: New York Stock Exchange
  • XSHE: ShenZhen Stock Exchange
  • XSHG: Shanghai Stock Exchange

Example, get Tencent Holdings Ltd from HongKong market. http://financials.morningstar.com/ajax/exportKR2CSV.html?t=XHKG:000700

  • Get financial statment, return csv format file
http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=<market>:<stock>&reportType=<is|cf|bs>&period=<12|3>&dataType=<A|R>&order=<asc|desc>&denominatorView=<raw|percentage|decimal>&columnYear=5&number=3
  • reportType: is = Income Statement, cf = Cash Flow, bs = Balance Sheet
  • period: 12 for annual reporting, 3 for quarterly reporting
  • dataType: this doesn't seem to change and is always A
  • order: asc or desc (ascending or descending)
  • columnYear: 5 or 10 are the only two values supported, 10 years report need register
  • number: The units of the response data. 1 = None 2 = Thousands 3 = Millions 4 = Billions
  • Get price ratio, return html

Get price ratio history

http://financials.morningstar.com/valuate/valuation-history.action?&t=<market>:<stock>&type=price-earnings

Get current price ratio

http://financials.morningstar.com/valuate/current-valuation-list.action?&t=<market>:<stock>

Get forward price ratio

http://financials.morningstar.com/valuate/forward-valuation-list.action?&t=<market>:<stock>
  • Get history price, return json format data
http://globalquote.morningstar.com/globalcomponent/RealtimeHistoricalStockData.ashx?ticker=<maarket>:<stock>&showVol=true&dtype=his&f=d&range=<startDate>|<endDate>
  • f: m = month, d = day
  • startData, endData: YYYY-M-D
@Raj39120

This comment has been minimized.

Copy link

@Raj39120 Raj39120 commented Apr 30, 2020

cool

@tejaschachcha

This comment has been minimized.

Copy link

@tejaschachcha tejaschachcha commented May 17, 2020

columnYear=10 works as well if referer is set correctly.

referer

@yewkay

This comment has been minimized.

Copy link

@yewkay yewkay commented May 17, 2020

I can't get the URL to work
entering http://financials.morningstar.com/ajax/exportKR2CSV.html?t=XNYS:ALB into the browser address bar does nothing when i hit enter. Am I missing something?

@Jorsche

This comment has been minimized.

Copy link

@Jorsche Jorsche commented Sep 26, 2020

cant seems to get it work. im getting back nothing .is there any solutions?

@Glazomer

This comment has been minimized.

Copy link

@Glazomer Glazomer commented Oct 7, 2020

cant seems to get it work. im getting back nothing .is there any solutions?

Works for me, but no the 10 years parameter

@Glazomer

This comment has been minimized.

Copy link

@Glazomer Glazomer commented Oct 7, 2020

columnYear=10 works as well if referer is set correctly.

referer

How you made it work? For October 2020 it doesn't work

@bambrozio

This comment has been minimized.

Copy link

@bambrozio bambrozio commented Nov 1, 2020

I'm giving a test with MSFT, but no success. Can you please help to identify what is wrong on my request? Also, how do I know the correct <market> of a given <stock>?
Here's my attempt:

http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=XNAS:MSFT&reportType=is&period=12&dataType=A&order=asc&denominatorView=raw&columnYear=10&number=3
@Glazomer

This comment has been minimized.

Copy link

@Glazomer Glazomer commented Nov 1, 2020

I'm giving a test with MSFT, but no success. Can you please help to identify what is wrong on my request? Also, how do I know the correct <market> of a given <stock>?
Here's my attempt:

http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=XNAS:MSFT&reportType=is&period=12&dataType=A&order=asc&denominatorView=raw&columnYear=10&number=3

Are you trying to get financial report from MSFT?

@vomikan

This comment has been minimized.

Copy link

@vomikan vomikan commented Nov 4, 2020

FYI
moneymanagerex/moneymanagerex#2259
I am also trying to use morningstar.com API

@Siamondx

This comment has been minimized.

Copy link

@Siamondx Siamondx commented Jun 22, 2021

Also, do you guys know how to retrieve historical stock data (e.g. price) normalized in US$? Even if it's a foreign security?

@bambrozio

This comment has been minimized.

Copy link

@bambrozio bambrozio commented Jun 27, 2021

I'm giving a test with MSFT, but no success. Can you please help to identify what is wrong on my request? Also, how do I know the correct <market> of a given <stock>?
Here's my attempt:

http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=XNAS:MSFT&reportType=is&period=12&dataType=A&order=asc&denominatorView=raw&columnYear=10&number=3

Are you trying to get financial report from MSFT?

Yes. Not only MSFT, but any given ticket. I want to automate the retrieval of past 10 years ratios of some fundamentals data. Such as:

  • ROIC
  • EPS
  • Revenue
  • Operating income
  • Net Income
  • Free cash flow
  • Operating cash flow
  • P/E
  • Price/Book
  • Price/Sales
  • Price/Cash Flow
  • Book value per share (BVPS) + Dividends
  • Operating Cash Flow Per Share
  • Sales Per Share

Thus, besides each of those ratios, I also need to know how to find the correct naming expected for and . Perhaps there's another API to retrieve such a table?

@urbanskalar

This comment has been minimized.

Copy link

@urbanskalar urbanskalar commented Sep 20, 2021

I'm giving a test with MSFT, but no success. Can you please help to identify what is wrong on my request? Also, how do I know the correct <market> of a given <stock>?
Here's my attempt:

http://financials.morningstar.com/ajax/ReportProcess4CSV.html?t=XNAS:MSFT&reportType=is&period=12&dataType=A&order=asc&denominatorView=raw&columnYear=10&number=3

Are you trying to get financial report from MSFT?

Yes. Not only MSFT, but any given ticket. I want to automate the retrieval of past 10 years ratios of some fundamentals data. Such as:

* ROIC

* EPS

* Revenue

* Operating income

* Net Income

* Free cash flow

* Operating cash flow

* P/E

* Price/Book

* Price/Sales

* Price/Cash Flow

* Book value per share (BVPS) + Dividends

* Operating Cash Flow Per Share

* Sales Per Share

Thus, besides each of those ratios, I also need to know how to find the correct naming expected for and . Perhaps there's another API to retrieve such a table?

I think I found the problem. You have to edit header before sending request. Here is a python sample of what works for me.

import requests
from requests.structures import CaseInsensitiveDict

url = "https://financials.morningstar.com/finan/ajax/exportKR2CSV.html?&callback=?&t=AAPL&region=usa&culture=en-US&cur=&order=asc"

headers["Referer"] = "https://financials.morningstar.com/ratios/r.html?t=AAPL&culture=en&platform=sal"
session = requests.Session()

resp = session.get(url, headers=headers)

print(resp.status_code)
print(resp.content)
@urbanskalar

This comment has been minimized.

Copy link

@urbanskalar urbanskalar commented Sep 20, 2021

I tried: http://globalquote.morningstar.com/globalcomponent/RealtimeHistoricalStockData.ashx?ticker=XNAS:AMZN&showVol=true&dtype=his&f=d&range=2020-12-31|2021-03-31

And I get a 502 error?

This one doesn't work for me either, but I found a different link which uses csv format instead of json:

http://performance.morningstar.com/perform/Performance/stock/exportStockPrice.action?t=<market:ticker>&pd=max&freq=<frequency>&sd=&ed=&pg=0&culture=en-US&cur=USD')

where market is as mentioned above:

XHKG: Hong Kong Stock Exchange
XASE: American Stock Exchange
XNAS: Nasdaq Stock Exchange
XNYS: New York Stock Exchange
XSHE: ShenZhen Stock Exchange
XSHG: Shanghai Stock Exchange

frequency is:

d for daily
w for weekly
m for monthly
q for quarterly
a for annualy

and I'm pretty sure you know what ticker is.

I didn't play with other parameters, but I guess you could set range for "pd" instead of current value "max". If you want to do more research on this you can use Browser Console (on firefox) and pres export button with different parameters on this link and observe urls that pup up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment