-
Notifications
You must be signed in to change notification settings - Fork 144
Description
Hi, dear all,
I am a new learner of Finnhub who is trying to do some basic work with Finnhub.
Finnhub-python version: 2.24.20.
Here is the code. API-key I have stored in .env with FINNHUB_KEY=xxxxxxxxxxxxxxxxxxxxxx
from decouple import config
import finnhub
import json
import pandas as pd
from pprint import pprint
import requests
-# Get the tokens for API access
api_key = config("FINNHUB_KEY")
-# Specify params
symbol = 'IBM'
interval = 'D'
start_date = 1609455600 #2021-01-01
end_date = 1612047600 #2021-01-31
-# Specify endpoints
base_url = 'https://finnhub.io/api/v1'
endpoint = '/stock/candle?'
query = f'symbol={symbol}&resolution={interval}&from={start_date}&to={end_date}&token={api_key}'
-# Get request
response = requests.get(base_url + endpoint + query)
pprint(response.json())
-# Convert to DataFrame
data = pd.DataFrame.from_records(response.json())
data['t'] = pd.to_datetime(data['t'], unit='s')
print(data.head())
Error:
{'error': "You don't have access to this resource."}
Could someone help me on this point?