快速开始

本指南将帮助你在 5 分钟内开始使用 XMan API。

1. 获取 API Key

首先,你需要一个 API Key 来认证请求。

  1. 登录 XMan 控制台
  2. 进入 设置 → API Keys
  3. 点击"创建新的 API Key"
  4. 复制生成的 Key(注意:Key 只显示一次)

2. 发送第一个请求

使用 cURL 测试你的 API Key:

curl -X GET "https://api.xman.ink/v1/bookmarks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

3. 创建收藏

添加你的第一个收藏:

curl -X POST "https://api.xman.ink/v1/bookmarks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "title": "Example Page",
    "tags": ["example"]
  }'

4. 使用 SDK(可选)

我们提供官方 SDK 简化开发:

JavaScript

npm install @xman/sdk

import { XMan } from '@xman/sdk';

const client = new XMan({ apiKey: 'YOUR_API_KEY' });

const bookmark = await client.bookmarks.create({
  url: 'https://example.com',
  title: 'Example',
  tags: ['example']
});

Python

pip install xman-python

from xman import XMan

client = XMan(api_key='YOUR_API_KEY')

bookmark = client.bookmarks.create(
    url='https://example.com',
    title='Example',
    tags=['example']
)

下一步