Skip to main content

A Python wrapper for

Project description

|image0| |image1|

|CI Status| |Version| |Versions| is an easy-to-use and fully-functional Python wrapper and
`command-line utility <>`__ for the API.

------------ is available for download through the Python Package Index
(PyPi). You can install it right away using pip or easy_install.

If you’re using Python 3 or above:

.. code:: bash

pip install "pinboard>=2.0"

For Python 2.7:

.. code:: bash

pip install "pinboard>=1.0,<2.0"


To get started, you’re going to need to get your Pinboard API token from
the `password page <>`__ on the
Pinboard website. Once you’ve got that, you’re ready to go.

.. code:: pycon

>>> import pinboard
>>> pb = pinboard.Pinboard(api_token)

Once you’ve done this, you can now use the ``pb`` object to make calls
to the Pinboard API. Here are some examples:


Returns the most recent time a bookmark was added, updated or deleted.

.. code:: pycon

>>> pb.posts.update()
datetime.datetime(2014, 7, 27, 18, 11, 29)


Add a bookmark:

.. code:: pycon

>>> pb.posts.add(url="", description="A Great Search Engine", \
extended="This is a description!", tags=["search", "tools"], shared=True, \

Update a bookmark:

.. code:: pycon

# First, retrieve the bookmark you'd like to edit
>>> bookmark = pb.posts.get(url='')['posts'][0]
>>> bookmark
<Bookmark description="A Great Search Engine" url="">

# You can now change description, extended, shared, toread, tags, or time directly with the bookmark object.
>>> bookmark.description = "Google is pretty awesome"
>>> bookmark.tags = ["search", "searching"]

# If you want to update the bookmark creation date as well, you'll need to pass in `update_time=True` to the save method
>>> import datetime
>>> bookmark.time = - datetime.timedelta(days=5)

Delete a bookmark:

.. code:: pycon

>>> pb.posts.delete(url="")

Get one or more posts on a single day matching the parameters:

.. code:: pycon

>>> pb.posts.get(url="")
{u'date': datetime.datetime(2014, 7, 25, 16, 35, 25),
u'posts': [<Bookmark description="A Great Search Engine" url="">],
u'user': u'dlo'}

>>> import datetime
>>> pb.posts.get(
{u'date': datetime.datetime(2014, 7, 25, 16, 35, 25),
u'posts': [<Bookmark description="A Great Search Engine" url="">,
<Bookmark description="Smooth Scrolling | CSS-Tricks" url="">,
<Bookmark description="Apple "Frustrated" that "People Don't Want to Pay Anything" on Mobile, Says 'The Banner Saga' Developer | Touch Arcade" url="">],
u'user': u'dlo'}

Return all recent bookmarks (optionally filtering by tag):

.. code:: pycon

>>> pb.posts.recent(tag=["programming", "python"])
{u'date': datetime.datetime(2014, 4, 28, 2, 7, 58),
u'posts': [<Bookmark description="itunesfs : Python Package Index" url="">,
<Bookmark description="mincss "Clears the junk out of your CSS" -" url="">,
<Bookmark description="Braintree Test Credit Card Account Numbers" url="">,
<Bookmark description="Valued Lessons: Monads in Python (with nice syntax!)" url="">,
<Bookmark description="Paste #EGY1XPQxQ2UPuT91SH83 at spacepaste" url="">,
<Bookmark description="40 Random Letters and Numbers" url="">,
<Bookmark description="PEP 3156 -- Asynchronous IO Support Rebooted" url="">,
<Bookmark description="Brython" url="">,
<Bookmark description="Django REST framework" url="">,
<Bookmark description="mypy - A New Python Variant with Dynamic and Static Typing" url="">,
<Bookmark description="Julython 2012" url="">,
<Bookmark description="Stripe Blog: Exploring Python Using GDB" url="">,
<Bookmark description="Python FAQ: Descriptors - fuzzy notepad" url="">,
<Bookmark description="A Guide to Python's Magic Methods «" url="">,
<Bookmark description="Melopy" url="">,
<Bookmark description="litl/rauth" url="">],
u'user': u'dlo'}

Return a list of dates with the number of posts at each date:

.. code:: pycon

>>> pb.posts.dates(tag=["programming", "python"])
{u'dates': {, 12, 5): 1,, 12, 6): 1,
..., 7, 24): 6,, 7, 25): 4},
u'tag': u'programming+python',
u'user': u'dlo'}

Get all bookmarks in your account:

.. code:: pycon

>>> pb.posts.all()
[<Bookmark description="Of Princesses and Dragons" url="">
<Bookmark description="A Great Search Engine" url="">,
<Bookmark description="Runner Econ 101 - StimHa" url="">,
<Bookmark description="서인국, 탄탄 근육+ 태평양 어깨…어부바 부른다 : 네이" url="">]

You can also filter by tag, start, results, fromdt, or todt.

.. code:: pycon

>>> import datetime
>>> five_days_ago = - datetime.timedelta(days=5)
>>> pb.posts.all(tag=["programming"], start=10, results=100, fromdt=five_days_ago)
[<Bookmark description="Of Princesses and Dragons" url="">
<Bookmark description="A Great Search Engine" url="">,
<Bookmark description="Runner Econ 101 - StimHa" url="">,
<Bookmark description="서인국, 탄탄 근육+ 태평양 어깨…어부바 부른다 : 네이" url="">]


Suggest tags for a given URL:

.. code:: pycon

