Title: | Get information from 'pinboard.in' API |
---|---|
Description: | Full connectivity to the 'pinboard.in' service. Retrieve bookmarks, add new ones. Add, delete and rename tags, all from the convenience of your R session. |
Authors: | Roel M. Hogervorst [aut, cre] |
Maintainer: | Roel M. Hogervorst <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-11-04 19:53:39 UTC |
Source: | https://github.com/RMHogervorst/pinboardr |
All interactions with the 'pinboard.in' API (application programming interface) require authentication. This doc explains where to find your secrets and how to set up your computer so you can programmaticaly interact with pinboard.
You do need to have a pinboard account.
Go to the pinboard password page
and scroll down to API Token.
It says something like: "this is your API token:
username:NUMBERSANDLETTERS
I would recommend you add the token to your .renviron file, either locally or
globally. A full introduction how these files work is beyond the scope
of this doc but if you create a 'hidden' file named .Renviron in the project folder
or in your home folder, R will read in the username and token and they will
be available to pinboardr.
Use usethis::edit_r_environ()
or find the file manually.
Add to your .renviron file the following
PB_USERNAME=username
PB_TOKEN="NUMBERSANDLETTERS"
Restart the session to make the changes active.
This is not the recommended approach, but will work nevertheless. You can either:
set the variables at the start of your session using Sys.setenv(PB_USERNAME = "username", PB_TOKEN="NUMBERSANDLETTERS")
pass the username and token to every command: pb_last_update(username=username, token=NUMBERSANDLETTERS)
This means your secrets, username and token are visible in your .rhistory, and if you save it in a script, it will be visible to anyone who opens your script. I think you don't want that, but my threatmodel is not your threatmodel.
Convenience function to make working with the dataframe of bookmarks a bit easier.
pb_add_tag_column(dataframe, tag)
pb_add_tag_column(dataframe, tag)
dataframe |
the dataframe of bookmarks |
tag |
tag you would like to extract into a new column |
a dataframe with one extra column, containing TRUE or FALSE for presence of the tag
## Not run: pb_add_tag_column(all_bookmars, "europe") ## End(Not run)
## Not run: pb_add_tag_column(all_bookmars, "europe") ## End(Not run)
Get one specific note
pb_get_note(id = NULL, username = NULL, token = NULL)
pb_get_note(id = NULL, username = NULL, token = NULL)
id |
the id of a note |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
a list containing id, title, created_at, updated_at, length, text and hash
## Not run: pb_get_note(id=12345) ## End(Not run)
## Not run: pb_get_note(id=12345) ## End(Not run)
Return a data.frame of notes meta information, id, hash, title, length, created_at and updated_at. When you know the id, you can use the other endpoint pb_get_note
pb_get_notes_overview(username = NULL, token = NULL)
pb_get_notes_overview(username = NULL, token = NULL)
username |
your username You probably don't need to supply this every time. See |
token |
your token |
a data.frame with notes meta information
## Not run: pb_get_notes_overview() ## End(Not run)
## Not run: pb_get_notes_overview() ## End(Not run)
Returns the most recent time a bookmark was added, updated or deleted. Use this before calling posts_all to see if the data has changed since the last fetch.
pb_last_update(as_datetime = FALSE, username = NULL, token = NULL)
pb_last_update(as_datetime = FALSE, username = NULL, token = NULL)
as_datetime |
defaults to FALSE, if TRUE will turn the text value into "POSIXlt" "POSIXt" |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
time in text format or as "POSIXlt" "POSIXt"
## Not run: pb_last_update(as_datetime = TRUE) pb_last_update() ## End(Not run)
## Not run: pb_last_update(as_datetime = TRUE) pb_last_update() ## End(Not run)
You must give a url and description, all other arguments are optional.
pb_posts_add( url, title, description = NULL, tags = NULL, dt = NULL, replace = NULL, public = NULL, toread = NULL, username = NULL, token = NULL )
pb_posts_add( url, title, description = NULL, tags = NULL, dt = NULL, replace = NULL, public = NULL, toread = NULL, username = NULL, token = NULL )
url |
REQUIRED the URL of the item |
title |
REQUIRED Title of the item. |
description |
Description of the item |
tags |
vector of up to 100 tags |
dt |
creation time for this bookmark. Defaults to current time. Datestamps more than 10 minutes ahead of server time will be reset to current server time (UTC timestamp in this format: 2010-12-11T19:48:02Z) |
replace |
Replace any existing bookmark with this URL. Default is TRUE If set to FALSE, will throw an error if bookmark exists |
public |
TRUE/FALSE Make bookmark public. Default is "TRUE" unless user has enabled the "save all bookmarks as private" user setting, in which case default is "no" |
toread |
TRUE/FALSE Marks the bookmark as unread. Default is "FALSE" |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
status in text 'done'
## Not run: pb_posts_add(url="https://example.com", title="an example website") ## End(Not run)
## Not run: pb_posts_add(url="https://example.com", title="an example website") ## End(Not run)
This API endpoint is rate limited to once every 5 minutes.
pb_posts_all( tags = NULL, start = 0L, results = NULL, fromdt = NULL, todt = NULL, meta = NULL, username = NULL, token = NULL )
pb_posts_all( tags = NULL, start = 0L, results = NULL, fromdt = NULL, todt = NULL, meta = NULL, username = NULL, token = NULL )
tags |
filter by up to three tags |
start |
int offset value (default is 0) |
results |
int number of results to return. Default is all |
fromdt |
datetime return only bookmarks created after this time |
todt |
datetime return only bookmarks created before this time |
meta |
int include a change detection signature for each bookmark |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
a dataframe of all posts of pinboard format see ?pinboard_formatting
## Not run: pb_posts_all(tags = "inspiration", results = 15) ## End(Not run)
## Not run: pb_posts_all(tags = "inspiration", results = 15) ## End(Not run)
Returns a dataframe of dates with the number of posts at each date. Use this to see all posts per date or posts per tag per date.
pb_posts_dates(tags = NULL, username = NULL, token = NULL)
pb_posts_dates(tags = NULL, username = NULL, token = NULL)
tags |
filter by up to three tags |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
a data.frame with dates and counts
## Not run: pb_posts_dates(tags = "europe") ## End(Not run)
## Not run: pb_posts_dates(tags = "europe") ## End(Not run)
Delete a bookmark from pinboard by url.
pb_posts_delete(url = NULL, username = NULL, token = NULL)
pb_posts_delete(url = NULL, username = NULL, token = NULL)
url |
REQUIRED url of bookmark to delete |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
status in text: "done", "item not found"
## Not run: pb_posts_delete("https://example.com") ## End(Not run)
## Not run: pb_posts_delete("https://example.com") ## End(Not run)
Returns one or more posts on a single day matching the arguments. If no date or url is given, date of most recent bookmark will be used.
pb_posts_get( tags = NULL, dt = NULL, url = NULL, meta = NULL, username = NULL, token = NULL )
pb_posts_get( tags = NULL, dt = NULL, url = NULL, meta = NULL, username = NULL, token = NULL )
tags |
filter by up to three tags |
dt |
return results bookmarked on this day (UTC date in this format: 2010-12-31). |
url |
return bookmark for this URL |
meta |
TRUE/FALSE include a change detection signature in a meta attribute |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
a dataframe of all posts of pinboard format see ?pinboard_formatting
## Not run: pb_posts_get() ## End(Not run)
## Not run: pb_posts_get() ## End(Not run)
Returns a list of the user's most recent posts, filtered by tag.
pb_posts_recent(tags = NULL, count = 15, username = NULL, token = NULL)
pb_posts_recent(tags = NULL, count = 15, username = NULL, token = NULL)
tags |
tags filter by up to three tags |
count |
number of results to return default is 15 max is 100 |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
a dataframe of all recent of pinboard format see ?pinboard_formatting
## Not run: pb_posts_recent(tags = "inspiration") ## End(Not run)
## Not run: pb_posts_recent(tags = "inspiration") ## End(Not run)
Popular tags are tags used site-wide for the url; recommended tags are drawn from the user's own tags.
pb_posts_suggest(url = NULL, username = NULL, token = NULL)
pb_posts_suggest(url = NULL, username = NULL, token = NULL)
url |
REQUIRED url to get suggestions for |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
a data.frame with popular and recommended tags
## Not run: pb_posts_suggest(url = "https://example.com") ## End(Not run)
## Not run: pb_posts_suggest(url = "https://example.com") ## End(Not run)
Notice that 'pinboard.in' does not tell you if a tag exists or not. It will return a 'done' unless something else goes wrong.
pb_tags_delete(tag, username = NULL, token = NULL)
pb_tags_delete(tag, username = NULL, token = NULL)
tag |
REQUIRED tag the delete |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
text confirmation
## Not run: pb_tags_delete(tag = "svg") ## End(Not run)
## Not run: pb_tags_delete(tag = "svg") ## End(Not run)
Find all tags in use.
pb_tags_get(username = NULL, token = NULL)
pb_tags_get(username = NULL, token = NULL)
username |
your username You probably don't need to supply this every time. See |
token |
your token |
a dataframe with all tags and their count
## Not run: pb_get_all_tags() ## End(Not run)
## Not run: pb_get_all_tags() ## End(Not run)
Change the name of a tag. Notice that 'pinboard.in' does not tell you if a tag exists or not. It will return a 'done' unless something else goes wrong.
pb_tags_rename(old, new = NULL, username = NULL, token = NULL)
pb_tags_rename(old, new = NULL, username = NULL, token = NULL)
old |
REQUIRED old tag name |
new |
REQUIRED new tag name, if empty nothing will happen |
username |
your username You probably don't need to supply this every time. See |
token |
your token |
text confirmation
## Not run: pb_tags_rename(old = "svg", new = "illustrations") ## End(Not run)
## Not run: pb_tags_rename(old = "svg", new = "illustrations") ## End(Not run)
This is a silly endpoint and function, but I implemented it anyways. To reach this endpoint, you already are in possession of your token. And I will not implement a username and password authentication because that is inherently unsafe in this API. Be safe people!
pb_user_api_token(username = NULL, token = NULL)
pb_user_api_token(username = NULL, token = NULL)
username |
your username You probably don't need to supply this every time. See |
token |
your token |
token in string format
## Not run: pb_user_api_token() ## End(Not run)
## Not run: pb_user_api_token() ## End(Not run)
Get your secret RSS key for private feeds.
pb_user_secret(username = NULL, token = NULL)
pb_user_secret(username = NULL, token = NULL)
username |
your username You probably don't need to supply this every time. See |
token |
your token |
the secret RSS key
## Not run: pb_user_secret() ## End(Not run)
## Not run: pb_user_secret() ## End(Not run)
The pinboardr package returns the data in a format as close as possible to the data supplied by the API. Because 'pinboard.in' modeled their API on the original 'Delicious API' with the same unfortunate choices. See also the description on pinboard posts_add docs.
I try to hide the complexity from you by translating but sometimes that gives us different names. I first give you the pinboardr name and than the name in the delicious and pinboard API:
The 'title' of a bookmark is actually called 'description'.
The 'description' of a bookmark is actually called 'extended'.
The 'public' setting of bookmarks is called 'shared'.