Free realtime stocks data with python(finnhub)

disclaimer : I am not an expert i am just getting you familiar with api available and showing basic code as few months before i did’nt knew what a websocket is

theres an api called Finnhub , Go ahead and sign up and get your api keys from dashboard

api keys page of finnhub

don’t worry you can’t use my keys i will change it as soon as this article is posted

once you have your api keys copy them and fire up your text editor IDE of your choice and i am assuming if your reading this you alredy have python and pip setuped

install 2 libraris ( use pip3 if your using linux or mac )

once you’ve installed this libraries import them

write code to get started ! yay (its really basic but enough to get started with utilizing data)

in line 13 you can change the symbol acordingly for stocks data you wanna subscribe

if you run this file with (python3 if you have multiple python vesions installed)

you’ll get a output like this :

raw stocks output of api

note that if you get output type ping its because market is closed at the time maybe try cheaking day this confuses a lot of peoples includeing me

output when stocks market is closed

then you can easily use this data for whatever you want like this:

when you run this you’ll get much more cleaner output like this:

human readable output (sorted)

according to documentation at Finnhub attributes of a resposnse are:

and yea according to docs if your using a free api key you can only

1 API key can only open 1 connection at a time.

do take a note about that.

Okay so basically thats it i hoped it helped you even a little you free to use this data now in your projetcs do let me know if you’ve liked what i am doing it kinda helps me do more of this with motivation

Thanks for reading :)

Hey! i am a self taught devloper kinda young, iam gonna be posting a story often and tell about new technologies ive learned i hopw it atleast help one of you:)