Skip to main content

Sync Obsidian notes to Notion via GitHub

Project description

A tool to sync Obsidian notes to Notion via GitHub ๐Ÿ‘จโ€๐Ÿ’ป...


Report a Bug/Issue | Request a Feature | View Project Status


Obsidian Notion Sync

๐Ÿ“ฉ Installation

pip install obsidian-notion-sync

PyPI - Version PyPI - Python Version

๐Ÿ”„ Usage

There are 2 modes to use it :

Doing Obsidian sync with Git (this automatically triggers the below mode with Github Action)

>> obsidian-notion-sync git-sync

Doing Obsidian Vault sync with Notion

>> obsidian-notion-sync notion-sync

Synopsis

>> obsidian-notion-sync

Usage: obsidian-notion-sync [OPTIONS] COMMAND [ARGS]...
Sync Obsidian notes to Notion via GitHub

Options:
  --debug  Enable debug logging
  --help   Show this message and exit.

Commands:
  git-sync     Sync Obsidian notes to GitHub
  notion-sync  Sync Github placed Obsidian notes with Notion

๐ŸŽ›๏ธ How does it work ?

This is how the pipeline's overview looks like:

Pipeline

๐ŸŽฏ Detailed workflow

Step 1 : Takes up file all the files from your obsidian vault.

Uses the vault path given in the env variable

Obsidian Vault

Step 2 : Upon the running of the command, it copies the value at the place of invocation

Choose a place of invocation and it creates a directory named 'ObsidianClonedVault'.

Collected Locally

Step 3 : It then syncs this folder with a Github Repo

You can supply the name for an existing repo or it would create a new one with the given name in the env variable.

Github sycning

Step 4 : Once the syncing is completed, it triggers a Github action that uploads these files to notion via Notion APIs.

A Github workflow runs in the Github action space. You will get a mail if it fails for some reason. Check the logs for more debugging on that front.

Github Actions

Step 5 : Voila ! You can now access your notes on Notion too !

If everything goes well, it will update your notion page specified in the env variable.

Notion Populates

๐Ÿ› ๏ธ Configuration

Before using the tool, you need to set up the following environment variables:

Variable Description Example
GITHUB_TOKEN Your GitHub personal access token ghp_1234...
NOTION_TOKEN Your Notion integration token secret_5678...
OBSIDIAN_DIR Path to your Obsidian vault /Users/you/ObsidianVault
REPO_NAME Name for the GitHub repository My-Second-Brain
NOTION_PAGE_ID ID of your Notion page abc123...

๐Ÿช Setting up tokens

  1. GitHub Token:

    • Go to GitHub Settings โ†’ Developer Settings โ†’ Personal Access Tokens
    • Create a new token with 'repo' permissions
  2. Notion Token: (more details below on its access)

  3. Notion page ID: (more details below on its access)

    • Create a new page in Notion
    • Copy the page ID from the URL (it's the part after the page name and after the last '-')

๐Ÿ“‘ Example Configuration Script

You can create a shell script to set up your environment:

#!/bin/bash
export GITHUB_TOKEN="your_github_token"
export NOTION_TOKEN="your_notion_token"
export OBSIDIAN_DIR="/path/to/your/obsidian/vault"
export REPO_NAME="your-repo-name"
export NOTION_PAGE_ID="your_page_id"

obsidian-notion-sync --debug

Save this as run-sync.sh, make it executable (chmod +x run-sync.sh), and run it with ./run-sync.sh.

๐Ÿ“„ Setting up your notion page

(Skip this section if you were able to set the notion api tokens and page access )

Step 1 : Create a notion page for storing your Obsidian Vault

The red box highlighted is the Page Id - it is a 32 sized alphanumeric unique ID for the page which starts after the name of your page.

Notion Page

Step 2 : Go to https://www.notion.so/profile/integrations

You can open it from the settings in your notion app as well.

Integration

Step 3 : Create an integration

You can use the API tokens of an existing integration as well. Make sure it has the permission to read + write content.

New Integration

Step 4 : Copy this token

Set this token as your environment variable as mentioned above.

Copy This token

Step 5 : Allow your notion page to gain access

It will not have access to this connection by default.

Allow page for integration access

๐Ÿ–ฅ๏ธ Troubleshooting

If you encounter errors:

  1. Check that all environment variables are set correctly:

    echo $GITHUB_TOKEN
    echo $NOTION_TOKEN
    echo $OBSIDIAN_DIR
    echo $REPO_NAME
    echo $NOTION_PAGE_ID
    
  2. Ensure your Obsidian vault path exists and is accessible

  3. Verify that your GitHub token has the necessary permissions

  4. Check that your Notion integration is properly configured and has access to the page

๐Ÿง‘โ€๐Ÿง‘โ€๐Ÿง’โ€๐Ÿง’ Support

If you encounter any issues, please file them on our GitHub repository's issue tracker.

๐Ÿง‘โ€๐Ÿ’ป๐Ÿ‘ฉโ€๐Ÿ’ป Contribution

The agenda is to make this package as the easy and smooth package (with lesser bugs ;) for syncing a multitude for note taking applications but firstly achieve a robust two way sync between notion and obsidian.

Please refer to the CONTRIBUTING.md for more details. (TBD with more implementation and design considerations)

๐Ÿ“‚ Directory structure of the project:

# obsidian_notion_sync/
# โ”œโ”€โ”€ .github/
# โ”‚   โ””โ”€โ”€ workflows/
# โ”‚       โ””โ”€โ”€ sync.yml
# โ”œโ”€โ”€ src/
# โ”‚   โ””โ”€โ”€ obsidian_notion_sync/
# โ”‚       โ”œโ”€โ”€ __init__.py
# โ”‚       โ”œโ”€โ”€ __about__.py
# โ”‚       โ”œโ”€โ”€ _version.py
# โ”‚       โ”œโ”€โ”€ cli.py
# โ”‚       โ”œโ”€โ”€ config.py
# โ”‚       โ”œโ”€โ”€ sync.py
# โ”‚       โ”œโ”€โ”€ sync_to_notion.py
# โ”‚       โ””โ”€โ”€ exceptions.py
# โ”œโ”€โ”€ tests/
# โ”‚   โ””โ”€โ”€ __init__.py
# โ”œโ”€โ”€ .gitignore
# โ”œโ”€โ”€ LICENSE
# โ”œโ”€โ”€ README.md
# โ”œโ”€โ”€ pyproject.toml

License

obisidian-notion-sync is distributed under the terms of the MIT license.

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

obsidian_notion_sync-0.7.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

obsidian_notion_sync-0.7-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file obsidian_notion_sync-0.7.tar.gz.

File metadata

  • Download URL: obsidian_notion_sync-0.7.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.2

File hashes

Hashes for obsidian_notion_sync-0.7.tar.gz
Algorithm Hash digest
SHA256 4b99cd5ce7ed83718ea0a236f6586339b1cc9989d7ecc2c2415634c703a22e4b
MD5 52f600c5e440e08950bd71b644b98fbd
BLAKE2b-256 e546b4176340839f4cde9531a3467a79a7c527d61348ecc1f7306c299229fbab

See more details on using hashes here.

File details

Details for the file obsidian_notion_sync-0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for obsidian_notion_sync-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 2ee9edf4e31a252f57f98045dcd6345fe17da4c90345fa556ca202ada63dbbc6
MD5 2e975ca25c524907da2e0bb64235c84c
BLAKE2b-256 042d44e52826c0246c63fbb04a8d220abc195ca2efb8ae83ef1883bab6fb5a1b

See more details on using hashes here.

Supported by

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