paperap.resources.document_metadata module
Provide resources for interacting with document metadata in the Paperless-NgX API.
The document metadata endpoints expose additional information about documents that isn’t included in standard document responses, such as detailed OCR text, archive metadata, and system-level information.
- Classes:
DocumentMetadataResource: Resource for retrieving and managing document metadata.
- Exceptions:
ResourceNotFoundError: Raised when requested metadata is not found. APIError: Raised when the API returns an error response. BadResponseError: Raised when the API response cannot be parsed.
- class paperap.resources.document_metadata.DocumentMetadataResource(client)[source]
Bases:
StandardResource
[DocumentMetadata
,DocumentMetadataQuerySet
]Manage document metadata in Paperless-NgX.
Provides methods to interact with document metadata API endpoints, allowing retrieval of extended metadata associated with documents. Document metadata includes information such as OCR text, archive metadata, and system-level details that aren’t included in standard document responses.
Unlike most resources, DocumentMetadataResource uses a specialized endpoint structure that retrieves metadata for a specific document by ID.
- model_class
The model class for document metadata.
- Type:
Type[DocumentMetadata]
- queryset_class
The queryset class for metadata queries.
- Type:
Type[DocumentMetadataQuerySet]
Example
>>> client = PaperlessClient() >>> metadata_resource = client.document_metadata >>> # or directly >>> metadata_resource = DocumentMetadataResource(client)
- Parameters:
client (PaperlessClient)
- model_class
alias of
DocumentMetadata
- queryset_class
alias of
DocumentMetadataQuerySet
- name: str = 'document_metadata'
- endpoints: ClassVar[Endpoints] = {'detail': <string.Template object>}
- get_metadata(document_id)[source]
Retrieve metadata for a specific document.
Fetches extended metadata for a document that isn’t included in the standard document response, such as detailed OCR text, archive metadata, and system-level information.
- Parameters:
document_id (
int
) – The ID of the document for which to retrieve metadata.- Returns:
A model containing the document’s metadata.
- Return type:
- Raises:
ResourceNotFoundError – If the document or its metadata doesn’t exist.
APIError – If the API returns an error response.
BadResponseError – If the API response cannot be parsed.
Example
>>> client = PaperlessClient() >>> metadata = client.document_metadata.get_metadata(123) >>> print(f"Original filename: {metadata.original_filename}") >>> print(f"Archive Size: {metadata.archive_size} bytes")