A Rust API for Hypothesis
Description
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)
Installation and Usage
Authorization
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.
As a command-line utility:
Run hypothesis --help
to see subcommands and options.
NOTE: the CLI doesn't currently have all the capabilities of the Rust crate, specifically bulk actions and updating dates are not supported.
Generate shell completions:
As a Rust crate
Add to your Cargo.toml:
[]
= { = "0.4.0", = false}
= { = "0.2", = ["macros"] }
Examples
use Hypothesis;
use ;
async
See the documentation of the API struct (Hypothesis
) for a list of possible queries.
Use bulk functions to perform multiple actions - e.g. api.fetch_annotations
instead of a loop around api.fetch_annotation
.
Check the documentation for more usage examples.
Changelog
See the CHANGELOG
Contributing
Make sure you have a .env file (added to .gitignore) in the repo root with HYPOTHESIS_NAME, HYPOTHESIS_KEY, and TEST_GROUP_ID
Caveats / Todo:
- Only supports APIKey authorization and hypothes.is authority (i.e. single users).
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.- Need to figure out how
Document
works to properly document it (hah). - Can't delete a group after making it, can leave it though (maybe it's the same thing?)
- No idea what
UserProfile.preferences
andUserProfile.features
mean. - CLI just dumps output as JSON, this is fine right? Fancier CLIs can build on top of this (or use the crate directly)