kaitlin / pyft

A python API wrapper for the Financial Times API
The Unlicense
5 stars 7 forks source link

How to give the path to my local key? #1

Open antoinecomp opened 5 years ago

antoinecomp commented 5 years ago

I want to get all the Financial Time news from a date I give. I found your API. I applied for an API key from the news site but mine is in the following folder: C:\Users\antoi\Documents\Programming\Tests\StockPredictions. So I modified the code that allows me to give my key fp = os.path.expanduser("~/.ft.key") with os.path.expanduser("~\Documents\Programming\Tests\StockPredictions\.ft.key") But it doesn't work. Indeed I changed the following: fp = os.path.expanduser("~/.ft.key") with os.path.expanduser("~\Documents\Programming\Tests\StockPredictions\.ft.key") but it didn't worked. I have the following error:

---------------------------------------------------------------------------
MissingSchema                             Traceback (most recent call last)
<ipython-input-36-719b4768b590> in <module>
----> 1 df = ek.get_news_headlines('R:IBM.N AND Language:LEN', date_to = "2017-12-04", count=100)
      2 df.head()

C:\ProgramData\Anaconda3\lib\site-packages\eikon\news_request.py in get_news_headlines(query, count, date_from, date_to, raw_output, debug)
    111         payload.update({'dateTo': to_datetime(date_to).isoformat()})
    112 
--> 113     result = eikon.json_requests.send_json_request(News_Headlines_UDF_endpoint, payload, debug=debug)
    114 
    115     if raw_output:

C:\ProgramData\Anaconda3\lib\site-packages\eikon\json_requests.py in send_json_request(entity, payload, ID, debug)
     83                                      headers={'Content-Type': 'application/json',
     84                                               'x-tr-applicationid': profile.get_app_key()},
---> 85                                      timeout=60)
     86 
     87             try:

C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py in post(self, url, data, json, **kwargs)
    563         """
    564 
--> 565         return self.request('POST', url, data=data, json=json, **kwargs)
    566 
    567     def put(self, url, data=None, **kwargs):

C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    502             hooks = hooks,
    503         )
--> 504         prep = self.prepare_request(req)
    505 
    506         proxies = proxies or {}

C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py in prepare_request(self, request)
    434             auth=merge_setting(auth, self.auth),
    435             cookies=merged_cookies,
--> 436             hooks=merge_hooks(request.hooks, self.hooks),
    437         )
    438         return p

C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py in prepare(self, method, url, headers, files, data, params, auth, cookies, hooks, json)
    300 
    301         self.prepare_method(method)
--> 302         self.prepare_url(url, params)
    303         self.prepare_headers(headers)
    304         self.prepare_cookies(cookies)

C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py in prepare_url(self, url, params)
    380             error = error.format(to_native_string(url, 'utf8'))
    381 
--> 382             raise MissingSchema(error)
    383 
    384         if not host:

MissingSchema: Invalid URL 'None': No schema supplied. Perhaps you meant http://None?
erickfung commented 5 years ago

I have the same problem. I am wondering if anyone knows how to fix it.