A simple library that handles uploading files to Notion
Project description
notion_upload
A lightweight Python utility to upload files—both local and remote—to Notion via the Notion API. Supports internal (local) and external (URL-based) file uploads, with added support for bulk uploading multiple files at once.
Features
- ✅ Upload local files to Notion
- 🌐 Upload files from remote URLs
- 📁 MIME type validation
- ❌ Basic error checking and reporting
- 🔒 Uses Bearer token authentication
- 📦 Optional 5MB file size enforcement (enabled by default)
- 📤 Bulk upload multiple files in a single call
- 📋 Returns Notion file IDs for uploaded files
- 🧩 Completely manages multi part file uploads
Installation
Install the package
pip install notion-upload
The only external dependency is
requests.
Usage
Single File Upload Example
from notion_upload import notion_upload
NOTION_KEY = "your_notion_api_key"
#Internal
uploader = notion_upload(
"internal.jpg",
"internal.jpg",
NOTION_KEY
)
uploaded_file_id = uploader.upload()
print("Uploaded file ID:", uploaded_file_id)
#External
uploader = notion_upload(
"https://example.com/image.png","external.png",
NOTION_KEY
)
uploaded_file_ids = uploader.upload()
print("Uploaded file IDs:", uploaded_file_ids)
Bulk Upload Example
from notion_upload import bulk_upload
NOTION_KEY = "your_notion_api_key"
files_to_upload = {
"files": [
{
"path": "internal.jpg",
"name": "internal.jpg"
},
{
"path": "https://example.com/image.png",
"name": "external.png"
}
]
}
uploader = bulk_upload(files_to_upload, NOTION_KEY)
uploaded_file_ids = uploader.upload()
print("Uploaded file IDs:", uploaded_file_ids)
# If you would prefer a generator over a returned list, use upload_generator()
uploaded_file_ids = uploader.upload_generator()
print("Uploaded file IDs:", uploaded_file_ids)
File Types
Supported file types depend on the Notion API. Common formats like PDFs, images, and documents should work. Python’s built-in mimetypes module is used to infer MIME types.
Validation
- Ensures a Notion API key is provided
- Validates that the file extension matches the inferred MIME type
- Validates that the MIME type is the supported in Notion
- Optionally enforces Notion's 5MB upload limit (can be disabled)
- Prints clear, user-friendly errors on failure
- Throws clear errors on validation issues before attempting to upload
Notes
- Make sure your Notion integration has appropriate permissions for file uploads
- By default, files larger than 5MB will raise an error. To override this, pass
enforce_max_size=False. enforce_max_size=Falsedoes not prevent uploads from being blocked on files bigger than 5GB (Notion's hard ceiling for file size).- Bulk uploads return a list of Notion file IDs corresponding to each uploaded file.
Notion Version
Currenly supports Notion Version 2025-09-03
License
MIT License
Contributing
Contributions are welcome! Feel free to fork the repo, submit pull requests, or open issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file notion_upload-2.0.2.tar.gz.
File metadata
- Download URL: notion_upload-2.0.2.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7f2e453e58176905962d0878a240f5f06f66ae8566f0342d10698e2cb755cf0
|
|
| MD5 |
c271988eaad24c2988a64d9bbb3da26e
|
|
| BLAKE2b-256 |
c75048b0b2247030e78084986cb81f50ad78d637b135eed8ab580cbf1afc520c
|
Provenance
The following attestation bundles were made for notion_upload-2.0.2.tar.gz:
Publisher:
publish-package.yaml on michael-masarik/notion_upload
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notion_upload-2.0.2.tar.gz -
Subject digest:
c7f2e453e58176905962d0878a240f5f06f66ae8566f0342d10698e2cb755cf0 - Sigstore transparency entry: 1102188522
- Sigstore integration time:
-
Permalink:
michael-masarik/notion_upload@2078cb8ee3294f40b38bbef7cf9ec8251b060ce9 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/michael-masarik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yaml@2078cb8ee3294f40b38bbef7cf9ec8251b060ce9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file notion_upload-2.0.2-py3-none-any.whl.
File metadata
- Download URL: notion_upload-2.0.2-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65c36bccea01b59cb01cb1f11baea82b8bd6b973a143b9978cfac232f6f79676
|
|
| MD5 |
52f8892f1fc6381b2e57a1b132037210
|
|
| BLAKE2b-256 |
f7ba5efa40ac45617620492dc74b716519faae6b31c92a1bb8f23c2c1ea385fa
|
Provenance
The following attestation bundles were made for notion_upload-2.0.2-py3-none-any.whl:
Publisher:
publish-package.yaml on michael-masarik/notion_upload
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
notion_upload-2.0.2-py3-none-any.whl -
Subject digest:
65c36bccea01b59cb01cb1f11baea82b8bd6b973a143b9978cfac232f6f79676 - Sigstore transparency entry: 1102188526
- Sigstore integration time:
-
Permalink:
michael-masarik/notion_upload@2078cb8ee3294f40b38bbef7cf9ec8251b060ce9 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/michael-masarik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yaml@2078cb8ee3294f40b38bbef7cf9ec8251b060ce9 -
Trigger Event:
release
-
Statement type: