Welcome to PyInstapaper’s documentation!¶
PyInstapaper¶
Instapaper is a tool for saving web pages to read later, e.g. offline on a mobile device. PyInstapaper is a Python wrapper for the full Instapaper API.
To use it, in addition to your Instapaper account username and password, you’ll need to request API credentials from Instapaper.
Usage¶
from pyinstapaper.instapaper import Instapaper, Folder
INSTAPAPER_KEY = 'MY_INSTAPAPER_API_KEY'
INSTAPAPER_SECRET = 'MY_INSTAPAPER_API_SECRET'
INSTAPAPER_LOGIN = 'me@example.com'
INSTAPAPER_PASSWORD = 'p@ssw0rd'
instapaper = Instapaper(INSTAPAPER_KEY, INSTAPAPER_SECRET)
instapaper.login(INSTAPAPER_LOGIN, INSTAPAPER_PASSWORD)
# Get the 10 latest instapaper bookmarks for the given account and do
# something with the article text
bookmarks = instapaper.get_bookmarks('starred')
for bookmark in enumerate(bookmarks):
do_something(bookmark.get_text())
bookmark.archive()
# Create a new folder
folder = Folder(instapaper, title='cool stuff')
result = folder.add()
Additional info¶
- Free software: MIT License
- Documentation: https://pyinstapaper.readthedocs.org.
- Boilerplate courtesy of cookiecutter: https://github.com/audreyr/cookiecutter
- Thanks to Ryan Galloway for pointing the way to using the Python oauth2 library for Instapaper’s XAuth implementation, though ideally pyinstapaper would use requests-oauthlib
Installation¶
Stable release¶
To install PyInstapaper, run this command in your terminal:
$ pip install pyinstapaper
This is the preferred method to install PyInstapaper, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for PyInstapaper can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/mdorn/pyinstapaper
Or download the tarball:
$ curl -OL https://github.com/mdorn/pyinstapaper/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
pyinstapaper¶
pyinstapaper package¶
Submodules¶
pyinstapaper.instapaper module¶
-
class
pyinstapaper.instapaper.
Bookmark
(client, **data)[source]¶ Bases:
pyinstapaper.instapaper.InstapaperObject
Object representing an Instapaper bookmark/article.
-
ATTRIBUTES
= ['bookmark_id', 'title', 'description', 'hash', 'url', 'progress_timestamp', 'time', 'progress', 'starred', 'type', 'private_source']¶
-
RESOURCE
= 'bookmarks'¶
-
RESOURCE_ID_ATTRIBUTE
= 'bookmark_id'¶
-
SIMPLE_ACTIONS
= ['delete', 'star', 'archive', 'unarchive', 'get_text']¶
-
TIMESTAMP_ATTRS
= ['progress_timestamp', 'time']¶
-
-
class
pyinstapaper.instapaper.
Folder
(client, **data)[source]¶ Bases:
pyinstapaper.instapaper.InstapaperObject
Object representing an Instapaper folder.
-
ATTRIBUTES
= ['folder_id', 'title', 'display_title', 'sync_to_mobile', 'folder_id', 'position', 'type', 'slug']¶
-
RESOURCE
= 'folders'¶
-
RESOURCE_ID_ATTRIBUTE
= 'folder_id'¶
-
SIMPLE_ACTIONS
= ['delete']¶
-
-
class
pyinstapaper.instapaper.
Highlight
(client, **data)[source]¶ Bases:
pyinstapaper.instapaper.InstapaperObject
Object representing an Instapaper highlight.
-
ATTRIBUTES
= ['highlight_id', 'text', 'note', 'time', 'position', 'bookmark_id', 'type', 'slug']¶
-
RESOURCE
= 'highlights'¶
-
RESOURCE_ID_ATTRIBUTE
= 'highlight_id'¶
-
SIMPLE_ACTIONS
= ['delete']¶
-
TIMESTAMP_ATTRS
= ['time']¶
-
-
class
pyinstapaper.instapaper.
Instapaper
(oauth_key, oauth_secret)[source]¶ Bases:
object
Instapaper client class.
Parameters: - str (oauth_secret) – Instapaper OAuth consumer key
- str – Instapaper OAuth consumer secret
-
get_bookmarks
(folder='unread', limit=25, have=None)[source]¶ Return list of user’s bookmarks.
Parameters: - folder (str) – Optional. Possible values are unread (default), starred, archive, or a folder_id value.
- limit (int) – Optional. A number between 1 and 500, default 25.
- have (list) – Optional. A list of IDs to exclude from results
Returns: List of user’s bookmarks
Return type: list
-
login
(username, password)[source]¶ Authenticate using XAuth variant of OAuth.
Parameters: - username (str) – Username or email address for the relevant account
- password (str) – Password for the account
-
request
(path, params=None, returns_json=True, method='POST', api_version='1')[source]¶ Process a request using the OAuth client’s request method.
Parameters: - path (str) – Path fragment to the API endpoint, e.g. “resource/ID”
- params (dict) – Parameters to pass to request
- method (str) – Optional HTTP method, normally POST for Instapaper
- api_version (str) – Optional alternative API version
Returns: response headers and body
Retval: dict
Module contents¶
Top-level package for PyInstapaper.
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/mdorn/pyinstapaper/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
PyInstapaper could always use more documentation, whether as part of the official PyInstapaper docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/mdorn/pyinstapaper/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up pyinstapaper for local development.
Fork the pyinstapaper repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/pyinstapaper.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv pyinstapaper $ cd pyinstapaper/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 pyinstapaper tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check https://travis-ci.org/mdorn/pyinstapaper/pull_requests and make sure that the tests pass for all supported Python versions.
Deploying¶
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
Travis will then deploy to PyPI if tests pass.
Credits¶
Development Lead¶
- Matt Dorn <mdorn@textmethod.com>
Contributors¶
None yet. Why not be the first?