ttrss-python is a light-weight client library for the JSON API of Tiny Tiny RSS. Handling JSON in Python can be quite a pain, so this library abstracts all that away to deliver Python object representations of categories, feeds and articles. Also, the specific calls and POST data sent to the server is handled automatically, so that you can focus on the stuff that matters to your frontend application.
Sounds good so far? Great, let’s get started!
This package is available at PyPI, so the easiest way to install is by doing a pip install ttrss-python. This will install the latest released version, as well as all dependencies. Currently, the only dependency is the awesome Python requests library for handling all the http requests.
If you for some reason can’t or don’t want to use pip, just download the tarball and run python setup.py install manually.
It’s highly recommended to use virtualenv for this (and any other for that matter!) installation.
The first thing you need to do is instantiate a TTRClient. The constructor requires three arguments; URL, your username and your password:
>>> from ttrss.client import TTRClient
>>> client = TTRClient('http://url-to-tiny-tiny', 'username', 'super-secret-password')
>>> client.login()
If you want the client to login automatically, as well as automatically refresh an expired session cookie, you may supply the optional keyword argument auto_login=True. Note that this may affect performance in a high-traffic client application, since it uses a response hook to check every server response for a NOT_LOGGED_IN message:
>>> client = TTRClient('http://url-to-tiny-tiny', 'username', 'super-secret-password', auto_login=True)
Now you can retrieve a list of feed categories:
>>> categories = client.get_categories()
To be continued...
This section will become more detailed over time as I add docstrings to the source code.
Bases: ttrss.client.RemoteObject
Bases: ttrss.client.RemoteObject
Bases: ttrss.client.RemoteObject
Bases: ttrss.client.RemoteObject
Bases: object
Bases: object
This is the actual client interface to Tiny Tiny RSS.
This object retains a http session with the needed session cookies. From the client you can fetch categories, feeds, headlines and articles, all represented by Python objects. You can also update modify articles and feeds on the server.
Get a list of articles from article ids.
Parameters: | article_id – A comma separated string of article ids to fetch. |
---|
Get a list of all available categories
Get total number of subscribed feeds.
Get a list of feeds in a category.
Parameters: |
|
---|
Get a list of headlines from a specified feed.
Parameters: | feed_id – Feed id. This is available as the id property of a Feed object. |
---|
Get total number of unread articles
Manually log in (i.e. request a session cookie)
This method must be used if the client was not instantiated with auto_login=True
Log out.
After logging out, login() must be used to gain a valid session again. Please note that logging out invalidates any automatic re-login even after logging back in.
Mark an article as read.
Parameters: | article_id – ID of article to mark as read. |
---|
Mark an article as unread.
Parameters: | article_id – ID of article to mark as unread. |
---|
Update all properties of an article object with fresh information from the server.
Please note that this method alters the original object and does not return a new one.
Parameters: | article – The article to refresh. |
---|
Share an article to the published feed.
Parameters: |
|
---|
Toggle the unread status of an article.
Parameters: | article_id – ID of the article to toggle. |
---|