热门角色不仅是灵感来源,更是你的效率助手。通过精挑细选的角色提示词,你可以快速生成高质量内容、提升创作灵感,并找到最契合你需求的解决方案。让创作更轻松,让价值更直接!
我们根据不同用户需求,持续更新角色库,让你总能找到合适的灵感入口。
设计符合RESTful规范的API端点,支持多功能操作。
在设计一个支持创建、读取、更新、删除(CRUD)操作的RESTful API时,我们需要定义 URL 模式、HTTP 方法、请求和响应格式,以及管理员访问权限认证。以下是一个示例 API 的设计:
/api/usersPOST/api/usersAuthorization: Bearer {token} (管理员权限的认证 Token)Content-Type: application/json{
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
"role": "user"
}
201 Created{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"created_at": "2023-10-01T12:00:00Z"
}
403 Forbidden400 Bad RequestGET/api/usersAuthorization: Bearer {token}200 OK[
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"created_at": "2023-10-01T12:00:00Z"
},
{
"id": 2,
"name": "Jane Smith",
"email": "jane@example.com",
"role": "user",
"created_at": "2023-10-02T08:00:00Z"
}
]
403 Forbidden500 Internal Server ErrorGET/api/users/{id}Authorization: Bearer {token}200 OK{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"created_at": "2023-10-01T12:00:00Z"
}
404 Not FoundPUT/api/users/{id}Authorization: Bearer {token}Content-Type: application/json{
"name": "John Doe Updated",
"email": "updated@example.com",
"role": "admin" // 仅管理员可以修改角色
}
200 OK{
"id": 1,
"name": "John Doe Updated",
"email": "updated@example.com",
"role": "admin",
"updated_at": "2023-10-03T10:00:00Z"
}
403 Forbidden404 Not FoundDELETE/api/users/{id}Authorization: Bearer {token}204 No Content (无内容返回)403 Forbidden404 Not Found认证: 使用 Bearer Token 进行认证。所有受保护的端点必须包含头部:
Authorization: Bearer {token}
{
"access_token": "{token}",
"expires_in": 3600
}
授权:
错误处理:
{
"error": {
"code": "RESOURCE_NOT_FOUND",
"message": "The requested user was not found."
}
}
分页支持:
GET /api/users),支持分页:
?page=1&limit=10{
"data": [ /* 用户数据 */ ],
"pagination": {
"current_page": 1,
"total_pages": 5,
"total_items": 50
}
}
通过上述设计,就可以满足用户管理功能的基本需求,并确保安全性和扩展性。
以下是一个关于订单管理的RESTful API设计,支持读取和更新操作:
URL: https://api.example.com/ordersBearer Token 发送授权头进行认证 (Authorization: Bearer <token>)/orders/{orderId}GETorderId 获取订单详细信息。Authorization: Bearer <token>
orderId (表示特定订单的ID, 必须)200 OK):
{
"status": "success",
"data": {
"orderId": "12345",
"userId": "67890",
"status": "completed",
"items": [
{
"productId": "111",
"quantity": 1,
"price": 100
},
{
"productId": "222",
"quantity": 2,
"price": 200
}
],
"totalPrice": 500
}
}
401 Unauthorized):
{
"status": "error",
"message": "Authentication token is missing or invalid"
}
403 Forbidden):
{
"status": "error",
"message": "You are not authorized to access this order"
}
404 Not Found):
{
"status": "error",
"message": "Order not found"
}
/orders/{orderId}PUTAuthorization: Bearer <token>
orderId (表示特定订单的ID, 必须){
"address": {
"street": "123 Main St",
"city": "New York",
"zipCode": "10001"
},
"status": "pending"
}
address)或自定义字段。禁止更新付款状态或敏感字段。200 OK):
{
"status": "success",
"data": {
"orderId": "12345",
"status": "updated",
"address": {
"street": "123 Main St",
"city": "New York",
"zipCode": "10001"
}
}
}
401 Unauthorized):
{
"status": "error",
"message": "Authentication token is missing or invalid"
}
403 Forbidden):
{
"status": "error",
"message": "You are not authorized to update this order"
}
400 Bad Request):
{
"status": "error",
"message": "Invalid input data or you are trying to update restricted fields"
}
GET /orders/{orderId})。PUT /orders/{orderId})。Bearer Token。以上就是一个简洁的RESTful API设计,支持订单的读取与更新操作,并对用户权限进行了限制,保证了数据安全性且满足了普通用户的基本使用需求。
以下是一个为产品设计的 RESTful API 的详细说明,该 API 支持创建和读取操作,提供 URL 模式、HTTP 方法、请求/响应格式,并包含管理员访问权限的认证要求:
Product。admin 权限进行认证检查)。/api/products/POSTContent-Type: application/json (请求体为 JSON 格式)Authorization: Bearer <token> (只有管理员权限用户才能创建){
"name": "string", // 产品名称(必填)
"description": "string", // 产品描述(选填)
"price": "float" // 产品价格(必填,正值)
}
201 Created
{
"id": "uuid", // 产品的唯一标识
"name": "string", // 产品名称
"description": "string",
"price": "float",
"created_at": "ISO 8601 timestamp",
"status": "success"
}
401 Unauthorized 或 400 Bad Request
{
"error": "string", // 错误描述
"status_code": 401
}
URL 模式: /api/products/
HTTP 方法: GET
请求头: 可选 Authorization: Bearer <token>
查询参数: 可用的查询选项用于过滤返回的产品列表:
?name=<部分名称>: 按名称进行模糊搜索?price_min=<金额>: 最低价格过滤?price_max=<金额>: 最高价格过滤响应格式:
200 OK
[
{
"id": "uuid", // 产品的唯一标识符
"name": "string", // 产品名称
"description": "string",
"price": "float",
"created_at": "ISO 8601 timestamp"
},
...
]
[]
400 Bad Request
{
"error": "string",
"status_code": 400
}
/api/products/{id}/GETAuthorization: Bearer <token>{id}: 产品的唯一标识符(UUID 格式)200 OK
{
"id": "uuid", // 产品的唯一标识
"name": "string", // 产品名称
"description": "string",
"price": "float",
"created_at": "ISO 8601 timestamp"
}
404 Not Found
{
"error": "Product not found",
"status_code": 404
}
Authorization 请求头传递 Token:
Authorization: Bearer <token>
admin 权限。请求
POST /api/products/ HTTP/1.1
Host: api.example.com
Authorization: Bearer abc123token
Content-Type: application/json
{
"name": "Wireless Headphones",
"description": "Noise cancelling over-ear headphones.",
"price": 199.99
}
响应
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "e217b630-21a3-11ee-be56-0242ac120002",
"name": "Wireless Headphones",
"description": "Noise cancelling over-ear headphones.",
"price": 199.99,
"created_at": "2023-10-31T12:00:00Z",
"status": "success"
}
请求
GET /api/products/?price_min=100 HTTP/1.1
Host: api.example.com
响应
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "e217b630-21a3-11ee-be56-0242ac120002",
"name": "Wireless Headphones",
"description": "Noise cancelling over-ear headphones.",
"price": 199.99,
"created_at": "2023-10-31T12:00:00Z"
},
{
"id": "f318c740-21a3-11ee-be56-0242ac120002",
"name": "Bluetooth Speaker",
"description": "Portable speaker with high-quality sound.",
"price": 149.99,
"created_at": "2023-10-30T15:00:00Z"
}
]
通过以上设计,你可以实现一个支持创建和读取产品的 RESTful API,同时包含管理员权限验证的具体逻辑。
帮助开发者快速设计符合RESTful规范的API端点,使其能够高效规划URL结构、明确HTTP方法、定义数据请求与响应格式,同时涵盖访问权限的认证要求,简化开发流程并提升API设计质量。
快速获取标准化API设计方案,加速产品开发周期,确保输出符合行业规范的技术产品。
通过自动生成的RESTful API设计,减少重复性脑力劳动,提高工作效率和专注度。
无需技术背景,也能快速定义API需求,帮助团队实现精准开发对齐与明确分工。
将模板生成的提示词复制粘贴到您常用的 Chat 应用(如 ChatGPT、Claude 等),即可直接对话使用,无需额外开发。适合个人快速体验和轻量使用场景。
把提示词模板转化为 API,您的程序可任意修改模板参数,通过接口直接调用,轻松实现自动化与批量处理。适合开发者集成与业务系统嵌入。
在 MCP client 中配置对应的 server 地址,让您的 AI 应用自动调用提示词模板。适合高级用户和团队协作,让提示词在不同 AI 工具间无缝衔接。
免费获取高级提示词-优惠即将到期