Skip to main content

A lightweight client for the feedly api (https://developers.feedly.com).

Project description

python-api-client

Python client code for the feedly api https://developers.feedly.com/

Initializing a client

To initialize a client, first you need an access token. To just play around, login to feedly and go to the console. Then find the feedlyToken property. This is your web access token. You can make requests with this token but it will expire. It's not suitable for building an application, but will get you going.

If you're serious about building an app, you probably want to get a developer token. Check the page for more details.

You can run feedly/examples/setup_auth.py to get your access token saved into the default config directory, ~/.config/feedly. Then, you can initialize the client as follows:

from feedly.api_client.session import FeedlySession

sess = FeedlySession()

Clients are lightweight -- you can keep a client around for the lifetime of your program, or you can create a new one when needed. It's a bit more efficient to keep it around. If you do choose to create clients as needed, you should pass in the user's ID in the constructor, otherwise you'll incur a /v3/profile request.

Examples setup

When running an example, for the first time, you'll be prompted to enter your token. It will be saved in ~/.config/feedly

API Oriented Usage

You can use the FeedlySession object to make arbitrary API requests. E.g.:

sess.do_api_request('/v3/feeds/feed%2Fhttp%3A%2F%2Fblog.feedly.com%2Ffeed%2F')
{
  "id": "feed/http://blog.feedly.com/feed/",
  "feedId": "feed/http://blog.feedly.com/feed/",
  "title": "Feedly Blog",
  ...
}

Object Oriented Usage

Retrieving Streams

Alternatively, you can use the object-oriented code, which facilitates common usage patterns. E.g. you can list your user categories:

sess.user.user_categories.name2stream
{'comics': <UserCategory: user/xxx/category/aaa>,
 'econ': <UserCategory: user/xxx/category/bbb>,
 'global.must': <UserCategory: user/xxx/category/ccc>,
 'politics': <UserCategory: user/xxx/category/ddd>,
}

where xxx is your actual user ID.

It's not necessary to list categories beforehand, if you know the ones that exist, you can get one on the fly, by querying it by id or name:

sess.user.user_categories.get('comics')  # From the category name
sess.user.user_categories.get('aaa')  # From the category id
<UserCategory: user/xxx/category/aaa>

You can access:

  • User feeds with sess.user.user_categories
  • User boards with sess.user.user_tags
  • Team feeds with sess.user.enterprise_categories
  • Team boards with sess.user.enterprise_tags

Accessing Entries (articles)

If you need to access entries or entry IDs, you can use easily stream them via stream_contents and stream_ids, respectively:

with FeedlySession(auth_token=token) as sess:
    for eid in sess.user.user_categories.get('politics').stream_ids():
         print(eid)
Dz51gkBgvGUvFOfTATCYLB2uqVaBIaGGazzxpZh2WL0=_16549c827dd:1645ba:3da9d93
Dz51gkBgvGUvFOfTATCYLB2uqVaBIaGGazzxpZh2WL0=_16549c827dd:1645bb:3da9d93
Z/Hzx8NYfSSE8sweA2v5+4r5h7HC5ALdE2YGYB8MYbQ=_1654a26f3fe:79d9ef9:6f86c10b
...

Take note of the StreamOptions class. There are important max_count and count properties that control streaming. To download all items, something like this could be done:

opts = StreamOptions(max_count=sys.maxsize) # down all items that exist
opts.count = sys.maxsize # download as many items as possible in every API request
with FeedlySession() as sess:
    for eid in sess.user.get_category('politics').stream_ids(opts):
         print(eid)

Tagging Existing Entries

with FeedlySession() as sess:
    sess.user.get_tag('politics').tag_entry(eid)

Odds and Ends

Feedly APIs are rate limited. Do not make multiple requests concurrently. You can download quite a few entries at a time, see the previous section for details. Once you get rate limited, the client will stop any attempted requests until you have available quota.

To debug things, set the log level to DEBUG. This will print log messages on every API request.

Token Management

The above examples assume the auth (access) token is valid. However these tokens do expire. Instead of passing the auth token itself, you can create a feedly.session.Auth implementation to refresh the auth token. A file based implementation is already provided (FileAuthStore). Once this is done the client will automatically try to refresh the auth token if a 401 response is encountered.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

feedly-client-0.23.tar.gz (15.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

feedly_client-0.23-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

feedly_client-0.23-py2.py3-none-any.whl (4.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file feedly-client-0.23.tar.gz.

File metadata

  • Download URL: feedly-client-0.23.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.5

File hashes

Hashes for feedly-client-0.23.tar.gz
Algorithm Hash digest
SHA256 9e54fbc74f35fceb657225ce409400a207e8d85f98230c8e031d9780ee2fef24
MD5 c05b9357b33f5ba305d6c6815fecca49
BLAKE2b-256 398f914ad8eaaa9de79b8ef2e1bbb0b948a173c9c5575e7030fb7f23973cbd07

See more details on using hashes here.

File details

Details for the file feedly_client-0.23-py3-none-any.whl.

File metadata

  • Download URL: feedly_client-0.23-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.5

File hashes

Hashes for feedly_client-0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 e191c27637122b4aefa00661bfd26a50dfb721c9fda22cb8a4817800cc126a18
MD5 7fa800d459bc5ef07a9431acb806130e
BLAKE2b-256 9ea8f7a92dfdbe5bf02ec81252bc926bba8f6d46fb04a9c23067399579e37534

See more details on using hashes here.

File details

Details for the file feedly_client-0.23-py2.py3-none-any.whl.

File metadata

  • Download URL: feedly_client-0.23-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.5

File hashes

Hashes for feedly_client-0.23-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fb35bed6dc0dcafa0ed1ac0bc9fefe521dc4202ab608f5db6e02f51a8cdfcae9
MD5 9a12460f0d9719527a626d55959249cb
BLAKE2b-256 ac7deb303bafbd00d22df757aed80fe8494c4dff4a7974d2ffd1b42a868986b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page