Title: | Wrapper for the 'Hypothes.is' Web Annotation Service |
---|---|
Description: | Interact with the application programming interface for the web annotation service 'Hypothes.is' (See <http://hypothes.is> for more information.) Allows users to download data about public annotations, and create, retrieve, update, and delete their own annotations. |
Authors: | Matthew Lincoln [aut, cre] |
Maintainer: | Matthew Lincoln <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1.9000 |
Built: | 2024-11-03 02:48:35 UTC |
Source: | https://github.com/mdlincoln/hypothesisr |
Create annotations
hs_create(token, uri, user, permissions = list(read = "group:__world__", update = user, delete = user, admin = user), document = NULL, target = NULL, tags = NULL, text, custom = NULL)
hs_create(token, uri, user, permissions = list(read = "group:__world__", update = user, delete = user, admin = user), document = NULL, target = NULL, tags = NULL, text, custom = NULL)
token |
Character. Your account token, which you can generate at https://hypothes.is/register |
uri |
Character. The URI to be annotated. |
user |
Character. Your user account, normally in the format |
permissions |
A named list with read, update, delete, and admin permissions. Defaults to setting global read permissions ( |
document |
A list describing the document. CURRENTLY IGNORED. |
target |
A list describing the highlight position of the annotation. CURRENTLY IGNORED |
tags |
Character. (optional) Tags to apply to the annotation. |
text |
Character. Text to put in the body of the annotation. This will be coerced into a character vector of length 1 using paste. |
custom |
Add arbitrary fields to the JSON object submitted to hypothes.is by means of a named list. |
Upon successful creation, returns a 22-character annotation ID. This ID may be retrieved using hs_read.
https://h.readthedocs.io/en/latest/api/#create
## Not run: hs_create(token = user_token, uri = "https://github.com/mdlincoln/hypothesisr", user = "acct:[email protected]", tags = c("testing", "R"), text = "R made me!") ## End(Not run)
## Not run: hs_create(token = user_token, uri = "https://github.com/mdlincoln/hypothesisr", user = "acct:[email protected]", tags = c("testing", "R"), text = "R made me!") ## End(Not run)
Delete an annotation
hs_delete(token, id)
hs_delete(token, id)
token |
Character. Your account token, which you can generate at https://hypothes.is/register |
id |
Character. A hypothes.is annotation id. |
TRUE on successful deletion.
https://h.readthedocs.io/en/latest/api/#delete
Retrieve a single annotation by ID
hs_read(id)
hs_read(id)
id |
Character. A hypothes.is annotation id. |
A dataframe with the contents of that annotation.
https://h.readthedocs.io/en/latest/api/#read
hs_read("WFMnSC3FEeaNvLeGkQeJbg")
hs_read("WFMnSC3FEeaNvLeGkQeJbg")
This is a utility wrapper around hs_create that takes an original comment ID and creates a reply to it by adding the custom references
field when constructing the annotation. Normal fields like
hs_reply(token, user, id, text, ...)
hs_reply(token, user, id, text, ...)
token |
Character. Your account token, which you can generate at https://hypothes.is/register |
user |
Character. Your user account, normally in the format |
id |
Character. The annotation ID to reply to. |
text |
Character. Text to put in the body of the annotation. This will be coerced into a character vector of length 1 using paste. |
... |
Other arguments to pass to hs_create. |
Search hypothes.is annotations.
hs_search(limit = NULL, offset = NULL, sort = "updated", order = "asc", uri = NULL, user = NULL, text = NULL, any = NULL, custom = list())
hs_search(limit = NULL, offset = NULL, sort = "updated", order = "asc", uri = NULL, user = NULL, text = NULL, any = NULL, custom = list())
limit |
Integer. The maximum number of annotations to return. (Default: 20) |
offset |
Integer The minimum number of initial annotations to skip. This is used for pagination. For example if there are 65 annotations matching our search query and we're retrieving up to 30 annotations at a time, then to retrieve the last 5, set offset = 5. (Default = 0) |
sort |
Character. Specify which field the annotations should be sorted
by: |
order |
Character. Specify which order annotations should be sorted by:
|
uri |
Character. Search for annotations of a particular URI, for example
|
user |
Character. Search for annotations by a particular user. For
example, |
text |
Character. Search for annotations whose body text contains some
text, for example: |
any |
Character. Search for annotations whose |
custom |
A named list of any field in the results returned by hypothes.is as a name, and the search text as values. |
A dataframe with annotation data.
If any vectors are passed to these arguments, only the first values will be used.
https://h.readthedocs.io/en/latest/api/#search
# Search for no more than 5 annotations containing the text "ulysses" hs_search(text = "ulysses", limit = 5) # Search with a custom field for tags hs_search(custom = list(tags = "todo")) # use the 'uri.parts' field to find annotations on a given domain (exclude # the TLD, as this will result in all annotations on sites with, e.g., .org, # as well.) hs_search(custom = list(uri.parts = "programminghistorian"))
# Search for no more than 5 annotations containing the text "ulysses" hs_search(text = "ulysses", limit = 5) # Search with a custom field for tags hs_search(custom = list(tags = "todo")) # use the 'uri.parts' field to find annotations on a given domain (exclude # the TLD, as this will result in all annotations on sites with, e.g., .org, # as well.) hs_search(custom = list(uri.parts = "programminghistorian"))
Takes the same arguments as hs_search and pages through all available results, formatting the output as a data.frame.
hs_search_all(sort = "updated", order = "asc", uri = NULL, user = NULL, text = NULL, any = NULL, custom = list(), pagesize = 200, progress = interactive())
hs_search_all(sort = "updated", order = "asc", uri = NULL, user = NULL, text = NULL, any = NULL, custom = list(), pagesize = 200, progress = interactive())
sort |
Character. Specify which field the annotations should be sorted
by: |
order |
Character. Specify which order annotations should be sorted by:
|
uri |
Character. Search for annotations of a particular URI, for example
|
user |
Character. Search for annotations by a particular user. For
example, |
text |
Character. Search for annotations whose body text contains some
text, for example: |
any |
Character. Search for annotations whose |
custom |
A named list of any field in the results returned by hypothes.is as a name, and the search text as values. |
pagesize |
Integer. How many annotations to retrieve per query. Between 1 and 200. (Default: 200) |
progress |
Boolean. Should a progress bar be displayed during download? |
A dataframe with annotation data.
## Not run: hs_search_all(text = "arxiv") ## End(Not run)
## Not run: hs_search_all(text = "arxiv") ## End(Not run)
Update annotations
hs_update(token, id, uri = NULL, user = NULL, permissions = NULL, document = NULL, target = NULL, tags = NULL, text = NULL, custom = NULL)
hs_update(token, id, uri = NULL, user = NULL, permissions = NULL, document = NULL, target = NULL, tags = NULL, text = NULL, custom = NULL)
token |
Character. Your account token, which you can generate at https://hypothes.is/register. |
id |
Character. A hypothes.is annotation id. |
uri |
Character. The URI to be annotated. |
user |
Character. Your user account, normally in the format |
permissions |
A named list with read, update, delete, and admin permissions. Defaults to setting global read permissions ( |
document |
A list describing the document. CURRENTLY IGNORED. |
target |
A list describing the highlight position of the annotation. CURRENTLY IGNORED |
tags |
Character. (optional) Tags to apply to the annotation. |
text |
Character. Text to put in the body of the annotation. This will be coerced into a character vector of length 1 using paste. |
custom |
Add arbitrary fields to the JSON object submitted to hypothes.is by means of a named list. |
TRUE on successful update.
https://h.readthedocs.io/en/latest/api/#update
## Not run: hs_update(user_token, "lDf9rC3EEea6ck-G5kLdXA", text = "Now even more annotate-y!") ## End(Not run)
## Not run: hs_update(user_token, "lDf9rC3EEea6ck-G5kLdXA", text = "Now even more annotate-y!") ## End(Not run)
Interact with the API for the web annotation service hypothes.is. Allows users to add, search for, and retrieve annotation data.
Functions for opening an annotation in the system browser
open_context(id) open_annotation(id) open_uri(id)
open_context(id) open_annotation(id) open_uri(id)
id |
Annotation ID. |
open_context
: Open an annotation in context, displaying the original webpage with an annotation overlay
open_annotation
: Open an annotation on the hypothes.is webpage
open_uri
: Open the original webpage to which the annotation links