初始化2

This commit is contained in:
2026-04-08 17:10:58 +08:00
commit 4986d90eb9
532 changed files with 112617 additions and 0 deletions

128
public/docs/quickstart.md Normal file
View File

@@ -0,0 +1,128 @@
# 5 分钟快速上手
> 本教程将带你完成 Websopy SDK 的安装、配置,并发送你的第一个 API 请求。
## 📋 前提条件
- Node.js 16.x 或更高版本
- npm 8.x 或 yarn 1.22+
- 一个 Websopy 账户([立即注册](https://websopy.com/register)
## 🚀 开始
### 第一步:安装 SDK
```bash
# 使用 npm
npm install @websopy/sdk
# 或使用 yarn
yarn add @websopy/sdk
# 或使用 pnpm
pnpm add @websopy/sdk
```
### 第二步:获取 API Key
1. 登录 [Websopy 控制台](https://console.websopy.com)
2. 进入 **开发者中心 → API Key**
3. 点击 **创建新 Key**
4. 选择权限范围(建议先选择「只读」权限测试)
5. 复制生成的 Key注意Key 只显示一次,请妥善保存)
### 第三步:初始化客户端
```typescript
import { WebsopyClient } from '@websopy/sdk'
const client = new WebsopyClient({
apiKey: 'your-api-key-here',
// 可选:指定 API 端点
baseUrl: 'https://api.websopy.com/v1'
})
```
### 第四步:发送第一个请求
```typescript
async function main() {
try {
// 获取用户信息
const user = await client.user.getProfile()
console.log('当前用户:', user.name)
// 创建第一个项目
const project = await client.project.create({
name: '我的第一个项目',
description: '通过 API 创建'
})
console.log('项目创建成功:', project.id)
// 获取项目列表
const projects = await client.project.list()
console.log('项目总数:', projects.total)
} catch (error) {
console.error('请求失败:', error.message)
}
}
main()
```
### 第五步:运行代码
```bash
npx ts-node your-script.ts
# 或
node your-script.js
```
**预期输出:**
```
当前用户: 张三
项目创建成功: proj_abc123xyz
项目总数: 5
```
## 🎉 恭喜!
你已经成功发送了第一个 API 请求。接下来你可以:
- 📖 继续阅读 [API Key 创建与管理](./apikey.md)
- 🔌 查看 [REST API 完整参考](./api-reference.md)
- 🤖 尝试 [AI 智能体接入](./ai-agent.md)
## ⚠️ 常见问题
### Q: 报 "Invalid API Key" 错误?
检查以下几点:
1. API Key 是否正确复制(不要有空格)
2. Key 是否已过期或被禁用
3. Key 的权限范围是否包含当前操作
### Q: 报 "Rate Limit Exceeded" 错误?
免费账户默认 100 次/分钟。如需更高配额,在控制台升级套餐。
### Q: 如何开启调试模式?
```typescript
const client = new WebsopyClient({
apiKey: 'your-api-key',
debug: true // 打印详细请求日志
})
```
## 📚 相关资源
- [SDK 源码仓库](https://github.com/websopy/sdk)
- [示例代码集合](https://github.com/websopy/examples)
- [API 状态页](https://status.websopy.com)
---
**上一步:** [返回教程首页](../index.md)
**下一步:** [API Key 创建与管理](./apikey.md)