A lightweight Python API for Hypothes.is
Project description
Hypothepy
A lightweight Python API for Hypothes.is
Free software: MIT license
Documentation: https://hypothepy.readthedocs.io
Check the official hypothes.is documentation:
Features
Light Python interface for all the REST endpoints available.
API parameters are simple native python types
API calls just return a requests.Response object
provides handy helpers
Python 3.6+
Only version 1 (stable) implemented (for the moment)
Only APIKey Authentication implemented (for the moment)
Command line interface (cooming soon)
Examples of Usage
from hypothepy.v1.api import HypoApi hypo = HypoApi( api_key='YOUR PERSONAL API KEY', user_name='YOUR USER NAME' ) hypo.annotations.search(user='EMBO')
Helpers
hypothepy provides a set of helpers to facilitate creating additional objects requiered by hypothes.is API
helpers.documents
Allows to create a new document objects that you can directly pass as a parameter to api calls:
from hypothepy.v1.api import HypoApi hypo = HypoApi() document = hypo.helpers.documents(title='My Title') # => { 'title': 'My Title' } hypo.annotations.create( # ... document=document, )
helpers.permissions
Similarly to documents, helpers.permissions allows is a handy shortcut for creating permissions objects:
from hypothepy.v1.api import HypoApi hypo = HypoApi() hypo.helpers.permissions( read = ['group:__world__'], update = ['acct:YOUR USER NAME@hypothes.is'], delete = ['acct:YOUR USER NAME@hypothes.is'], admin = ['acct:YOUR USER NAME@hypothes.is'], )
This example above is such a common pattern that hypo provides a preset shortcut for it under helpers.permissions.READ_ALL:
hypo.helpers.permissions.READ_ALL # => { # 'read': ['group:__world__'], # 'update': ['acct:YOUR USER NAME@hypothes.is'], # 'delete': ['acct:YOUR USER NAME@hypothes.is'], # 'admin': ['acct:YOUR USER NAME@hypothes.is'], # }
This is useful when you are, for example, creating new annotations:
hypo.annotations.create( uri='http://www.embo.org', permissions=hypo.helpers.permissions.READ_ALL, # ... )
History
0.2.0 (2019-08-28)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hypothepy-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b41edcbbc8dd73ab6c6833e976963de6fd6c69d31a0f5067dda73aa84688b6db |
|
MD5 | d127609dc6cd32a28593862ed911f465 |
|
BLAKE2b-256 | ce9d8b352a3ba82047507ce0af869a57dffa7c7780fe7349ea1b8aa916276054 |