开发工具中心 API
发布: (2025年12月15日 GMT+8 00:46)
5 min read
原文: Dev.to
Source: Dev.to
我构建的内容
提交给 Xano AI 驱动后端挑战赛:可投产的公共 API
标题: DevTools 资源中心 API
可用: True
DevTools API 列表
- Xano Hub API
- Xano Assisted Production API
软件后端架构

后端采用分层、模块化设计,适用于 MVP。API 端点提供 REST 接口,受身份验证、速率限制和参数校验保护。核心业务逻辑被抽象为搜索、推荐、评分等服务。数据访问层负责对 PostgreSQL 的查询、缓存和事务处理。事件处理和后台任务实现了可扩展的异步集成。



缓存策略概览

数据库模式
tools
| Column | Type | Constraints / Description |
|---|---|---|
| id | SERIAL | 主键 |
| name | VARCHAR(255) | 唯一、非空 |
| slug | VARCHAR(255) | 唯一、URL 安全 |
| category_id | INTEGER | FK → categories.id |
| description | TEXT | 工具描述 |
| tagline | VARCHAR(500) | 简短营销语句 |
| website_url | VARCHAR(500) | 官方网站 |
| logo_url | VARCHAR(500) | Logo 图片 URL |
| founded_date | DATE | 公司成立日期 |
| company_name | VARCHAR(255) | 开发该工具的公司 |
| is_active | BOOLEAN | 默认: true |
| query_count | INTEGER | 默认: 0(趋势分数) |
| last_queried_at | TIMESTAMP | 最近一次 API 查询时间 |
| created_at | TIMESTAMP | 默认: now() |
| updated_at | TIMESTAMP | 默认: now() |
索引
category_idslugis_active(query_count, last_queried_at)
categories
| Column | Type | Constraints / Description |
|---|---|---|
| id | SERIAL | 主键 |
| name | VARCHAR(255) | 唯一、非空 |
| slug | VARCHAR(255) | 唯一 |
| parent_id | INTEGER | 自引用 FK → categories.id |
| description | TEXT | 类别描述 |
| icon | VARCHAR(100) | 图标标识符 |
| display_order | INTEGER | 默认: 0 |
| created_at | TIMESTAMP | 创建时间戳 |
索引
parent_idslug
pricing_tiers
| Column | Type | Constraints / Description |
|---|---|---|
| id | SERIAL | 主键 |
| tool_id | INTEGER | FK → tools.id (CASCADE) |
| tier_name | VARCHAR(100) | Free、Starter、Pro |
| monthly_price | DECIMAL(10,2) | 可为空 |
| annual_price | DECIMAL(10,2) | 可为空 |
| currency | VARCHAR(3) | 默认: USD |
| billing_cycle | ENUM | monthly、annual、one-time |
| features_json | JSONB | 灵活的功能列表 |
| limits_json | JSONB | API 限制、用户数、存储等 |
| is_current | BOOLEAN | 默认: true |
| effective_from | TIMESTAMP | 定价开始时间 |
| effective_to | TIMESTAMP | 可为空 |
| created_at | TIMESTAMP | 创建时间戳 |
索引
(tool_id, is_current)(effective_from, effective_to)
alternatives
| Column | Type | Constraints / Description |
|---|---|---|
| id | SERIAL | 主键 |
| tool_id | INTEGER | FK → tools.id |
| alternative_id | INTEGER | FK → tools.id |
| similarity_score | DECIMAL(5,2) | 范围: 0–100 |
| match_basis | ENUM | features、pricing、category |
| comparison_notes | TEXT | 对比细节 |
| upvotes | INTEGER | 默认: 0 |
| created_at | TIMESTAMP | 创建时间戳 |
| updated_at | TIMESTAMP | 更新时间戳 |
约束
UNIQUE(tool_id, alternative_id)tool_id <> alternative_id
索引
tool_idsimilarity_score DESC
reviews_aggregate
| Column | Type | Constraints / Description |
|---|---|---|
| id | SERIAL | 主键 |
| tool_id | INTEGER | FK → tools.id |
| source | VARCHAR(50) | g2、capterra、producthunt |
| avg_rating | DECIMAL(3,2) | 范围: 0–5 |
| total_reviews | INTEGER | 评论数量 |
| rating_breakdown | JSONB | 例如 {5:120,4:45,...} |
| source_url | VARCHAR(500) | 评论页面 URL |
| last_scraped_at | TIMESTAMP | 抓取时间 |
| created_at | TIMESTAMP | 创建时间戳 |
索引
(tool_id, source)avg_rating DESC
features
| Column | Type | Constraints / Description |
|---|---|---|
| id | SERIAL | 主键 |
| tool_id | INTEGER | FK → tools.id |
| feature_name | VARCHAR(255) | 功能名称 |
| feature_category | VARCHAR(100) | Auth、API、Database |
| is_available | BOOLEAN | 默认: true |
| tier_availability | VARCHAR(50) | free、pro、all |
| description | TEXT | 功能详情 |
| created_at | TIMESTAMP | 创建时间戳 |
索引
tool_idfeature_categoryis_available
changelog
| Column | Type | Constraints / Description |
|---|---|---|
| id | SERIAL | 主键 |
| tool_id | INTEGER | FK → tools.id |
| change_type | ENUM | pricing、feature、update |
| change_summary | VARCHAR(500) | 简短摘要 |
| change_details | TEXT | 详细变更 |
| old_value | JSONB | 旧值 |
| new_value | JSONB | 新值 |
| changed_at | TIMESTAMP | 变更发生时间 |
| created_at | TIMESTAMP | 创建时间戳 |
索引
(tool_id, changed_at DESC)change_type
integrations
| Column | Type | Constraints / Description |
|---|---|---|
| id | SERIAL | 主键 |
| tool_id | INTEGER | FK → tools.id |
| integrates_with | INTEGER | FK → tools.id |
| integration_type | ENUM | native、api、webhook、zapier |
| ease_of_setup | ENUM | easy、medium、complex |
| documentation_url | VARCHAR(500) | 文档链接 |
| is_official | BOOLEAN | 默认: false |
| created_at | TIMESTAMP | 创建时间戳 |
索引
tool_idintegrates_with
API 文档
Tools API
1️⃣ 获取全部工具
端点
GET /tools/
查询参数
| 参数 | 类型 | 描述 |
|---|---|---|
category | string (optional) | 按类别过滤 |
price_min | number (optional) | 最低价格 |
price_max | number (optional) | 最高价格 |
features | array of strings (optional) | 必需的功能 |
sort | string (default: “name”) | 排序字段 |
page | number (default: 1) | 页码 |
size | number (default: 10) | 每页条目数 |
响应示例
{
"items": [
{
"id": 1,
"name": "VS Code",
"slug": "vs-code",
"category_id": 3,
"description": "Free source‑code editor",
"website_url": "https://code.visualstudio.com/",
"logo_url": "https://example.com/logo.png",
"is_active": true,
"query_count": 124,
"last_queried_at": "2025-11-01T12:34:56Z"
}
// …more tools
],
"page": 1,
"size": 10,
"total_items": 342,
"total_pages": 35
}
2️⃣ 获取工具详情
端点
GET /tools/{id}/
路径参数
id– 工具的整数 ID。
响应示例
{
"id": 1,
"name": "VS Code",
"slug": "vs-code",
"category": {
"id": 3,
"name": "IDE"
},
"description": "Free source‑code editor",
"website_url": "https://code.visualstudio.com/",
"logo_url": "https://example.com/logo.png",
"features": [
{ "name": "IntelliSense", "available": true },
{ "name": "Debugging", "available": true }
],
"pricing_tiers": [
{ "tier_name": "Free", "monthly_price": null, "annual_price": null }
],
"reviews": {
"avg_rating": 4.7,
"total_reviews": 215
}
}
3️⃣ 搜索工具
端点
GET /tools/search/
查询参数
| 参数 | 类型 | 描述 |
|---|---|---|
q | string | 搜索词(名称、标语等) |
page | number | 页码(默认 1) |
size | number | 每页条目数(默认 10) |
响应 – 与 获取全部工具 的结构相同,只是已按搜索词过滤。
Categories API
端点
GET /categories/
返回工具类别列表及其层级结构。
Pricing Tiers API
端点
GET /tools/{id}/pricing/
提供指定工具的当前及历史定价信息。
Alternatives API
端点
GET /tools/{id}/alternatives/
返回基于相似度得分排序的替代工具列表。
Reviews Aggregate API
端点
GET /tools/{id}/reviews/
聚合来自外部来源(G2、Capterra、Product Hunt)的评分。
Features API
端点
GET /tools/{id}/features/
列出工具的所有功能,按类别和套餐可用性分组。
Changelog API
端点
GET /tools/{id}/changelog/
提供变更的时间顺序列表(定价、功能、更新等)。
Integrations API
端点
GET /tools/{id}/integrations/
展示该工具的原生及第三方集成情况。