> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/ai/manage-documents/python.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# Python

Full CRUD for the DNotifier knowledge base over HTTP.

## Setup

```python
import asyncio
from dnotifier import DNotifier

USER_ID = "indexer-service"

async def create_notifier() -> DNotifier:
    notifier = DNotifier(
        app_id="your-app-id",
        secret="your-app-secret",
        transport="http",
        user_id=USER_ID,
    )
    await notifier.connect()
    return notifier
```

## Add

```python
await notifier.add_document(
    sender_id=USER_ID,
    record_id="refund-policy",
    content="Refund requests are processed within 5 business days after approval.",
    doc_type="text",
    metadata={"source": "help-center", "locale": "en"},
)
```

## Update

```python
await notifier.update_document(
    sender_id=USER_ID,
    record_id="refund-policy",
    content="Refund requests are processed within 3 business days after approval.",
    doc_type="text",
    metadata={"source": "help-center", "locale": "en", "version": 2},
)
```

## Get one document

```python
doc = await notifier.get_document(
    sender_id=USER_ID,
    record_id="refund-policy",
)
print(doc)
```

## List (paginated)

```python
doc_list = await notifier.list_documents(
    sender_id=USER_ID,
    limit=20,
    offset=0,
    doc_type="text",
)
print(doc_list)
```

## Delete

```python
await notifier.delete_document(
    sender_id=USER_ID,
    record_id="refund-policy",
)
```

## Batch import

```python
articles = [
    {"id": "faq-password", "content": "Reset password from Settings → Security."},
    {"id": "faq-billing", "content": "Invoices are emailed on the 1st of each month."},
]

for article in articles:
    await notifier.add_document(
        sender_id=USER_ID,
        record_id=article["id"],
        content=article["content"],
        doc_type="faq",
        metadata={"source": "help-center"},
    )
    print(f"Indexed: {article['id']}")
```

## Learn more

* [**Semantic search**](https://dnotifier.gitbook.io/product-docs/ai/semantic-search/python.md)
* [**Example: RAG bot**](https://dnotifier.gitbook.io/product-docs/ai/example-rag-bot/python.md)
