Export your personal Pocket data, including highlights as JSON.
pip3 install --user -r requirements.txt
- To use the API you need a
consumer_key
. You’ve got two alternatives here:- Lawful good way: register an app here with ‘Retrieve’ permissions and type ‘Desktop (other)’.
Open app in the list and take note of
consumer_key
. - Chaotic way: get API key directly from web app.
The benefit of doing this is that API gives away more data, including highlights.
To do that, go to Pocket web app, open Network Monitor from your browser dev tools (e.g. firefox), and refresh the page.
You can find
consumer_key
in ‘Request URL’ for any ofjson
requests.If you still struggle with these steps, I recommend a comprehensive tutorial.
This is sort of hacky, but only way I know of extracting highlights. I tried registering apps targeting other platforms (e.g. web/extension), but still nothing, seems that Pocket’s consumer key is hardcoded in backend code or something.
- Lawful good way: register an app here with ‘Retrieve’ permissions and type ‘Desktop (other)’.
Open app in the list and take note of
- Follow these instructions to retrieve an API token using
consumer_key
you got on the previous step.You can use anything as
redirect_uri
, e.g.https://example.com
. You should getaccess_token
after that.You only need to do this step once, after that you can use
access_token
straightaway.
Usage:
Recommended: create secrets.py
keeping your api parameters, e.g.:
consumer_key = "CONSUMER_KEY" access_token = "ACCESS_TOKEN"
After that, use:
./export.py --secrets /path/to/secrets.py
That way you type less and have control over where you keep your plaintext tokens/passwords.
Alternatively, you can pass parameters directly, e.g.
./export.py --consumer_key <consumer_key> --access_token <access_token>
However, this is verbose and prone to leaking your keys in shell history.
You can also import export.py
this as a module and call get_json
function directly to get raw JSON.
I’m not aware of any limits on number of old entries you can retrieve through API; it doesn’t even have pagination. If you know of them, please let me know or open PR!
I highly recommend to back up regularly and keep old exports. Easy way to achieve it is command like this:
./export.py --secrets /path/to/secrets.py >"export-$(date -I).json"
Or, you can use arctee that automates this.
See ./example-output.json, it’s got some example data you might find in your data export.
You can use dal.py
(stands for “Data Access/Abstraction Layer”) to access your exported data, even offline.
I elaborate on motivation behind it here.
- main usecase is to be imported as python module to allow for programmatic access to your data.
You can find some inspiration in =my.= package that I’m using as an API to all my personal data.
- to test it against your export, simply run:
./dal.py --source /path/to/export
- you can also try it interactively:
./dal.py --source /path/to/export --interactive