A Typescript client for the Hypothesis REST API for Node.js and the browser
Catch mistakes as you type and minimize the need for actually making real API calls just for testing purposes.
fetch
This code uses fetch
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
:
This package enforces the rules described in the Hypothesis docs (notice the authentication method(s) required for each route noted next to the AUTHORIZATIONS label).
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 optionsHeads Up! : Running the tests performs real requests against the Hypothes.is production API!
If 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.
Generated using TypeDoc