Skip to main content

Little api wrapper for the paperless(-ngx) dms.

Project description

Shows an illustrated sun in light mode and a moon with stars in dark mode.

PyPaperless

Test Badge

Little api client for Paperless-ngx! Find out more here:

Features

  • Depends on aiohttp.
  • Token authentication, note that credentials aren't supported anymore.
  • list requests all object ids of resources.
  • get methods for each resources. Accepts page parameters and Django filters and is thus very powerful.
  • iterate for each paginated endpoint, you may want to apply some Django filters here, as well.
  • create, update, delete methods for documents and their master data endpoints.
  • Paperless makes use of pagination. We use that too. You have the full control over how much data to fetch.
  • pypaperless is meant to be only the transportation layer. Store and reduce/aggregate data on your own.

Examples

Handling a session.

import asyncio

from pypaperless import Paperless

paperless = Paperless("localhost:8000", "your-secret-token")

async def main():
  paperless.initialize()
  # do something
  paperless.close()

  # or just use it in a context
  async with paperless:
    # do something

asyncio.run(main())

Actually request something

# requests one page
documents = await paperless.documents.get(page=1)
for item in documents.items:
  print(f"document #{item.id} has the following content: {item.content}")

Request all items of specific document types and iterate over them

doc_types = [
  "3", # salary
  "8", # contract
  "11", # bank account
]

# iterates over all pages
async for item in paperless.documents.iterate(document_type__id__in=",".join(doc_types)):
  print(f"document #{item.id} has the following content: {item.content}")

Request a specific item

correspondent = await paperless.correspondents.one(23)

Create a new correspondent

from pypaperless.models import CorrespondentPost
from pypaperless.models.shared import MatchingAlgorithm

new_correspondent = CorrespondentPost(
  name="Salty Correspondent",
  match="Give me all your money",
  matching_algorithm=MatchingAlgorithm.ALL,
)
# watch out, the result is a Correspondent object...
created_correspondent = paperless.correspondents.create(new_correspondent)
print(created_correspondent.id)
# >> 1337

And delete that salty guy again, including all of his god damn documents!

[!CAUTION] That code actually requests Paperless to physically delete that data! There is no point of return!

# ...
async for item in paperless.documents.iterate(correspondent__id=1337):
  await paperless.documents.delete(item)

await paperless.correspondents.delete(created_correspondent)

Thanks to

  • The Paperless-ngx Team
  • The Home Assistant Community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypaperless-2.0.1.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypaperless-2.0.1-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file pypaperless-2.0.1.tar.gz.

File metadata

  • Download URL: pypaperless-2.0.1.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pypaperless-2.0.1.tar.gz
Algorithm Hash digest
SHA256 5e71d4c62459165999286183b0ee04199ecb981be9f171680ec33756bf05bb3e
MD5 6ee41bc472db950103bd32cacd21edc6
BLAKE2b-256 85141977c2f42fb62ee4ec41d416dafccf1280362ef09801ebae9f8a555e8d4d

See more details on using hashes here.

File details

Details for the file pypaperless-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pypaperless-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pypaperless-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e35f3e49eec3e6842231c0d7810f7ed3d672e43edd20515c1e512f31ea1f6cb
MD5 79d5281be7147c21b6ff401677985b1f
BLAKE2b-256 3b4b03fd2dc1d104fe6ae06dd27658685502a015b349918b96d49c6f33a1daf3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page