Free stock api with Finnhub.io - Alternative for Yahoo finance

free realtime stock api

Phd students at University of South Carolina have been using Finnhub as their primary source for finance data since yahoo finance shut down 2 years ago. Today I just wanna show a quick Python tutorial to get realtime data from Finnhub stock api to draw candlestick chart and do your own analysis.

Make sure to get your Free API key first to access 60 calls/minute. In this tutorial I will use the API without a API key, which will limit me to 2 calls per mintue. Here is an example:

Get 2000 Daily candles for AAPL

https://finnhub.io/api/v1/stock/candle?symbol=AAPL&resolution=D&count=500



import plotly.graph_objects as go
import pandas as pd
from datetime import datetime
df = pd.read_csv('https://finnhub.io/api/v1/stock/candle?symbol=AAPL&resolution=D&count=500&format=csv')
fig = go.Figure(data=[go.Candlestick(x=df['t'],
open=df['o'],
high=df['h'],
low=df['l'],
close=df['c'])])
fig.show()




To learn more about Finnhub stock API , read the docs here