API reference#
These pages document the Python API of the bookshelf package. Import every name from the top-level package, for example from bookshelf import Bookshelf.
| Page | Covers |
|---|---|
| Bookshelf | The client that finds volumes, resolves books and corrects them |
| Volumes | A volume and the versions and editions it publishes |
| Books | A published book and the entries it indexes |
| Resources | The bytes behind an entry, read as frames or files |
| Errors | The exceptions a caller can catch |
| Cache | The local content cache that downloads read through |
| Legacy (0.4) | The deprecated 0.4 consumer API |
What semver covers#
Versions follow Semantic Versioning for the Python API listed in this section. A breaking change to any of it lands only in a new major version, after a release that deprecates it with a warning. Adding a name, a keyword argument with a default, or a field to a returned value type is not breaking.
The promised names in the bookshelf package are:
- The client:
Bookshelf. Its constructor, except thetransporttest seam, and the methodsclose,ensure_authenticated,search_volumes,volume,book,resource,resource_by_hashandcorrect_book. - Handles:
Volume,Book,BookEntryandResource. A handle is obtained from a client, for examplebs.book(...), and is not built directly. Its methods and attributes are promised, but its constructor is not. - Values:
ResourceInfo,DataPreview,ResourceType,Visibility,Identity,VolumeSummary,VolumeSearchResults,Facets,Facet,FacetValue,SeriesMetadata,BookCorrection,Problem,ItemErrorandCacheSummary. - The cache:
ContentCache, with the members on the Cache page. - Errors:
BookshelfErrorand every subclass on the Errors page. That includesPartialRegistrationErrorand the publisher errors,InvalidBundleError,InvalidRecipeError,InvalidReferenceError,RecordingErrorandRecordRefusedError, so anexceptclause naming one keeps working. An attribute that returns a generated model or a producer type, such asPartialRegistrationError.successful_outcomes, is provisional. - Metadata:
__version__,PRODUCTION_API_URLandOPENAPI_VERSION.
Beyond the root package:
bookshelf.auth, every name in its__all__.bookshelf.legacy, which stays until bookshelf 2.0 removes it.
ResourceType, Visibility and the other enumerated values are open. A value a newer platform adds arrives as a member of its own rather than an error, so compare with the named members and keep a fallback for the rest.
The API is synchronous. Async code calls it through asyncio.to_thread, as Reading asynchronously shows.
Outside the promise#
Anything not listed above can change in any release, even when it is importable. That includes:
- The
bookshelfcommand line interface. Its commands, options, output and exit codes may change between minor versions, so scripts that need stability should call the Python API instead. - The bundle and recipe formats, which follow their own schema versions rather than the package version. See the bundle format and the recipe format.
- The layout of the cache directory and the stored credentials file, which are private to the SDK.
- Underscore-prefixed modules and names, such as
bookshelf._core. - The generated API models, which track the platform contract. They are private, and some provisional producer methods still return them.
- Handle constructors, which take the private client and generated models.
- The producer surface, which is exported but still settling. That covers
setup,Activity,DraftBook,RegisterItem,Used,RegistrationSuccessandRegistrationFailure. It also covers theBookshelfmethodsactivity,draft_book,register_external,register_file,create_volume,get_or_create_volume,update_volume,delete_volume,update_draft,discard_draftandreplay_bundle, some of which still return generated models. bookshelf.publisher, which drives recording, replaying and publishing bundles, and its submodules. Its errors are the exception, because they are promised from the root package.