Skip to content

Not access to Finnhub resource #58

@yy824

Description

@yy824

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions