• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Rakuten RapidAPI Blog

The World's Largest API Marketplace

  • Enterprise
    • Product
    • eBooks
    • Contact Us
  • Marketplace
    • Product
    • Sign Up
    • Docs
  • Resources
    • API Blog
    • API Tutorial
    • Developer Showcase
  • EnglishEnglish
    • 日本語日本語
You are here: Home / API Tutorial / Yahoo Finance API – The Complete Guide

Yahoo Finance API – The Complete Guide

April 10, 2019 By rakuten Leave a Comment

Yahoo Finance API is a service that provides stock quotes and other financial information for any stock ticker symbol. It is one of the largest source of financial data available on the web, and it is updated continuously throughout the day. Yahoo Finance API covers over 37,000 stocks in more than 50 countries. Yahoo Finance is a media property that provides various financial news and data including stock details, quotes, press releases, financial reports.

In this tutorial, we will cover how to consume the Yahoo Finance API powered by Rakuten RapidAPI, how to get market summary, quotes and get a stock details using node.js.

Yahoo Finance API powered by Rakuten rapidAPI

Does Yahoo Finance have an API?

Yes, Yahoo Finance has an API. It provides data of stocks, financial news, press releases and financial reports of companies. The free tier of Yahoo Finance API gives 500 calls/month. Paid plan starts from $10/month.

Table of Contents

  • 1 Setup
    • 1.1 Getting the Javascript Code
    • 1.2 Start with Signing Up to the Yahoo Finance API
    • 1.3 How do I access my Yahoo Finance API?
  • 2 Yahoo Finance API Overview
  • 3 Get Market summary
    • 3.1 Understanding the code:
    • 3.2 API Response:
  • 4 Get Market Quotes:
    • 4.1 Understanding the code:
    • 4.2 API Response:
  • 5 Get Stock details:
    • 5.1 Understanding the code:
    • 5.2 API Response:
    • 5.3 Yahoo Finance API Historical Data
  • 6 Closing Notes
  • 7 That’s it!
    • 7.1 Share this:

Setup

To get started you’ll need:

  1. Javascript editor and npm unirest package that will speed up code writing.
  2. Subscribe to the Yahoo Finance API.

Getting the Javascript Code

Rakuten RapidApi got you covered and packaged all the JavaScript code you need to work with the API in an easy unirest SDK, which is a library to simplify HTTP REST requests and save you time writing code.

Get started by installing the unirest package with the following command:

npm install unirest --save

As soon as that’s done, you can start exploring the API. It’s safe to ignore the npm warn messages at this point if you see any.

 

Start with Signing Up to the Yahoo Finance API

Access is free through Rakuten RapidAPI — the world’s largest API marketplace. With 8,000+ third-party APIs and used by over 500,000 active developers, we enable developers to build transformative apps through the power of APIs. Find, test and connect to all the APIs you need in one place!

What is Yahoo Finance API?

Yahoo Finance API is a reliable source of stock market data. It also provides other financial information including market summaries, historical quotes, news feed and financial reports. The unofficial Yahoo Finance API can be accessed from Rakuten RapidAPI.

On top of that, you can try it without leaving the browser. You’ll need to sign up to get the API keys and make requests. With these keys, you’ll be able to make and authenticate the requests, so we will know they come from you.

Yahoo Finance API page on Rakuten rapidAPI

As soon as you sign-in with your account, the view above will be replaced with another view, where you can see your API keys (X-RapidAPI-Key) in the Request Headers section and a ready to copy snippet of code at the right side.


How do I access my Yahoo Finance API?

Yahaoo Finance API wrapper is available in multiple languages and via various tools and frameworks. Some of the programming languages supported include C, C#, Go, Java, JavaScript, Objective-C, Ocaml, PHP, Python, and Ruby. It can also be accessed via shell using cURL, HTTPie, and Wget. It also supports RapidQL, a GraphQL like query language. It also supports the Node.js framework. To access Yahoo Finance API follow the steps below.

  1. Create a free account with Rakuten RapidAPI using Github, Google, or email.
  2. Log into your account and navigate to the API.
  3. Choose a plan. You can start with the free tier or purchase a paid plan.
  4. Every API at Rakuten RapidAPI comes with a quick start guide. The quick start guide is a collection of code snippets in popular programming languages and frameworks. You can choose your favorite and start in no time. For example if you are building your app in JavaScript, the code snippets are available in jQuery, fetch (method), and XMLHttpRequest.
  5. Simply copy paste the code snippet in your favorite IDE or code editor and you are ready to test drive the API.

 

Yahoo Finance API Overview

