Crates.io Docs.rs CI GitHub release dependency status

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:

bash cargo install hypothesis 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: bash hypothesis complete zsh > .oh-my-zsh/completions/_hypothesis exec zsh

As a Rust crate

Add to your Cargo.toml: toml [dependencies] hypothesis = {version = "0.4.0", default-features = false} tokio = { version = "0.2", features = ["macros"] }

Examples

```rust no_run use hypothesis::Hypothesis; use hypothesis::annotations::{InputAnnotation, Target, Selector};

[tokio::main]

async fn main() -> Result<(), hypothesis::errors::HypothesisError> { let api = Hypothesis::fromenv()?; let newannotation = InputAnnotation::builder() .uri("https://www.example.com") .text("this is a comment") .target(Target::builder() .source("https://www.example.com") .selector(vec![Selector::newquote("exact text in website to highlight", "prefix of text", "suffix of text")]) .build()?) .tags(vec!["tag1".tostring(), "tag2".tostring()]) .build()?; api.createannotation(&newannotation).await?; Ok(()) } `` See the documentation of the API struct ([Hypothesis](https://docs.rs/crate/hypothesis/struct.Hypothesis.html)) for a list of possible queries. Use bulk functions to perform multiple actions - e.g.api.fetchannotationsinstead of a loop aroundapi.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 HYPOTHESISNAME, HYPOTHESISKEY, and TESTGROUPID

Caveats / Todo: