热门角色不仅是灵感来源,更是你的效率助手。通过精挑细选的角色提示词,你可以快速生成高质量内容、提升创作灵感,并找到最契合你需求的解决方案。让创作更轻松,让价值更直接!
我们根据不同用户需求,持续更新角色库,让你总能找到合适的灵感入口。
生成详细的API文档,包括请求格式、参数等内容
以下是针对 GET /api/v1/users/{id} RESTful API 生成的一份详细API文档,涵盖了请求格式、参数、认证方式、响应结构、状态码及使用示例。
用于根据用户 ID 获取指定用户的详细信息。
/api/v1/users/{id}GET /api/v1/users/{id} HTTP/1.1
Host: example.com
Authorization: Bearer <your_access_token>
| 参数名 | 类型 | 必填 | 描述 |
|---|---|---|---|
id |
String | 是 | 用户的唯一标识符(UUID)。 |
| 参数名 | 必填 | 描述 |
|---|---|---|
Authorization |
是 | Bearer Token,用于验证用户身份。 |
Accept |
是 | 请求的内容格式 (application/json)。 |
{
"status": "success",
"data": {
"id": "string",
"name": "string",
"email": "string",
"phone": "string",
"created_at": "string",
"updated_at": "string"
}
}
| 字段名 | 类型 | 描述 |
|---|---|---|
status |
String | 请求的状态,success 表示成功。 |
data |
Object | 用户详细信息对象。 |
id |
String | 用户的唯一标识符。 |
name |
String | 用户的姓名。 |
email |
String | 用户的电子邮件地址。 |
phone |
String | 用户的电话号码(可选字段)。 |
created_at |
String | 用户记录的创建时间(ISO 8601 格式)。 |
updated_at |
String | 用户记录的更新时间(ISO 8601 格式)。 |
| 状态码 | 描述 |
|---|---|
| 200 | 请求成功,返回用户信息。 |
| 401 | 未授权,缺少有效的认证令牌或令牌无效。 |
| 404 | 找不到指定的用户 ID。 |
| 500 | 服务器内部错误。 |
GET /api/v1/users/1234abcd-5678efgh HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Accept: application/json
状态码: 200 OK
{
"status": "success",
"data": {
"id": "1234abcd-5678efgh",
"name": "John Doe",
"email": "johndoe@example.com",
"phone": "+123456789",
"created_at": "2023-01-01T10:00:00Z",
"updated_at": "2023-09-30T15:45:00Z"
}
}
状态码: 404 Not Found
{
"status": "error",
"message": "User not found"
}
状态码: 401 Unauthorized
{
"status": "error",
"message": "Unauthorized"
}
状态码: 500 Internal Server Error
{
"status": "error",
"message": "Something went wrong. Please try again later."
}
Authorization Header 并提供有效的 Bearer Token。id 参数中传入的用户 ID 必须为一个有效的 UUID 格式。希望这份文档对您有所帮助!
Query { user(id: $id) { name email } }此文档详细描述了 GraphQL 接口 Query 的使用,包括请求格式、参数说明、认证方式、响应结构、状态码及操作示例。
此接口用于查询特定用户的姓名和电子邮件地址,接口通过用户的唯一标识符 id 来进行查询。
GraphQL 请求需要通过 HTTP POST 方法发送,且请求的 Content-Type 必须为 application/json。请求的查询体中应该包含 GraphQL 查询语句和变量。
POST/graphql如果接口需要认证,通常需要在请求头中传递身份验证令牌:
Authorization: Bearer <your_token_here>
示例:
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI
String 或 Int以下为 GraphQL 查询的请求示例:
query GetUser($id: ID!) {
user(id: $id) {
name
email
}
}
$id 用于传递用户的 ID,用 JSON 格式传递。请求体应传递 GraphQL 查询和相应变量,示例如下:
{
"query": "query GetUser($id: ID!) { user(id: $id) { name email } }",
"variables": {
"id": "12345"
}
}
GraphQL 响应的基本结构如下:
data: 包含查询的结果数据。errors: 若查询出现错误,则会包含错误信息。示例返回格式:
{
"data": {
"user": {
"name": "John Doe",
"email": "john.doe@example.com"
}
}
}
{
"errors": [
{
"message": "User not found",
"locations": [
{
"line": 1,
"column": 3
}
],
"path": ["user"]
}
]
}
GraphQL 通常统一使用 HTTP 200 状态码表示请求成功发出,以下是常见状态码及其含义:
以下是通过 curl 发送请求的示例:
curl -X POST https://api.example.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your_token_here>" \
-d '{
"query": "query GetUser($id: ID!) { user(id: $id) { name email } }",
"variables": {
"id": "12345"
}
}'
const axios = require('axios');
const query = `
query GetUser($id: ID!) {
user(id: $id) {
name
email
}
}
`;
const variables = { id: "12345" };
axios.post(
'https://api.example.com/graphql',
{
query,
variables
},
{
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer <your_token_here>',
}
}
).then(response => {
console.log(response.data);
}).catch(error => {
console.error(error.response.data);
});
此 API 文档提供了一个完整的参考案例用于查询用户的基本信息,你可以根据项目需求扩展其他参数或功能。
以下是为POST /api/v1/products 生成的详细API文档:
该接口允许客户端创建一个新的产品。客户端需要发送必要的产品数据,服务器将处理创建请求,并将成功创建的产品信息返回给客户端。
/api/v1/productsPOSTBearer Token (基于OAuth2.0)application/json| Header 名称 | 描述 | 必填 |
|---|---|---|
| Authorization | Bearer <token>: 认证令牌 |
是 |
| Content-Type | 请求体数据的格式 (固定为application/json) |
是 |
| 参数名称 | 类型 | 描述 | 必填 | 示例 |
|---|---|---|---|---|
| name | string |
产品名称,不能重复 | 是 | "Wireless Mouse" |
| description | string |
产品描述 | 否 | "A lightweight wireless mouse" |
| price | float |
产品价格,必须为正数 | 是 | 29.99 |
| stock_quantity | integer |
产品库存量,必须为非负整数 | 是 | 150 |
| category_id | integer |
所属类别的ID。该ID必须存在于已定义的产品类别中 | 是 | 4 |
| image_urls | array |
包含产品图片路径的数组 | 否 | ["https://example.com/img1.jpg", "https://example.com/img2.jpg"] |
{
"name": "Wireless Mouse",
"description": "A lightweight wireless mouse",
"price": 29.99,
"stock_quantity": 150,
"category_id": 4,
"image_urls": [
"https://example.com/products/mouse1.jpg",
"https://example.com/products/mouse2.jpg"
]
}
成功的响应将返回包含新创建的产品详细信息的JSON对象:
| 参数名称 | 类型 | 描述 |
|---|---|---|
| id | integer |
新创建产品的唯一ID |
| name | string |
产品的名称 |
| description | string |
产品描述 |
| price | float |
产品价格 |
| stock_quantity | integer |
产品库存量 |
| category_id | integer |
所属类别的ID |
| image_urls | array |
产品图片路径数组 |
| created_at | string |
创建时间 (ISO 8601 格式) |
| updated_at | string |
更新时间 (ISO 8601 格式) |
| 状态码 | 描述 | 备注 |
|---|---|---|
| 201 | Created | 产品创建成功 |
| 400 | Bad Request | 请求参数无效或缺失 |
| 401 | Unauthorized | 未提供有效的授权令牌 |
| 404 | Not Found | 提供的category_id不存在 |
| 500 | Internal Server Error | 服务器内部错误 |
{
"id": 101,
"name": "Wireless Mouse",
"description": "A lightweight wireless mouse",
"price": 29.99,
"stock_quantity": 150,
"category_id": 4,
"image_urls": [
"https://example.com/products/mouse1.jpg",
"https://example.com/products/mouse2.jpg"
],
"created_at": "2023-10-25T12:34:56Z",
"updated_at": "2023-10-25T12:34:56Z"
}
{
"error": "Invalid request",
"message": "The field 'price' is required and must be a positive number."
}
{
"error": "Unauthorized",
"message": "A valid Bearer token is required for authentication."
}
{
"error": "Not Found",
"message": "The category with id '4' does not exist."
}
curl -X POST https://example.com/api/v1/products \
-H "Authorization: Bearer <your_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Wireless Mouse",
"description": "A lightweight wireless mouse",
"price": 29.99,
"stock_quantity": 150,
"category_id": 4,
"image_urls": [
"https://example.com/products/mouse1.jpg",
"https://example.com/products/mouse2.jpg"
]
}'
const axios = require('axios');
const data = {
name: "Wireless Mouse",
description: "A lightweight wireless mouse",
price: 29.99,
stock_quantity: 150,
category_id: 4,
image_urls: [
"https://example.com/products/mouse1.jpg",
"https://example.com/products/mouse2.jpg"
]
};
axios.post('https://example.com/api/v1/products', data, {
headers: {
'Authorization': 'Bearer <your_token>',
'Content-Type': 'application/json'
}
})
.then(response => {
console.log('Product created:', response.data);
})
.catch(error => {
console.error('Error creating product:', error.response.data);
});
以上为POST /api/v1/products的详细API文档。
帮助开发人员快速生成高质量、清晰明了的API文档,提升团队开发效率并优化与第三方开发者的协作体验。
优化API开发流程,生成标准化文档,快速对接各部门或外部合作方。
快速创建高质量的API文档,为开发者提供清晰、详尽的接口参考。
更轻松地协助开发团队整理API说明,为功能开发及外部对接提供支持。
将模板生成的提示词复制粘贴到您常用的 Chat 应用(如 ChatGPT、Claude 等),即可直接对话使用,无需额外开发。适合个人快速体验和轻量使用场景。
把提示词模板转化为 API,您的程序可任意修改模板参数,通过接口直接调用,轻松实现自动化与批量处理。适合开发者集成与业务系统嵌入。
在 MCP client 中配置对应的 server 地址,让您的 AI 应用自动调用提示词模板。适合高级用户和团队协作,让提示词在不同 AI 工具间无缝衔接。
免费获取高级提示词-优惠即将到期