paperless-ngx

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Paperless-ngx Skill

Paperless-ngx 技能

Manage documents in Paperless-ngx via its REST API using HTTP requests.
通过HTTP请求,借助REST API管理Paperless-ngx中的文档。

Configuration

配置

Requires environment variables:
  • PAPERLESS_URL
    : Base URL (e.g.,
    https://paperless.example.com
    )
  • PAPERLESS_TOKEN
    : API token from Paperless-ngx settings
需要配置环境变量:
  • PAPERLESS_URL
    : 基础URL(例如:
    https://paperless.example.com
  • PAPERLESS_TOKEN
    : 从Paperless-ngx设置中获取的API令牌

Authentication

身份验证

Include token in all requests:
Authorization: Token $PAPERLESS_TOKEN
所有请求中需包含令牌:
Authorization: Token $PAPERLESS_TOKEN

Core Operations

核心操作

Search Documents

搜索文档

bash
curl -s "$PAPERLESS_URL/api/documents/?query=invoice" \
  -H "Authorization: Token $PAPERLESS_TOKEN"
Filter options:
correspondent__id
,
document_type__id
,
tags__id__in
,
created__date__gte
,
created__date__lte
,
added__date__gte
.
bash
curl -s "$PAPERLESS_URL/api/documents/?query=invoice" \
  -H "Authorization: Token $PAPERLESS_TOKEN"
过滤选项:
correspondent__id
document_type__id
tags__id__in
created__date__gte
created__date__lte
added__date__gte

Get Document Details

获取文档详情

bash
curl -s "$PAPERLESS_URL/api/documents/{id}/" \
  -H "Authorization: Token $PAPERLESS_TOKEN"
bash
curl -s "$PAPERLESS_URL/api/documents/{id}/" \
  -H "Authorization: Token $PAPERLESS_TOKEN"

Download Document

下载文档

bash
undefined
bash
undefined

Original file

原始文件

curl -s "$PAPERLESS_URL/api/documents/{id}/download/"
-H "Authorization: Token $PAPERLESS_TOKEN" -o document.pdf
curl -s "$PAPERLESS_URL/api/documents/{id}/download/"
-H "Authorization: Token $PAPERLESS_TOKEN" -o document.pdf

Archived (OCR'd) version

归档(经OCR识别)版本

curl -s "$PAPERLESS_URL/api/documents/{id}/download/?original=false"
-H "Authorization: Token $PAPERLESS_TOKEN" -o document.pdf
undefined
curl -s "$PAPERLESS_URL/api/documents/{id}/download/?original=false"
-H "Authorization: Token $PAPERLESS_TOKEN" -o document.pdf
undefined

Upload Document

上传文档

bash
curl -s "$PAPERLESS_URL/api/documents/post_document/" \
  -H "Authorization: Token $PAPERLESS_TOKEN" \
  -F "document=@/path/to/file.pdf" \
  -F "title=Document Title" \
  -F "correspondent=1" \
  -F "document_type=2" \
  -F "tags=3" \
  -F "tags=4"
Optional fields:
title
,
created
,
correspondent
,
document_type
,
storage_path
,
tags
(repeatable),
archive_serial_number
,
custom_fields
.
bash
curl -s "$PAPERLESS_URL/api/documents/post_document/" \
  -H "Authorization: Token $PAPERLESS_TOKEN" \
  -F "document=@/path/to/file.pdf" \
  -F "title=Document Title" \
  -F "correspondent=1" \
  -F "document_type=2" \
  -F "tags=3" \
  -F "tags=4"
可选字段:
title
created
correspondent
document_type
storage_path
tags
(可重复)、
archive_serial_number
custom_fields

Update Document Metadata

更新文档元数据

bash
curl -s -X PATCH "$PAPERLESS_URL/api/documents/{id}/" \
  -H "Authorization: Token $PAPERLESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "New Title", "correspondent": 1, "tags": [1, 2]}'
bash
curl -s -X PATCH "$PAPERLESS_URL/api/documents/{id}/" \
  -H "Authorization: Token $PAPERLESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "New Title", "correspondent": 1, "tags": [1, 2]}'

Delete Document

删除文档

bash
curl -s -X DELETE "$PAPERLESS_URL/api/documents/{id}/" \
  -H "Authorization: Token $PAPERLESS_TOKEN"
bash
curl -s -X DELETE "$PAPERLESS_URL/api/documents/{id}/" \
  -H "Authorization: Token $PAPERLESS_TOKEN"

Organization Endpoints

组织管理端点

Tags

标签

bash
undefined
bash
undefined

List tags

列出标签

curl -s "$PAPERLESS_URL/api/tags/" -H "Authorization: Token $PAPERLESS_TOKEN"
curl -s "$PAPERLESS_URL/api/tags/" -H "Authorization: Token $PAPERLESS_TOKEN"

Create tag

创建标签

curl -s -X POST "$PAPERLESS_URL/api/tags/"
-H "Authorization: Token $PAPERLESS_TOKEN"
-H "Content-Type: application/json"
-d '{"name": "Important", "color": "#ff0000"}'
undefined
curl -s -X POST "$PAPERLESS_URL/api/tags/"
-H "Authorization: Token $PAPERLESS_TOKEN"
-H "Content-Type: application/json"
-d '{"name": "Important", "color": "#ff0000"}'
undefined

Correspondents

联系人

bash
undefined
bash
undefined

List correspondents

列出联系人

curl -s "$PAPERLESS_URL/api/correspondents/" -H "Authorization: Token $PAPERLESS_TOKEN"
curl -s "$PAPERLESS_URL/api/correspondents/" -H "Authorization: Token $PAPERLESS_TOKEN"

Create correspondent

创建联系人

curl -s -X POST "$PAPERLESS_URL/api/correspondents/"
-H "Authorization: Token $PAPERLESS_TOKEN"
-H "Content-Type: application/json"
-d '{"name": "ACME Corp"}'
undefined
curl -s -X POST "$PAPERLESS_URL/api/correspondents/"
-H "Authorization: Token $PAPERLESS_TOKEN"
-H "Content-Type: application/json"
-d '{"name": "ACME Corp"}'
undefined

Document Types

文档类型

bash
undefined
bash
undefined

List document types

列出文档类型

curl -s "$PAPERLESS_URL/api/document_types/" -H "Authorization: Token $PAPERLESS_TOKEN"
curl -s "$PAPERLESS_URL/api/document_types/" -H "Authorization: Token $PAPERLESS_TOKEN"

Create document type

创建文档类型

curl -s -X POST "$PAPERLESS_URL/api/document_types/"
-H "Authorization: Token $PAPERLESS_TOKEN"
-H "Content-Type: application/json"
-d '{"name": "Invoice"}'
undefined
curl -s -X POST "$PAPERLESS_URL/api/document_types/"
-H "Authorization: Token $PAPERLESS_TOKEN"
-H "Content-Type: application/json"
-d '{"name": "Invoice"}'
undefined

Bulk Operations

批量操作

bash
curl -s -X POST "$PAPERLESS_URL/api/documents/bulk_edit/" \
  -H "Authorization: Token $PAPERLESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [1, 2, 3],
    "method": "add_tag",
    "parameters": {"tag": 5}
  }'
Methods:
set_correspondent
,
set_document_type
,
add_tag
,
remove_tag
,
delete
,
reprocess
.
bash
curl -s -X POST "$PAPERLESS_URL/api/documents/bulk_edit/" \
  -H "Authorization: Token $PAPERLESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [1, 2, 3],
    "method": "add_tag",
    "parameters": {"tag": 5}
  }'
支持的方法:
set_correspondent
set_document_type
add_tag
remove_tag
delete
reprocess

Task Status

任务状态

After upload, check task status:
bash
curl -s "$PAPERLESS_URL/api/tasks/?task_id={uuid}" \
  -H "Authorization: Token $PAPERLESS_TOKEN"
上传完成后,检查任务状态:
bash
curl -s "$PAPERLESS_URL/api/tasks/?task_id={uuid}" \
  -H "Authorization: Token $PAPERLESS_TOKEN"

Response Handling

响应处理

  • List endpoints return
    {"count": N, "results": [...]}
    with pagination
  • Single objects return the object directly
  • Use
    ?page=2
    for pagination
  • Add
    ?ordering=-created
    for sorting (prefix
    -
    for descending)
  • 列表端点返回
    {"count": N, "results": [...]}
    格式的数据,并支持分页
  • 单个对象端点直接返回该对象
  • 使用
    ?page=2
    进行分页
  • 添加
    ?ordering=-created
    进行排序(前缀
    -
    表示降序)