A Typescript client for the Hypothesis REST API
npm install hypothesis-restWORK-IN-PROGRESS
!License

!npm bundle size
!Libraries.io dependency status for GitHub repo
!Deployment workflow



A Typescript client for the Hypothesis REST API for Node.js and the browser
- Static type checking for your API calls, responses and errors
- Typescript errors for unauthenticated requests
- Deal with Annotations, Groups, Profiles and Users rather than just HTTP requests
Catch mistakes as you type and minimize the need for actually making real API calls just for testing purposes.
fetchfetch so it will run as-is in modern browsers and Node.js 18 or later (the fetch Browser compatibility table on MDN also mentions Node.js 18).To support anything else, you can polyfill fetch:
- For Node.js < 18
- For older or fringe browsers
- There are plenty of others out there
- Generate your API token (you'll need to be logged into Hypothesis)
- Generate au OAuth token
- Get an OAuth token for someone else's account
action | Unauthenticated | API Key | Auth Client | Auth Client Forwarded User
---|---|---|---|---root | ✓ | ✓ | ✓ | ✓search | ✓ | ✓ | ✓ | ✓createAnnotation | | ✓ | |fetchAnnotation | ✓ | ✓ | |updateAnnotation | | ✓ | |deleteAnnotation | | ✓ | |flagAnnotation | | ✓ | |hideAnnotation | | ✓ | |showAnnotation | | ✓ | |getListOfGroups | ✓ | ✓ | |createGroup | | ✓ | | ✓fetchGroup | ✓ | ✓ | ✓ |updateGroup | | ✓ | ✓ | ✓createOrUpdateGroup | | ✓ | | ✓getGroupMembers | ✓ | ✓ | ✓ |addGroupMember | | | ✓ |removeGroupMember | | ✓ | |fetchProfile | ✓ | ✓ | |fetchUsersGroups | ✓ | ✓ | |createUser | | | ✓ |fetchUser | | | ✓ |updateUser | | | ✓ |
npm i to install dependenciesnpm run to see more optionsIf you intend to run the tests (npm test), you'll first need to create a local environment file (cp .env.example .env.testing.local) and add a value for each declared environment variable. This will allow you to test using the library to reach endpoints that require authentication, among other things.