twelvedata/twelvedata-python

API isn't recognised

Closed this issue · 2 comments

as595 commented

Describe the bug
When I specify my API in the python client I get an InvalidAPIKeyError, but my api works fine if I submit the same query using the standard requests library method in python.

To Reproduce

this throws an error:

from twelvedata import TDClient
td = TDClient(apikey="XXX")
ts = td.time_series(
symbol="AAPL",
interval="1day",
outputsize=30,
timezone="America/New_York",
)
ts.as_pandas()

this works fine:

import requests
url = "https://twelve-data1.p.rapidapi.com/time_series"
querystring = {"symbol":"AAPL","interval":"1day","outputsize":"30","format":"json"}
headers = {
"content-type": "application/octet-stream",
"X-RapidAPI-Key": "XXX",
"X-RapidAPI-Host": "twelve-data1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
print(response.json())

Expected behavior
I'd expect a pd df to be returned. (I also tested a JSON return, same issue)

Desktop (please complete the following information):
Max OSX 10.15.7

Additional context
I realise this is really difficult for you to test/reproduce without me posting my api. But perhaps it's helpful to say that it's an api on the basic plan - so perhaps that's the issue?

The API key provided by RapidAPI cannot be utilized for obtaining data directly from Twelve Data, as this package is designed to request data directly. You have two alternatives:

  1. Obtain a new API key directly from Twelve Data.
  2. Continue making data requests through RapidAPI.
as595 commented

👍