The Yahoo Finance API provides, through Rakuten RapidAPI, 8 endpoints, each of which covers a specific feature that you can use:

  • market/get-summary: Get live summary information at the request time
  • market/get-movers: The live day gainers / losers / actives in specific region
  • market/get-quotes: Retrieve the quotes by symbols
  • market/get-charts: Get data to draw charts for a specific symbol and its comparisons
  • market/auto-complete: Get auto complete suggestion for stocks
  • stock/get-detail: Get detail information of each stock
  • stock/get-histories: Get stock histories to draw charts
  • stock/get-news: Get latest news related to a symbol, the result may be empty if there are no news in that region

 

Get Market summary

  1. Start by clicking on the market/get-summary function on the left menu.
  2. The header parameters will be prefilled automatically
  3. Enter the region and language code you wish to get summary information from
  4. Click on the Test Endpoint button to make a request and see the result
  5. Your code is ready to be copied on the right side of the screen

Yahoo Finance API page on Rakuten RapidAPI - Steps for getting the market summary

Understanding the code:

To get the market summary you need just a few lines of codes and a few pieces of data:

  • The X-RapidAPI-Key displayed on the page
  • The region and language code you wish to get summary information from
const unirest = require('unirest');

const API_KEY = "YOUR_API_KEY_HERE";
const region = "US", lang = "en";

unirest.get(`https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/get-summary?region=${region}&lang=${lang}`)
.header("X-RapidAPI-Host", "apidojo-yahoo-finance-v1.p.rapidapi.com")
.header("X-RapidAPI-Key", API_KEY)
.end(function (result) {
 console.log(result.status, result.headers, result.body);
});

API Response:

The response is pretty easy to interpret, comments were added to explain the fields:

{
 "marketSummaryResponse": {
   "result": [
     {
       "fullExchangeName":"SNP", // Name of the exchange
       "exchangeTimezoneName":"America/New_York", // Timezone
       "symbol":"^GSPC", // Exchange symbol
       "regularMarketChange":{}, // Information about the market change
       "gmtOffSetMilliseconds": -14400000,
       "exchangeDataDelayedBy":0,
       "language":"en-US", // Language
       "regularMarketTime":{},
       "regularMarketChangePercent":{},
       "exchangeTimezoneShortName":"EDT",
       "quoteType":"INDEX", // Type of the quote
       "regularMarketPrice":{},
       "marketState":"REGULAR",
       "market":"us_market",
       "quoteSourceName":"Free Realtime Quote",
       "priceHint":2,
       "tradeable":false, // Whether this can be traded
       "sourceInterval":15,
       "exchange":"SNP",
       "shortName":"S&P 500",
       "region":"US",
       "regularMarketPreviousClose":{}
     },
     ...
   ],
   "error": null
 }
}

 

Get Market Quotes:

  1. Start by clicking on the market/quotes function on the left menu.
  2. The header parameters will be prefilled automatically
  3. Enter the region, language, and symbols you wish to get quotes for
  4. Click on the Test Endpoint button to make a request and see the result
  5. Your code is ready to be copied on the right side of the screen

Yahoo Finance API page on Rakuten RapidAPI - Steps to get market quotes

Understanding the code:

To get the market quotes you need just a few lines of codes and a few pieces of data:

  • The X-RapidAPI-Key displayed on the page
  • The region, language, and symbols you wish to get quotes for, note that symbols is URL encoded because it’s passed as a query string parameter
const unirest = require('unirest');

const API_KEY = "YOUR_API_KEY_HERE";
const region = "US", lang = "en";
const symbols = "BAC%2CKC%3DF%2C002210.KS%2CIWM%2CAMECX";

unirest.get(`https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/get-quotes?region=${region}&lang=${lang}&symbols=${symbols}`)
.header("X-RapidAPI-Host", "apidojo-yahoo-finance-v1.p.rapidapi.com")
.header("X-RapidAPI-Key", API_KEY)
.end(function (result) {
 console.log(result.status, result.headers, result.body);
});

API Response:

The response is pretty easy to interpret, comments were added to explain the fields:

