在请求头中包含你的API密钥:
X-API-Key: sk_your_api_key_here或使用Bearer Token格式:
Authorization: Bearer sk_your_api_key_here默认限制:每小时100个请求
响应头会包含限流信息:
X-RateLimit-Limit - 限制数量X-RateLimit-Remaining - 剩余请求数X-RateLimit-Reset - 重置时间/api/v1/miniapps请求体:
{
"name": "My MiniApp",
"description": "一个简单的计数器应用",
"sourceCode": "function App() { return <div>Hello World</div>; }\nReactDOM.render(<App />, document.getElementById('root'));",
"isPublic": false, // 可选,默认为false(私有)
"autoGeneratePreview": true
}示例请求(Node.js):
const response = await fetch('https://your-domain.com/api/v1/miniapps', {
method: 'POST',
headers: {
'X-API-Key': 'sk_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'My MiniApp',
description: '一个简单的计数器应用',
sourceCode: `function App() {
const [count, setCount] = React.useState(0);
return (
<div className="p-4">
<h1>计数器: {count}</h1>
<button onClick={() => setCount(count + 1)}>+1</button>
</div>
);
}
ReactDOM.render(<App />, document.getElementById('root'));`,
autoGeneratePreview: true
})
});
const data = await response.json();
console.log('MiniApp URL:', data.data.url);响应示例:
{
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"shortId": "Ab3Cd5Ef", // 8字符短链接ID
"name": "My MiniApp",
"description": "一个简单的计数器应用",
"isPublic": false,
"url": "https://your-domain.com/miniapps/Ab3Cd5Ef", // 使用短链接
"createdAt": "2024-01-01T00:00:00.000Z"
},
"message": "Miniapp created successfully"
}API使用标准HTTP状态码表示请求结果: