Code Monkey home page Code Monkey logo

pyft's Introduction

PyFT

(prounounced "pfft")

PyFT is a python API wrapper around the Financial Times Content API, v2. Access to the Financial Times API requires a key, which can be obtained at developer.ft.com.

Dependencies

This wrapper is written to be compatible with Python 3+. To install necessary dependencies, use pip and the provided requirements.txt file.

pip install -r requirements.txt

Getting Started

PyFT will look in two places for your api key. First, ~/.ft.key will be read and the contents of that file will be used for your API key. Secondly, PyFT will try to use an environment variable called FT_API_KEY. If the environment variable is present, it will override the contents of the file.

To get the data for a single piece of content on FT.com:

from pyft import FT

ft = FT()
# the id can be pulled from the slug url of an FT.com story
content = ft.get_content("6f2ca3d6-86f5-11e4-982e-00144feabdc0")
print(content)

To get all of the content that has been updated since a certain date (continuing from previous example):

updated_content = ft.get_content_notifications(updated_since="2015-01-01")

##Running Tests

You can run the tests in the home directory with the python unittest framework:

python -m unittest tests.py

pyft's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyft's Issues

How to give the path to my local key?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.