This is a Python script that I used to fetch my saved articles (now Boards) on feedly.com.
I referred to many design patterns from python-feedly. Many thanks!
Python 3, requests, pandas, numpy (pandas and numpy are used to flatten json).
-
Download the source files.
-
Create a config.json file, which contains your secret tokens and looks like
{
"client_id": "XXX",
"client_secret": "XXX",
"access_token": "XXX",
"refresh_token": "XXX",
"last_fetch": -1,
"my_stream_id1": "user/XXX"
}
-
You may apply for a developer access token, or find them using the web app (feedly.com) with Chrome developer tools. Check API calls in Network tab.
-
The
my_stream_id1
is the streamId you will need. For each "saved article category" (now Board) you would like to fetch, there is astreamId
. ThestreamId
can be achieved through an API call, or using the Chrome developer tools. -
If you have more than one category to fetch, modify the
FeedlyClient.tag_fetch()
function and thestreamId
parameters in it. -
This script fetches your saved articles incrementally, the
last_fetch
is the timestamp of the most recent fetch, and it is checked during each run. The format is unix timestamp in millisecond. For your first time "incremental fetch", which is actually a "full fetch", you may set that as-1
.
- For the database, I used the Python dataset library.
As an example, I used SQLite backend with it.
If you would like to use other kinds of library, make sure your DataBase wrapper support a
DataBase.insert(item: json)
method. The only argument is the item dict from the original response json.
full response (json) -> response['items'] (list) -> item (json)
-
The
DataBase.insert
method is responsible to format theitem-json
and store that into the database. -
Each
item
is a saved article with many metadata.
-
The script supports automatically renew
access_token
throughrefresh_token
when it is expired. -
Run
python3 main.py
. Wait until the fetch finishes. -
Enjoy! File issue or PR if you have any suggestions.
MIT. Use at your own risk.