notion-haystack: Export Notion pages to Haystack Documents
This python package allows you to easily export your Notion pages to Haystack Documents by providing a Notion API token.
Given that the Notion API is subject to some rate limits,
this component will automatically retry failed requests and wait for the rate limit to reset before retrying. This is
especially useful when exporting a large number of pages. Furthermore, this component uses asyncio to make requests in
parallel, which can significantly speed up the export process.
Installation
pip install notion-haystack
Usage
To use this package, you will need a Notion API token. You can follow the steps outlined in the Notion documentation to create a new Notion integration, connect it to your pages, and obtain your API token.
To enable your Notion integration to work on specific pages and the child pages in Notion, make sure to enable it in the 'Connections' setting of the page.
The following minimal example demonstrates how to export a list of pages to Haystack Documents:
from notion_haystack import NotionExporter
exporter = NotionExporter(api_token="<your-token>")
exported_pages = exporter.run(page_ids=["<list-of-page-ids>"])
# exported_pages will be a list of Haystack Documents where each Document corresponds to a Notion page
The following example shows how to use the NotionExporter inside an indexing pipeline:
from haystack import Pipeline
from notion_haystack import NotionExporter
from haystack.components.preprocessors import DocumentSplitter
from haystack.components.writers import DocumentWriter
from haystack.document_stores import InMemoryDocumentStore
document_store = InMemoryDocumentStore()
exporter = NotionExporter(api_token='YOUR_NOTION_API_KEY')
splitter = DocumentSplitter()
writer = DocumentWriter(document_store=document_store)
indexing_pipeline = Pipeline()
indexing_pipeline.add_component(instance=exporter, name="exporter")
indexing_pipeline.add_component(instance=splitter, name="splitter")
indexing_pipeline.add_component(instance=writer, name="writer")
indexing_pipeline.connect("exporter.documents", "splitter.documents")
indexing_pipeline.connect("splitter", "writer")
indexing_pipeline.run(data={"exporter": {"page_ids": ["your_page_id"] }})
# The pages will now be indexed in the document store
The NotionExporter class takes the following arguments:
api_token: Your Notion API token. You can find information on how to get an API token in Notion's documentationexport_child_pages: Whether to recursively export all child pages of the provided page ids. Defaults toFalse.extract_page_metadata: Whether to extract metadata from the page and add it as a frontmatter to the markdown. Extracted metadata includes title, author, path, URL, last editor, and last editing time of the page. Defaults toFalse.exclude_title_containing: If specified, pages with titles containing this string will be excluded. This might be useful for example to exclude pages that are archived. Defaults toNone.
The NotionExporter.run method takes the following arguments:
page_ids: A list of page ids to export. Ifexport_child_pagesisTrue, all child pages of these pages will be exported as well.
Metadata
Release files for notion-haystack 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| notion_haystack-1.0.0.tar.gz | 8.4 kB | Without provenance | Details for notion_haystack-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| notion_haystack-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for notion_haystack-1.0.0-py3-none-any.whl |
Total release size: 17.0 kB
Release files / notion_haystack-1.0.0.tar.gz
| Download URL | notion_haystack-1.0.0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e86e60040259390f31d7c2d47acd8c9856b37b611e1c07c140315140bee1ef8
|
|
BLAKE2b-256 checksum How to use checksums |
4c07ee12199a77860a0c937c7a15bcb4ec96443e20b1441383799ddfd7f56091
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.25.2
|
Release files / notion_haystack-1.0.0-py3-none-any.whl
| Download URL | notion_haystack-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d554f8b1a04eacddc872240daad35faa05ed70990543a5ed6e744d4780387f5a
|
|
BLAKE2b-256 checksum How to use checksums |
345427d483254f27ff5a755984850f3b9b17e00e2d4f9d8c4879c145f4439ce2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.25.2
|
Security for notion-haystack 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.