Getting Started
Stock Summary Pages
Stock Valuation & Ranking
Screeners
Gurus
Insiders
Market Data
What's New
Community
Videos
 

Getting Started with API

An overview of the platform

For the whole usage page, please visit the User API page.

In computer programming, an application programming interface (API) is a set of routines, protocols and tools for building software applications.

GuruFocus' API uses REST architecture. The format of response is JSON. You can use any programming language you would like to build your own winning strategy based on our Guru, Insider and Financial data.

API Change Log

Different companies have different financial templates, and each template has different financial fields. GuruFocus now changes the new financial API to be in accordance with the template shown on the 30-year financials page, effective as of Jan. 3, 2020. Any recent financial API or 30-year financial data changes can be found HERE. Other API or item changes can be found HERE.

The free trial membership only allows 100 requests.

For all stocks that are not traded in the U.S., please replace {symbol?} with {exchange:symbol?} when calling the API.

Membership

API request limit

Free trial

Premium

2,000 per region

Limit 100

PremiumPlus

20,000 per region

Limit 100

Professional

50,000 per region

Limit 100

Professional with unlimited api query

Unlimited

Limit 100

1. Obtain your personal API Token

The GuruFocus API is for Premium and PremiumPlus members' use only. Please obtain your personal Token now .

2. Company financial data

For company financials, up to 30 years of annual data and 120 quarters of quarterly data is available. This API mainly provides data from the 30-year financial page.

Request

Method

URL

GET

https://api.gurufocus.com/public/user/{your personal token?}/stock/{symbol?}/financials

Example

https://api.gurufocus.com/public/user/{your personal token?}/stock/WMT/financials

3. Company key statistics data

Users can also access the company current key statistics data.

Request

Method

URL

GET

https://api.gurufocus.com/public/user/{your personal token?}/stock/{symbol?}/keyratios

Example

https://api.gurufocus.com/public/user/{your personal token?}/stock/WMT/keyratios

For more usage information, please look at the User API page .

Python Code Sample

The following code uses Python 3+ to output the PS Ratio in Valuation Ratio for Walmart (WMT).

import urllib.request, json

response = urllib.request.urlopen('https://api.gurufocus.com/public/user/{your personal token?}/stock/WMT/keyratios')

content = response.read()
data = json.loads(content.decode('utf8'))
print(data['Valuation Ratio']['PS Ratio'])

The Python output of PS Ratio:

0.49

If you encounter "403 Forbidden Error," please see this page.

This is probably because of mod_security or another similar server security feature which blocks known spider/bot user agents (urllib uses something like Python urllib/3.3.0, which is easily detected). Try setting a known browser user agent.

We also support Java, C#, PHP and more. Access the User API page for more information.

Related Content