>>> pb.posts.suggest(url="")
[{u'popular': [u'pinboard']},
{u'recommended': [u'bookmark',

Return all tags in your account along with the number of times they were

.. code:: pycon

>>> pb.tags.get()
[<Tag name="absurd" count=1>,
<Tag name="accessibility" count=2>,
<Tag name="accounting" count=3>,
<Tag name="zen" count=1>,
<Tag name="zsh" count=1>,
<Tag name="zynga" count=1>]

Delete a tag:

.. code:: pycon

>>> pb.tags.delete(tag="zynga")

Rename a tag:

.. code:: pycon

>>> pb.tags.rename(old='ppython', new='python')


By default, will return parsed JSON objects. If you’d like
the raw response object for a request, just pass in

.. code:: pycon

>>> response = pb.tags.get(parse_response=False)
>>> response
<addinfourl at 4396047680 whose fp = <socket._fileobject object at 0x105f79850>>
... your tags ... maps 1-1 to the Pinboard API (e.g., will
send a request to “”). For more
information on other methods and usage, please read the `Pinboard API
documentation <>`__.

One more note–you might have noticed that there is no “title” attribute
for bookmarks. This has been done since the Pinboard API calls titles
“descriptions” and descriptions “extended” (and this was done to stay
consistent with the Delicious API, way back in the day). In order to
keep things minimally confusing, this library sticks to how Pinboard
names these fields. Just remember–“description” means “title” and
“extended” means “description”.

Command Line

In addition to providing full Python-level support for the Pinboard API, also comes bundled with a handy command-line utility called
“pinboard”. Just type “pinboard -h” for a full list of supported
commands. Your API token needs to be available to, and can
be entered in several ways. Firstly will try to read the
~/.pinboardrc configuration file. If not present then it will try to
read an environment variable called ``PINBOARD_TOKEN``. Lastly it will
show a shell prompt for the user to enter their token (you can
immediately force the latter behavior by typing ``pinboard login``).

All of the commands pre-process and indent the JSON output. If you would
like to shoot the raw response data to stdout, just pass “–raw” before
the subcommand (e.g., “pinboard –raw bookmarks”).


.. code:: sh

$ pinboard login
Enter your Pinboard API token: username:XXXXX
Saved Pinboard credentials to ~/.pinboardrc
$ pinboard suggest-tags --url
"popular": [
"recommended": [
$ pinboard get --date 7-13-2014
"date": "2014-07-13T03:03:58Z",
"posts": [
"extended": "",
"hash": "e2311835eb0de6bff2595a9b1525bb98",
"description": "Python 2.7.x and Python 3.x key differences",
"tags": "python",
"href": "",
"meta": "561d1f53791a8c50109393411f0301fc",
"time": "2014-07-13T03:03:58Z",
"shared": "yes",
"toread": "no"
"extended": "",
"hash": "4abe28f70154bd35f84be73cec0c53ef",
"description": "Miami, the great world city, is drowning while the powers that be look away | World news | The Observer",
"tags": "",
"href": "",
"meta": "2ca547789553ba9d3202a5cd3d367685",
"time": "2014-07-13T02:53:54Z",
"shared": "yes",
"toread": "yes"
"user": "dlo"
$ pinboard --raw get --date 7/13/2014
{"date":"2014-07-13T03:03:58Z","user":"dlo","posts":[{"href":"http:\/\/\/Articles\/2014_python_2_3_key_diff.html","description":"Python 2.7.x and Python 3.x key differences","extended":"","meta":"561d1f53791a8c50109393411f0301fc","hash":"e2311835eb0de6bff2595a9b1525bb98","time":"2014-07-13T03:03:58Z","shared":"yes","toread":"no","tags":"python"},{"href":"http:\/\/\/world\/2014\/jul\/11\/miami-drowning-climate-change-deniers-sea-levels-rising","description":"Miami, the great world city, is drowning while the powers that be look away | World news | The Observer","extended":"","meta":"2ca547789553ba9d3202a5cd3d367685","hash":"4abe28f70154bd35f84be73cec0c53ef","time":"2014-07-13T02:53:54Z","shared":"yes","toread":"yes","tags":""}]}

You can print a full list of pinboard commands by passing the “-h” flag.

.. code:: sh

$ pinboard -h
usage: pinboard [-h] [--raw]


positional arguments:
add posts/add
delete posts/delete
get posts/get
recent posts/recent
dates posts/dates
bookmarks posts/all
suggest-tags posts/suggest
tags tags/get
delete-tag tags/delete
rename-tag tags/rename
notes notes/list
note notes/ID
rss-key user/secret
api-token user/api_token

optional arguments:
-h, --help show this help message and exit
--raw Print the raw data from the Pinboard API without any

…or help for a specific subcommand by passing the subcommand and then
the “-h” flag.

.. code:: sh

$ pinboard bookmarks -h
usage: pinboard bookmarks [-h] [--from_date FROM_DATE] [--to_date TO_DATE]
[--tags TAGS [TAGS ...]] [--count COUNT]
[--offset OFFSET]

optional arguments:
-h, --help show this help message and exit
--from_date FROM_DATE
--to_date TO_DATE
--tags TAGS [TAGS ...]
--count COUNT
--offset OFFSET

Using the CLI in Docker

To build the CLI in Docker:

.. code:: sh

$ cd <>/bin
$ docker build -t pinboard .

To run the CLI in Docker after building:

.. code:: sh

$ export PINBOARD_TOKEN=<>
$ docker run -ti -e PINBOARD_TOKEN pinboard bookmarks --count 10


If you like this library, you might want to check out `Pushpin for
Pinboard <>`__.

.. _license-licenselicense-imagelicense-url:

License |License|

Apache License, Version 2.0. See `LICENSE <>`__ for details.

.. raw:: html

<!-- -->

.. |image0| image:: meta/repo-banner.png
.. |image1| image:: meta/repo-banner-bottom.png
.. |CI Status| image::
.. |Version| image::
.. |Versions| image::
.. |License| image::

Project details

Download files

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

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

pinboard-2.1.8-py2.py3-none-any.whl (14.0 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page