Package: hydrus-api
Hydrus APIPython module implementing the Hydrus API.RequirementsPython >= 3.9 (I think; Let me know if you can use this with an older Python version)requests library (pip install requests)Installation$ pip install hydrus-apiIf you want to use the package in your own (installable) Python project, specify it in yoursetup.pyusing:install_requires=['hydrus-api'].ContributingPlease feel free to contribute in the form of a pull request when the API changes (keep close to the existing code style
or you'll create more work than help); I've been bad about merging these until now, I'll try to be more conscientious of
them.Try to avoid checking in your modifications to.vscode/settings.jsonand.envplease.I can't guarantee any fixed timespan in which I'll update this module myself when the API changes -- the only reason it
was updated now is because prkc kept bugging me; So if you desperately need this module to be updated, please create a
pull request.DescriptionRead the (latest) official documentationhere.When instantiatinghydrus_api.Clienttheacccess_keyis optional, allowing you to initially manually request
permissions usingrequest_new_permissions(). Alternatively there ishydrus_api.utils.request_api_key()to make this
easier. You can instantiate a newClientwith the returned access key after that.If the API version the module is developed against and the API version of the Hydrus client differ, there is a chance
that using this API module might have unintended consequences -- be careful.If something with the API goes wrong, a subclass ofAPIError(MissingParameter,InsufficientAccess,DatabaseLocked,ServerError) orAPIErroritself will be raised with therequests.Responseobject that caused the error.APIErrorwill only be raised directly, if the returned status code is unrecognized.The module providesPermission,URLType,ImportStatus,TagAction,TagStatus,PageType,PageState,FileSortType,ServiceType,NoteConflictResolutionandDuplicateStatusEnums for your convenience. Due to a
limitation of JSON, all dictionary keys that are returned by the client will be strings, so when using Enum members to
index a dictionary that was returned by the client, make sure to use the string representation of its value. Usually you
would have to do this:str(Enum.member.value), but the listed Enums allow you to just dostr(Enum.member)instead to
get the string representation of the member's value directly.The module provides convenience functions inhydrus_api.utilsthat are not strictly part of the API, e.g.add_and_tag_files()andget_page_list(); read their docstrings to figure out what they do.The client methodsadd_file()andadd_and_tag_files()acceptstr,pathlib.Pathand objects that implement the
internalBinaryFileLikeprotocol (i.e. all objects that provide aread()-method that returnsbytes).The functionhydrus_api.utils.parse_hydrus_metadata_filebehaves similarly, except that it accepts objects that
implement the internalTextFileLikeprotocol (i.e. itsread()-method returns a string).Check outexamples/for some example applications. Some of them might be outdated, but they should be good enough to
give you an idea how to use the module.Changes with v5.0.0To avoid confusion, starting with v5.0.0, responses will be returned unmodified from the API, exactly like described in
the official documentation. The previous functionality of automatically indexing a single top-level key has been
removed.