Skip to content

快速开始 ​

基础 URL(Beta):https://notes-api.palmcode.cl/api/v1

自行托管?

所有示例均使用 PalmNotes 托管的 Beta 服务。如果您运行自己的 PalmNotes 服务器,请将 https://notes-api.palmcode.cl 替换为您自己的 API 地址,其余保持不变。

  1. 在 PalmNotes 中打开 设置 → 开发者 并创建令牌。只选择您需要的权限范围(scope)。
  2. 复制令牌(pn_pat_…)。它只显示一次。
  3. 发送请求:
bash
curl https://notes-api.palmcode.cl/api/v1/notes?limit=5 \
  -H "Authorization: Bearer $PALMNOTES_TOKEN"
ts
const res = await fetch('https://notes-api.palmcode.cl/api/v1/notes?limit=5', {
  headers: { Authorization: `Bearer ${process.env.PALMNOTES_TOKEN}` },
});
const { data, meta } = await res.json();
python
import os, requests

r = requests.get(
    "https://notes-api.palmcode.cl/api/v1/notes",
    params={"limit": 5},
    headers={"Authorization": f"Bearer {os.environ['PALMNOTES_TOKEN']}"},
)
print(r.json()["data"])

创建笔记:

bash
curl -X POST https://notes-api.palmcode.cl/api/v1/notes \
  -H "Authorization: Bearer $PALMNOTES_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"From the API","content_markdown":"# Hello\n\n- one\n- two","tags":["api"]}'
ts
const res = await fetch('https://notes-api.palmcode.cl/api/v1/notes', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PALMNOTES_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ title: 'From the API', content_markdown: '# Hello\n\n- one\n- two', tags: ['api'] }),
});
const { data } = await res.json(); // data.id, data.version
python
import os, requests

r = requests.post(
    "https://notes-api.palmcode.cl/api/v1/notes",
    headers={"Authorization": f"Bearer {os.environ['PALMNOTES_TOKEN']}"},
    json={"title": "From the API", "content_markdown": "# Hello\n\n- one\n- two", "tags": ["api"]},
)
print(r.json()["data"]["id"])

所有成功响应的格式为 { "data": …, "meta"?: … }。所有错误的格式为 { "error": { "code", "message", "request_id" } }。