{
 "quoteResponse":{
   "result": [
       {
         "language":"en-US",
         "region":"US",
         "quoteType":"EQUITY", // Type of the quote
         "quoteSourceName":"Nasdaq Real Time Price", // Source name of the quote
         "exchangeDataDelayedBy":0, // Delay for the data returned
         "preMarketChange":-0.21000099,
         "preMarketChangePercent":-0.7261445,
         "preMarketTime":1548340100,
         "preMarketPrice":28.71,
         "regularMarketChangePercent":0.2939111,
         "regularMarketPreviousClose":28.92,
         "fullExchangeName":"NYSE", // Full name of the exchange
         "longName":"Bank of America Corporation",
         "marketState":"REGULAR",
         "exchange":"NYQ",
         "sourceInterval":15,
         "exchangeTimezoneName":"America/New_York",
         "exchangeTimezoneShortName":"EST",
         "pageViews":{},
         "gmtOffSetMilliseconds":-18000000,
         "esgPopulated":false,
         "tradeable":true,
         "priceHint":3,
         "shortName":"Bank of America Corporation",
         "market":"us_market",
         "regularMarketPrice":29.005,
         "regularMarketTime":1548351167,
         "regularMarketChange":0.084999084,
         "regularMarketVolume":28284717,
         "symbol":"BAC"
       },
       ...
   ],
   "error": null
 }
}

 

Get Stock details:

  1. Start by clicking on the stock/get-detail function on the left menu.
  2. The header parameters will be prefilled automatically
  3. Enter the region, language, and symbol you wish to get quotes for
  4. Click on the Test Endpoint button to make a request and see the result
  5. Your code is ready to be copied on the right side of the screen

Yahoo Finance API page on Rakuten RapidAPI - Steps to get stock details

Understanding the code:

To get the stock details you need just a few lines of codes and a few pieces of data:

  • The X-RapidAPI-Key displayed on the page
  • The region, language, and symbol representing the stock you wish to get details for
const unirest = require('unirest');

const API_KEY = "YOUR_API_KEY_HERE";
const region = "US", lang = "en";
const symbol = "NBEV";

unirest.get(`https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/get-quotes?region=${region}&lang=${lang}&symbol=${symbol}`)
.header("X-RapidAPI-Host", "apidojo-yahoo-finance-v1.p.rapidapi.com")
.header("X-RapidAPI-Key", API_KEY)
.end(function (result) {
 console.log(result.status, result.headers, result.body);
});

API Response:

The response is pretty easy to interpret, each field is an object containing pertinent information about the stock:

{
 "defaultKeyStatistics":{},
 "details":{},
 "summaryProfile":{},
 "recommendationTrend":{},
 "majorDirectHolders":{},
 "earnings":{},
 "price":{},
 "fundOwnership":{},
 "insiderTransactions":{},
 "insiderHolders":{},
 "netSharePurchaseActivity":{},
 "majorHoldersBreakdown":{},
 "financialData":{},
 "quoteType":{},
 "institutionOwnership":{},
 "calendarEvents":{},
 "summaryDetail":{},
 "symbol":"NBEV",
 "esgScores":{},
 "upgradeDowngradeHistory":{},
 "pageViews":{}
 }

 

Yahoo Finance API Historical Data

Yahoo Finance API gives stock price history only for a fixed time period of 1 month history before and after today’s date (specified by a start_date and end_date). History is specific to each country/market. For example, if you ask for United States market using ticker ‘aapl’, you will get histories since October 2014 only (unless there was an active market before that date). The current day’s stock price is always available regardless of the start_date and end_date.

Closing Notes

Finance APIs have made consumption of financial data easy. Using an API like Yahoo Finance API one can easily integrate stock prices, company news, etc in apps without jumping through too many hoops. You can integrate real-time stock quotes into your website or mobile app, create portfolio management tools or just display stock information directly from your website or mobile app with Yahoo! Finance API.

However one should have a solid understanding of APIs to get the most of them. Our introductory article, What is an API? introduces the core concepts behind APIs and is a great primer if you are new to APIs.

That’s it!

You are ready to go. Feel free to use any or all of the above snippets as you like. Check out the thousands more building blocks that are equally simple to access at Rakuten RapidAPI.

Get started for free banner

About Rakuten RapidAPI

Rakuten RapidAPI Logo

Rakuten RapidAPI is the world’s largest API marketplace with 8,000+ third-party APIs and used by over 500,000 active developers. We enable developers to build transformative apps through the power of APIs. Find, test and connect to all the APIs you need in one place!

Check out some of the world’s best APIs including Microsoft, Sendgrid, Crunchbase, and Skyscanner.

Facebook | LinkedIn | Twitter

3.7 / 5 ( 9 votes )

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)

Filed Under: API Tutorial

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Accelerate tech modernization

To compete in the digital age, Rakuten RapidAPI helps enterprises deploy scalable and flexible IT systems to allow for ongoing experimentation and iteration at speed.

Learn More
Try Rakuten RapidAPI for free
  • Enterprise
  • Marketplace
  • Resources
  • EnglishEnglish

© 2022 Rakuten RapidAPI. All rights reserved.