![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
![]() |
|
我已經開始大量使用黑曜石,因為這是一個很棒的筆記實用程序,並具有許多高級功能,插件和社區支持。
I've started using Obsidian quite a lot, as it's a fantastic note-taking utility with a lot of advanced features, plugins, and community support. I know others who use Notion, and while I've been trying to get to grips with it, there are some things I'd like to keep in both services at all times. That's why I wrote a Python script that allows me to synchronize my to-do list from Obsidian to a Notion database.
我已經開始大量使用黑曜石,因為這是一個很棒的筆記實用程序,並具有許多高級功能,插件和社區支持。我知道其他使用概念的人,當我一直試圖掌握它時,我想始終保持兩種服務。這就是為什麼我編寫了一個Python腳本,使我能夠將我的待辦事項清單從Obsidian同步到一個概念數據庫。
In order to use this script, you'll need to follow the instructions outlined below in order to generate an integration token for your Notion database. You can then give your integration access to your selected database, and it will be able to read and write to it as it needs to. Notion has a lot of different integrations readily available, but we're going to be creating our own combined with a pre-made template.
為了使用此腳本,您需要遵循以下概述的說明,以便為您的概念數據庫生成集成令牌。然後,您可以使您可以對所選數據庫進行集成訪問權限,並且它將能夠根據需要讀取和寫入。概念有很多不同的集成容易獲得,但是我們將與預製模板共同創建自己的組合。
As well, this is mostly a proof of concept. While it may be useful to some in its current state, this article is designed to help you get to grips with the Notion API and build your own integrations.
同樣,這主要是概念證明。儘管它對當前狀態的某些人可能很有用,但本文旨在幫助您掌握概念API並建立自己的集成。
Setting up API access in Notion
在概念中設置API訪問
Notion's API is easy to use
概念的API易於使用
First and foremost, Notion's API is really easy to use and quite well-documented. It can be quite hard to get started if you're not too familiar, so we'll walk you through the steps in order to create your own integration. The pictures above can also be used as a reference to ensure that you are creating the integration correctly.
首先,Intion的API確實易於使用並且有充分的文獻記錄。如果您不太熟悉,可能很難入門,因此我們會引導您完成這些步驟,以創建自己的集成。上面的圖片也可以用作參考,以確保您正確創建集成。
Next, we'll need to create the Notion database that your notes will be stored in. We're going to use the To-do List template on Notion, though we'll need to remove some additional fields. This template turns each task into its own page so that you can enter additional information.
接下來,我們需要創建您的筆記將存儲在其中的概念數據庫。儘管我們需要刪除一些其他字段,但我們將使用概念上的待辦事項列表模板。該模板將每個任務變成自己的頁面,以便您可以輸入其他信息。
Now that we have our template ready, click the "..." button (to the left of "New") and click "Customize To-dos". Click "Tasks" to remove it from the database. This will allow us to modify the fields in the template, where we can remove the "Assign" and "Due" fields. I also renamed "Task name" to simply "Name".
現在,我們已經準備好模板了,請單擊“ ...”按鈕(在“新”的左側),然後單擊“自定義待辦事項”。單擊“任務”將其從數據庫中刪除。這將使我們能夠修改模板中的字段,我們可以在其中刪除“分配”和“應得的”字段。我還將“任務名稱”重命名為“名稱”。
Finally, we'll finish by adding our integration to the page, so that it can edit the page. Go to the very top right of the page, where there's another "..." button. Click that, hover over "Connections" and scroll down to the integration that we created. Click it, and confirm that you want to give it access to the page.
最後,我們將通過將集成添加到頁面上來結束,以便它可以編輯頁面。轉到頁面右上角,那裡還有另一個“ ...”按鈕。單擊它,懸停在“連接”上,然後向下滾動到我們創建的集成。單擊它,並確認您要訪問該頁面。
Now with our page set up, we can move on to deploying the script to synchronize our Obsidian notes with Notion!
現在,經過我們的頁面設置,我們可以繼續部署腳本以將我們的黑曜石筆記與概念同步!
Setting up our script
設置我們的腳本
You need your database ID, integration token, and Markdown file name
您需要數據庫ID,集成令牌和Markdown文件名
The script that I've written can be found on GitHub, and it's pretty easy to get set up. You'll need to have Python installed on your machine, and you'll need to place the downloaded script in the same folder as your Obsidian notes. The only required Python library that doesn't already come preinstalled is the requests library, which you can install with the following command:
我編寫的腳本可以在Github上找到,並且很容易設置。您需要在計算機上安裝Python,並且需要將下載的腳本放在與黑曜石筆記同一文件夾中。唯一需要預先安裝的唯一必需的python庫是請求庫,您可以使用以下命令安裝:
pip3 install requests
PIP3安裝請求
Next, you'll need to replace the NOTION_TOKEN, DATABASE_ID, and TASKS variables defined at the start of the file with your details. The token is the integration token that we created earlier, and the database ID is found in the URL of the Notion database we created. The database ID is everything after "notion.so/" and everything before "?v=..." For example, a database ID might look like the following:
接下來,您需要替換文件開頭定義的notion_token,database_id和任務變量,並使用您的詳細信息。令牌是我們之前創建的集成令牌,並且數據庫ID在我們創建的概念數據庫的URL中找到。數據庫ID是“ intion.so/”之後的所有內容,並且在“ v = ...之前的所有內容”中,數據庫ID可能看起來如下:
1bd1ef8871068079b3f7e7a515dc292b
1BD1EF8871068079B3F7E7A515DC292B
Finally, replace "tasks.md" with the actual name of the markdown file that you use to track your tasks. I used tasks.md to test this script, but if you already have a daily tracker, you can change the name to match the file where they're stored.
最後,將“ tasks.md”替換為您用於跟踪任務的Markdown文件的實際名稱。我使用tasks.md來測試此腳本,但是如果您已經有每日跟踪器,則可以更改名稱以匹配存儲的文件。
Running the script
運行腳本
Now that we have everything in place, we can run the script! Simply open a terminal in the folder and run the following command:
現在我們已經準備好了所有東西,我們可以運行腳本!只需在文件夾中打開終端並運行以下命令:
python3 synctasks.py
Python3 Synctasks.py
This will then connect to your Notion database with your integration token, read your markdown file, and synchronize its contents with the server. You can also automate the running of the script so that it synchronizes multiple times a day. It will remove tasks that you delete from your notes, and it will also update the status if you change them from incomplete to completed (or vice versa).
然後,這將使用您的集成令牌連接到您的概念數據庫,讀取您的Markdown文件,並將其內容與服務器同步。您也可以自動化腳本的運行,以便每天多次同步。它將刪除您從筆記中刪除的任務,如果將狀態從不完整更改為已完成(或VICE反之亦然),它也將更新狀態。
This is a very basic script that will get you started with the Notion API, and you can expand on its functionality to do a lot more than just manage
這是一個非常基本的腳本,可以使您開始使用概念API,並且您可以擴展其功能,而不僅僅是管理
免責聲明:info@kdj.com
所提供的資訊並非交易建議。 kDJ.com對任何基於本文提供的資訊進行的投資不承擔任何責任。加密貨幣波動性較大,建議您充分研究後謹慎投資!
如果您認為本網站使用的內容侵犯了您的版權,請立即聯絡我們(info@kdj.com),我們將及時刪除。
-
- 比特幣價格激增觸發了大規模的短清算
- 2025-03-25 20:45:12
- 比特幣的價格漲幅為87,000美元,引發了一波短暫的清算浪潮,迫使看跌商人虧本關閉頭寸。
-
- 儘管ETH價格下跌,以太坊網絡市值超過了豐田和白金
- 2025-03-25 20:45:12
- 在持續交易所交易基金(ETF)流出時,Ether(ETH)在撰寫本文時以大約2,088美元的價格交易,下降了57%以上
-
-
- 2025年為以太坊塗了一個動蕩的畫布
- 2025-03-25 20:40:16
- 與看漲的預測相對於以太坊的下降低於2,000美元的閾值
-
- 美國的經濟增長從支持它的人們那裡縮小。富人正在收緊錢包。
- 2025-03-25 20:35:12
- 這篇博客文章調查了富裕的美國人減少支出對美國經濟的影響。
-
-
-
- 出現了令人不安的新趨勢:一個複雜的陪審團騙局,將無辜的公民人質綁架並要求比特幣付款
- 2025-03-25 20:30:12
- 陪審團的這種比特幣欺詐行為通過電話騷擾了許多人,並聲稱如果他們現在不付款,他們將被捕。
-
- Dogecoin團隊宣布與Indy 500團隊建立合作夥伴關係,以提高慈善計劃
- 2025-03-25 20:25:12
- 預計這種合作夥伴關係將提高Dogecoin的品牌知名度,尤其是在跟隨賽車運動的主流觀眾中。