A lightweight wrapper and CLI for the Hypothesis Web API v1.0.0. It includes all APIKey authorized endpoints related to * annotations (create / update / delete / search / fetch / flag), * groups (create / update / list / fetch / leave / members) * profile (user information / groups)
You'll need a Hypothesis account, and a personal API token obtained as described here.
Set the environment variables $HYPOTHESIS_NAME
and $HYPOTHESIS_KEY
to your username and the developer API key respectively.
bash
cargo install hypothesis
Run hypothesis --help
to see subcommands and options.
Generate shell completions:
bash
hypothesis complete zsh > .oh-my-zsh/completions/_hypothesis
exec zsh
Add to your Cargo.toml: ```toml [dependencies] hypothesis = {version = "0.3.0", default-features = false}
tokio = { version = "0.2", features = ["macros"] } ```
```rust use hypothesis::Hypothesis; use hypothesis::annotations::{AnnotationMaker, Target, Selector, TextQuoteSelector};
async fn main() -> coloreyre::Result<()> {
let api = Hypothesis::fromenv()?;
let newannotation = api.createannotation(
&AnnotationMaker {
uri: "https://www.example.com".toowned(),
text: "this is a comment".toowned(),
target: Target {
source: "https://www.example.com".toowned(),
selector: vec![Selector::newquote("exact text in website to highlight",
"prefix of text",
"suffix of text")],
},
tags: Some(vec!["tag1".tostring(), "tag2".tostring()]),
.. Default::default()
}
).await?;
Ok(())
}
``
Use bulk functions to perform multiple actions - e.g.
api.fetchannotationsinstead of a
loop around
api.fetchannotation`.
Check the documentation for more usage examples.
See the CHANGELOG
Target.selector.RangeSelector
doesn't seem to follow W3C standards. It's just a hashmap for now.Annotation
hypermedia links are stored as a hashmap, b/c I don't know all the possible values.Document
works to properly document it (hah).UserProfile.preferences
and UserProfile.features
mean.